diff options
author | Guangrong Fu <fu.guangrong@zte.com.cn> | 2022-08-17 08:41:44 +0800 |
---|---|---|
committer | Guangrong Fu <fu.guangrong@zte.com.cn> | 2022-08-17 08:41:44 +0800 |
commit | f00f74740e42d08cc6823d094b78aedf87e4cff8 (patch) | |
tree | 95a3e311741feecdb328f8ebddc883b5b9773631 /holmes-actions | |
parent | f01cd76e0eb8f6a4ea78b26c60e3a37d7d4dd6ae (diff) |
bugfix - username capitalization problem
Issue-ID: HOLMES-564
Signed-off-by: Guangrong Fu <fu.guangrong@zte.com.cn>
Change-Id: Ifa350d406f5fc7549c88bf5b50a8bc111d76fd8c
Diffstat (limited to 'holmes-actions')
10 files changed, 24 insertions, 30 deletions
diff --git a/holmes-actions/pom.xml b/holmes-actions/pom.xml index 8c74bca..5687d18 100644 --- a/holmes-actions/pom.xml +++ b/holmes-actions/pom.xml @@ -12,7 +12,7 @@ <parent>
<groupId>org.onap.holmes.common</groupId>
<artifactId>holmes-common-parent</artifactId>
- <version>1.4.3-SNAPSHOT</version>
+ <version>1.4.4-SNAPSHOT</version>
</parent>
<name>holmes-common-service</name>
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/database/DbDaoUtil.java b/holmes-actions/src/main/java/org/onap/holmes/common/database/DbDaoUtil.java index 2cbb538..15f49e4 100644 --- a/holmes-actions/src/main/java/org/onap/holmes/common/database/DbDaoUtil.java +++ b/holmes-actions/src/main/java/org/onap/holmes/common/database/DbDaoUtil.java @@ -1,5 +1,5 @@ /**
- * Copyright 2017-2021 ZTE Corporation.
+ * Copyright 2017-2022 ZTE Corporation.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/dmaap/store/ClosedLoopControlNameCache.java b/holmes-actions/src/main/java/org/onap/holmes/common/dmaap/store/ClosedLoopControlNameCache.java index 89514dc..cd47431 100644 --- a/holmes-actions/src/main/java/org/onap/holmes/common/dmaap/store/ClosedLoopControlNameCache.java +++ b/holmes-actions/src/main/java/org/onap/holmes/common/dmaap/store/ClosedLoopControlNameCache.java @@ -1,5 +1,5 @@ /* - * Copyright 2020-2021 ZTE Corporation. + * Copyright 2020-2022 ZTE Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/dmaap/store/UniqueRequestIdCache.java b/holmes-actions/src/main/java/org/onap/holmes/common/dmaap/store/UniqueRequestIdCache.java index 8c68776..6a65b0c 100644 --- a/holmes-actions/src/main/java/org/onap/holmes/common/dmaap/store/UniqueRequestIdCache.java +++ b/holmes-actions/src/main/java/org/onap/holmes/common/dmaap/store/UniqueRequestIdCache.java @@ -1,5 +1,5 @@ /* - * Copyright 2020-2021 ZTE Corporation. + * Copyright 2020-2022 ZTE Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/engine/dao/EngineEntityMapper.java b/holmes-actions/src/main/java/org/onap/holmes/common/engine/dao/EngineEntityMapper.java index 5432027..3dc652e 100644 --- a/holmes-actions/src/main/java/org/onap/holmes/common/engine/dao/EngineEntityMapper.java +++ b/holmes-actions/src/main/java/org/onap/holmes/common/engine/dao/EngineEntityMapper.java @@ -1,5 +1,5 @@ /** - * Copyright 2020-2021 ZTE Corporation. + * Copyright 2020-2022 ZTE Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/utils/AlarmInfoMapper.java b/holmes-actions/src/main/java/org/onap/holmes/common/utils/AlarmInfoMapper.java index 996df25..e9755e8 100644 --- a/holmes-actions/src/main/java/org/onap/holmes/common/utils/AlarmInfoMapper.java +++ b/holmes-actions/src/main/java/org/onap/holmes/common/utils/AlarmInfoMapper.java @@ -1,5 +1,5 @@ /**
- * Copyright 2017-2021 ZTE Corporation.
+ * Copyright 2017-2022 ZTE Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/utils/CorrelationRuleMapper.java b/holmes-actions/src/main/java/org/onap/holmes/common/utils/CorrelationRuleMapper.java index ed1c581..835d059 100644 --- a/holmes-actions/src/main/java/org/onap/holmes/common/utils/CorrelationRuleMapper.java +++ b/holmes-actions/src/main/java/org/onap/holmes/common/utils/CorrelationRuleMapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2017-2021 ZTE Corporation. + * Copyright 2017-2022 ZTE Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/utils/GsonUtil.java b/holmes-actions/src/main/java/org/onap/holmes/common/utils/GsonUtil.java index f5ad56c..e43a68e 100644 --- a/holmes-actions/src/main/java/org/onap/holmes/common/utils/GsonUtil.java +++ b/holmes-actions/src/main/java/org/onap/holmes/common/utils/GsonUtil.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2021 ZTE Corporation. + * Copyright 2018-2022 ZTE Corporation. * <p> * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/utils/UserUtil.java b/holmes-actions/src/main/java/org/onap/holmes/common/utils/UserUtil.java index f0ff8d9..5400b20 100644 --- a/holmes-actions/src/main/java/org/onap/holmes/common/utils/UserUtil.java +++ b/holmes-actions/src/main/java/org/onap/holmes/common/utils/UserUtil.java @@ -1,5 +1,5 @@ /**
- * Copyright 2017 ZTE Corporation.
+ * Copyright 2017-2022 ZTE Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,9 +15,10 @@ */
package org.onap.holmes.common.utils;
-import javax.servlet.http.HttpServletRequest;
import org.onap.holmes.common.constant.AlarmConst;
+import javax.servlet.http.HttpServletRequest;
+
public class UserUtil {
private UserUtil() {
@@ -25,11 +26,7 @@ public class UserUtil { }
public static String getUserName(HttpServletRequest request) {
- String userName = AlarmConst.ADMIN;
- String sessionName = request.getHeader("username");
- if (sessionName != null) {
- userName = sessionName.toLowerCase();
- }
- return userName;
+ return request.getHeader("username") == null ?
+ AlarmConst.ADMIN : request.getHeader("username");
}
}
diff --git a/holmes-actions/src/test/java/org/onap/holmes/common/utils/UserUtilTest.java b/holmes-actions/src/test/java/org/onap/holmes/common/utils/UserUtilTest.java index d88525a..7b452f0 100644 --- a/holmes-actions/src/test/java/org/onap/holmes/common/utils/UserUtilTest.java +++ b/holmes-actions/src/test/java/org/onap/holmes/common/utils/UserUtilTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2017 ZTE Corporation. + * Copyright 2017-2022 ZTE Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,15 +16,16 @@ package org.onap.holmes.common.utils; -import static org.hamcrest.core.IsEqual.equalTo; -import static org.junit.Assert.assertThat; - -import javax.servlet.http.HttpServletRequest; import org.easymock.EasyMock; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.powermock.api.easymock.PowerMock; + +import javax.servlet.http.HttpServletRequest; + +import static org.hamcrest.core.IsEqual.equalTo; +import static org.junit.Assert.assertThat; public class UserUtilTest { private HttpServletRequest request; @@ -39,29 +40,25 @@ public class UserUtilTest { } @Test - public void getUserName_header_name_empty() throws Exception { + public void getUserName_header_name_empty() { EasyMock.expect(request.getHeader("username")).andReturn(null); PowerMock.replayAll(); - String userName = UserUtil.getUserName(request); + assertThat("admin", equalTo(UserUtil.getUserName(request))); PowerMock.verifyAll(); - - assertThat("admin", equalTo(userName)); } @Test - public void getUserName_normal() throws Exception { - EasyMock.expect(request.getHeader("username")).andReturn("name1"); + public void getUserName_normal() { + EasyMock.expect(request.getHeader("username")).andReturn("Name").times(2); PowerMock.replayAll(); - String userName = UserUtil.getUserName(request); + assertThat("Name", equalTo(UserUtil.getUserName(request))); PowerMock.verifyAll(); - - assertThat("name1", equalTo(userName)); } } |