From f00f74740e42d08cc6823d094b78aedf87e4cff8 Mon Sep 17 00:00:00 2001 From: Guangrong Fu Date: Wed, 17 Aug 2022 08:41:44 +0800 Subject: [PATCH] bugfix - username capitalization problem Issue-ID: HOLMES-564 Signed-off-by: Guangrong Fu Change-Id: Ifa350d406f5fc7549c88bf5b50a8bc111d76fd8c --- holmes-actions/pom.xml | 2 +- .../org/onap/holmes/common/database/DbDaoUtil.java | 2 +- .../dmaap/store/ClosedLoopControlNameCache.java | 2 +- .../common/dmaap/store/UniqueRequestIdCache.java | 2 +- .../common/engine/dao/EngineEntityMapper.java | 2 +- .../onap/holmes/common/utils/AlarmInfoMapper.java | 2 +- .../holmes/common/utils/CorrelationRuleMapper.java | 2 +- .../org/onap/holmes/common/utils/GsonUtil.java | 2 +- .../org/onap/holmes/common/utils/UserUtil.java | 13 +++++------ .../org/onap/holmes/common/utils/UserUtilTest.java | 25 ++++++++++------------ pom.xml | 2 +- version.properties | 2 +- 12 files changed, 26 insertions(+), 32 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 @@ org.onap.holmes.common holmes-common-parent - 1.4.3-SNAPSHOT + 1.4.4-SNAPSHOT holmes-common-service 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. *

* 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. *

* 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)); } } diff --git a/pom.xml b/pom.xml index cda749e..19a1f22 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ holmes-common-parent pom - 1.4.3-SNAPSHOT + 1.4.4-SNAPSHOT holmes-common holmes-actions diff --git a/version.properties b/version.properties index 5abc35c..4761c30 100644 --- a/version.properties +++ b/version.properties @@ -4,7 +4,7 @@ major=1 minor=4 -patch=3 +patch=4 base_version=${major}.${minor}.${patch} -- 2.16.6