<parent>\r
<groupId>org.onap.holmes.common</groupId>\r
<artifactId>holmes-common-parent</artifactId>\r
- <version>1.4.3-SNAPSHOT</version>\r
+ <version>1.4.4-SNAPSHOT</version>\r
</parent>\r
\r
<name>holmes-common-service</name>\r
/**\r
- * Copyright 2017-2021 ZTE Corporation.\r
+ * Copyright 2017-2022 ZTE Corporation.\r
* <p>\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
/*
- * 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.
/*
- * 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.
/**
- * 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.
/**\r
- * Copyright 2017-2021 ZTE Corporation.\r
+ * Copyright 2017-2022 ZTE Corporation.\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
/*
- * 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.
/**
- * 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.
/**\r
- * Copyright 2017 ZTE Corporation.\r
+ * Copyright 2017-2022 ZTE Corporation.\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
*/\r
package org.onap.holmes.common.utils;\r
\r
-import javax.servlet.http.HttpServletRequest;\r
import org.onap.holmes.common.constant.AlarmConst;\r
\r
+import javax.servlet.http.HttpServletRequest;\r
+\r
public class UserUtil {\r
\r
private UserUtil() {\r
}\r
\r
public static String getUserName(HttpServletRequest request) {\r
- String userName = AlarmConst.ADMIN;\r
- String sessionName = request.getHeader("username");\r
- if (sessionName != null) {\r
- userName = sessionName.toLowerCase();\r
- }\r
- return userName;\r
+ return request.getHeader("username") == null ?\r
+ AlarmConst.ADMIN : request.getHeader("username");\r
}\r
}\r
/**
- * 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.
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;
}
@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));
}
}
<artifactId>holmes-common-parent</artifactId>\r
<packaging>pom</packaging>\r
\r
- <version>1.4.3-SNAPSHOT</version>\r
+ <version>1.4.4-SNAPSHOT</version>\r
<name>holmes-common</name>\r
<modules>\r
<module>holmes-actions</module>\r
\r
major=1\r
minor=4\r
-patch=3\r
+patch=4\r
\r
base_version=${major}.${minor}.${patch}\r
\r