summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-aaf
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk/epsdk-aaf')
-rw-r--r--ecomp-sdk/epsdk-aaf/pom.xml35
-rw-r--r--ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessPerms.java2
-rw-r--r--ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessPermsDetail.java2
-rw-r--r--ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRole.java2
-rw-r--r--ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRolePerms.java2
-rw-r--r--ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessUser.java2
-rw-r--r--ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessUserRoleDetail.java2
-rw-r--r--ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAuthUserRole.java2
-rw-r--r--ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalRoleDescription.java2
-rw-r--r--ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/exception/UserNotFoundException.java2
-rw-r--r--ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/service/LoginExternalAuthService.java2
-rw-r--r--ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/service/LoginExternalAuthServiceImpl.java4
-rw-r--r--ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/service/UserApiService.java2
-rw-r--r--ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/service/UserApiServiceImpl.java46
-rw-r--r--ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/util/EcompExternalAuthProperties.java2
-rw-r--r--ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/util/EcompExternalAuthUtils.java6
-rw-r--r--ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessPermsDetailTest.java94
-rw-r--r--ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessPermsTest.java86
-rw-r--r--ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRolePermsTest.java68
-rw-r--r--ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRoleTest.java59
-rw-r--r--ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessUserRoleDetailTest.java99
-rw-r--r--ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessUserTest.java56
-rw-r--r--ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAuthUserRoleTest.java64
-rw-r--r--ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalRoleDescriptionTest.java94
-rw-r--r--ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/service/LoginExternalAuthServiceImplTest.java185
-rw-r--r--ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/service/UserApiServiceImplTest.java313
-rw-r--r--ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/util/EcompExternalAuthPropertiesTest.java59
-rw-r--r--ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/util/EcompExternalAuthUtilsTest.java127
-rw-r--r--ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/framework/MockitoTestSuite.java94
29 files changed, 1463 insertions, 50 deletions
diff --git a/ecomp-sdk/epsdk-aaf/pom.xml b/ecomp-sdk/epsdk-aaf/pom.xml
index cccfc833..f3d22f61 100644
--- a/ecomp-sdk/epsdk-aaf/pom.xml
+++ b/ecomp-sdk/epsdk-aaf/pom.xml
@@ -1,16 +1,18 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+<?xml version="1.0"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.portal.sdk</groupId>
<artifactId>epsdk-project</artifactId>
- <version>2.4.0-SNAPSHOT</version>
+ <version>2.5.0-SNAPSHOT</version>
</parent>
<groupId>org.onap.portal.sdk</groupId>
<artifactId>epsdk-aaf</artifactId>
- <version>2.4.0-SNAPSHOT</version>
+ <version>2.5.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>ONAP Portal SDK AAF Authorization</name>
@@ -49,6 +51,25 @@
<artifactId>eelf-core</artifactId>
<version>1.0.0</version>
</dependency>
+ <!-- Jacoco for offline instrumentation -->
+ <dependency>
+ <groupId>org.jacoco</groupId>
+ <artifactId>org.jacoco.agent</artifactId>
+ <version>${jacoco.version}</version>
+ <classifier>runtime</classifier>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <version>1.10.19</version>
+ <scope>test</scope>
+ </dependency>
<!-- Spring -->
<dependency>
<groupId>org.springframework</groupId>
@@ -117,12 +138,6 @@
<artifactId>jackson-databind</artifactId>
<version>2.6.3</version>
</dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- <scope>test</scope>
- </dependency>
</dependencies>
<profiles>
<!-- disable doclint, a new feature in Java 8, when generating javadoc -->
@@ -154,7 +169,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
- <version>3.1</version>
+ <version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
diff --git a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessPerms.java b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessPerms.java
index 80956e64..a598a4c4 100644
--- a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessPerms.java
+++ b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessPerms.java
@@ -33,7 +33,7 @@
*
* ============LICENSE_END============================================
*
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ *
*/
package org.onap.portalsdk.external.authorization.domain;
diff --git a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessPermsDetail.java b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessPermsDetail.java
index fab7d2c0..47c613b0 100644
--- a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessPermsDetail.java
+++ b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessPermsDetail.java
@@ -33,7 +33,7 @@
*
* ============LICENSE_END============================================
*
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ *
*/
package org.onap.portalsdk.external.authorization.domain;
diff --git a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRole.java b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRole.java
index a14a4b5f..8c191181 100644
--- a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRole.java
+++ b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRole.java
@@ -33,7 +33,7 @@
*
* ============LICENSE_END============================================
*
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ *
*/
package org.onap.portalsdk.external.authorization.domain;
diff --git a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRolePerms.java b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRolePerms.java
index f38b2f9f..95b4f0c4 100644
--- a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRolePerms.java
+++ b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRolePerms.java
@@ -33,7 +33,7 @@
*
* ============LICENSE_END============================================
*
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ *
*/
package org.onap.portalsdk.external.authorization.domain;
diff --git a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessUser.java b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessUser.java
index 3ca88991..aafd9c1b 100644
--- a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessUser.java
+++ b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessUser.java
@@ -33,7 +33,7 @@
*
* ============LICENSE_END============================================
*
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ *
*/
package org.onap.portalsdk.external.authorization.domain;
diff --git a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessUserRoleDetail.java b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessUserRoleDetail.java
index 5106f387..929bd351 100644
--- a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessUserRoleDetail.java
+++ b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessUserRoleDetail.java
@@ -33,7 +33,7 @@
*
* ============LICENSE_END============================================
*
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ *
*/
package org.onap.portalsdk.external.authorization.domain;
diff --git a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAuthUserRole.java b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAuthUserRole.java
index 33e21f2c..67d83ff6 100644
--- a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAuthUserRole.java
+++ b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAuthUserRole.java
@@ -33,7 +33,7 @@
*
* ============LICENSE_END============================================
*
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ *
*/
package org.onap.portalsdk.external.authorization.domain;
diff --git a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalRoleDescription.java b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalRoleDescription.java
index d09db15d..68effb0c 100644
--- a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalRoleDescription.java
+++ b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalRoleDescription.java
@@ -33,7 +33,7 @@
*
* ============LICENSE_END============================================
*
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ *
*/
package org.onap.portalsdk.external.authorization.domain;
diff --git a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/exception/UserNotFoundException.java b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/exception/UserNotFoundException.java
index 8d15b44c..785bbf95 100644
--- a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/exception/UserNotFoundException.java
+++ b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/exception/UserNotFoundException.java
@@ -33,7 +33,7 @@
*
* ============LICENSE_END============================================
*
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ *
*/
package org.onap.portalsdk.external.authorization.exception;
diff --git a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/service/LoginExternalAuthService.java b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/service/LoginExternalAuthService.java
index 8f387f98..0ad02460 100644
--- a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/service/LoginExternalAuthService.java
+++ b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/service/LoginExternalAuthService.java
@@ -33,7 +33,7 @@
*
* ============LICENSE_END============================================
*
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ *
*/
package org.onap.portalsdk.external.authorization.service;
diff --git a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/service/LoginExternalAuthServiceImpl.java b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/service/LoginExternalAuthServiceImpl.java
index d2ccfc2e..173e9e7d 100644
--- a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/service/LoginExternalAuthServiceImpl.java
+++ b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/service/LoginExternalAuthServiceImpl.java
@@ -33,7 +33,7 @@
*
* ============LICENSE_END============================================
*
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ *
*/
package org.onap.portalsdk.external.authorization.service;
@@ -59,6 +59,7 @@ import org.onap.portalsdk.core.web.support.AppUtils;
import org.onap.portalsdk.core.web.support.UserUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
@Service("loginExternalAuthService")
public class LoginExternalAuthServiceImpl implements LoginExternalAuthService {
@@ -79,6 +80,7 @@ public class LoginExternalAuthServiceImpl implements LoginExternalAuthService {
@Override
@SuppressWarnings("rawtypes")
+ @Transactional
public LoginBean findUser(LoginBean bean, String menuPropertiesFilename, Map additionalParams,
boolean matchPassword, HttpServletRequest request) throws Exception {
diff --git a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/service/UserApiService.java b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/service/UserApiService.java
index 6eb312b6..14aeaf5e 100644
--- a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/service/UserApiService.java
+++ b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/service/UserApiService.java
@@ -33,7 +33,7 @@
*
* ============LICENSE_END============================================
*
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ *
*/
package org.onap.portalsdk.external.authorization.service;
diff --git a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/service/UserApiServiceImpl.java b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/service/UserApiServiceImpl.java
index 8425f7da..fb320c17 100644
--- a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/service/UserApiServiceImpl.java
+++ b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/service/UserApiServiceImpl.java
@@ -33,7 +33,7 @@
*
* ============LICENSE_END============================================
*
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ *
*/
package org.onap.portalsdk.external.authorization.service;
@@ -207,28 +207,30 @@ public class UserApiServiceImpl implements UserApiService {
role.setPriority(Integer.valueOf(roleDesc.getPriority()));
}
}
- for (ExternalAccessPerms extPerm : roleDesc.getPermissions()) {
- RoleFunction roleFunction = new RoleFunction();
- roleFunction.setCode(extPerm.getInstance());
- roleFunction.setAction(extPerm.getAction());
- if (extPerm.getDescription() != null
- && EcompExternalAuthUtils.checkNameSpaceMatching(extPerm.getType(), namespace)) {
- roleFunction.setName(extPerm.getDescription());
- } else if (extPerm.getDescription() == null
- && EcompExternalAuthUtils.checkNameSpaceMatching(extPerm.getType(), namespace)) {
- roleFunction.setName(extPerm.getType().substring(namespace.length() + 1) + "|"
- + extPerm.getInstance() + "|" + extPerm.getAction());
- } else if (extPerm.getDescription() == null
- && !EcompExternalAuthUtils.checkNameSpaceMatching(extPerm.getType(), namespace)) {
- roleFunction.setName(
- extPerm.getType() + "|" + extPerm.getInstance() + "|" + extPerm.getAction());
+ if (roleDesc.getPermissions() != null) {
+ for (ExternalAccessPerms extPerm : roleDesc.getPermissions()) {
+ RoleFunction roleFunction = new RoleFunction();
+ roleFunction.setCode(extPerm.getInstance());
+ roleFunction.setAction(extPerm.getAction());
+ if (extPerm.getDescription() != null
+ && EcompExternalAuthUtils.checkNameSpaceMatching(extPerm.getType(), namespace)) {
+ roleFunction.setName(extPerm.getDescription());
+ } else if (extPerm.getDescription() == null
+ && EcompExternalAuthUtils.checkNameSpaceMatching(extPerm.getType(), namespace)) {
+ roleFunction.setName(extPerm.getType().substring(namespace.length() + 1) + "|"
+ + extPerm.getInstance() + "|" + extPerm.getAction());
+ } else if (extPerm.getDescription() == null
+ && !EcompExternalAuthUtils.checkNameSpaceMatching(extPerm.getType(), namespace)) {
+ roleFunction.setName(
+ extPerm.getType() + "|" + extPerm.getInstance() + "|" + extPerm.getAction());
+ }
+ if (EcompExternalAuthUtils.checkNameSpaceMatching(extPerm.getType(), namespace)) {
+ roleFunction.setType(extPerm.getType().substring(namespace.length() + 1));
+ } else {
+ roleFunction.setType(extPerm.getType());
+ }
+ roleFunctions.add(roleFunction);
}
- if (EcompExternalAuthUtils.checkNameSpaceMatching(extPerm.getType(), namespace)) {
- roleFunction.setType(extPerm.getType().substring(namespace.length() + 1));
- } else {
- roleFunction.setType(extPerm.getType());
- }
- roleFunctions.add(roleFunction);
}
}
role.setRoleFunctions(roleFunctions);
diff --git a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/util/EcompExternalAuthProperties.java b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/util/EcompExternalAuthProperties.java
index a680a672..87d4c1fd 100644
--- a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/util/EcompExternalAuthProperties.java
+++ b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/util/EcompExternalAuthProperties.java
@@ -33,7 +33,7 @@
*
* ============LICENSE_END============================================
*
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ *
*/
package org.onap.portalsdk.external.authorization.util;
diff --git a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/util/EcompExternalAuthUtils.java b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/util/EcompExternalAuthUtils.java
index 56b1527e..6f4ff29a 100644
--- a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/util/EcompExternalAuthUtils.java
+++ b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/util/EcompExternalAuthUtils.java
@@ -33,7 +33,7 @@
*
* ============LICENSE_END============================================
*
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ *
*/
package org.onap.portalsdk.external.authorization.util;
@@ -44,7 +44,6 @@ import javax.xml.bind.DatatypeConverter;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.portalsdk.core.onboarding.util.CipherUtil;
import org.onap.portalsdk.core.util.SystemProperties;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
@@ -53,9 +52,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
public class EcompExternalAuthUtils {
private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(EcompExternalAuthUtils.class);
-
- @Autowired
- CipherUtil cipherUtil;
public static final String EXT_EMPTY_JSON_STRING = "{}";
public static final String EXT_ROLE_FIELD = "role";
diff --git a/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessPermsDetailTest.java b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessPermsDetailTest.java
new file mode 100644
index 00000000..43dcc827
--- /dev/null
+++ b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessPermsDetailTest.java
@@ -0,0 +1,94 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ *
+ */
+package org.onap.portalsdk.external.authorization.domain;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Test;
+
+public class ExternalAccessPermsDetailTest {
+
+ public ExternalAccessPermsDetail mockExternalAccessPermsDetailTest() {
+ List<String> roles = new ArrayList<>();
+ roles.add("test_role");
+ roles.add("test_role2");
+ ExternalAccessPermsDetail mockExtPermsDetailTest = new ExternalAccessPermsDetail();
+ mockExtPermsDetailTest.setAction("*");
+ mockExtPermsDetailTest.setDescription("test_name");
+ mockExtPermsDetailTest.setType("test_type");
+ mockExtPermsDetailTest.setInstance("test_instance");
+ mockExtPermsDetailTest.setRoles(roles);
+ return mockExtPermsDetailTest;
+ }
+
+ @Test
+ public void externalAccessPermsDetailTest() {
+ List<String> roles = new ArrayList<>();
+ roles.add("test_role");
+ roles.add("test_role2");
+ ExternalAccessPermsDetail extPermsDetailTest = new ExternalAccessPermsDetail();
+ ExternalAccessPermsDetail extPermsDetailTest2 = new ExternalAccessPermsDetail("test_type", "test_instance", "*",
+ "test_name");
+ ExternalAccessPermsDetail extPermsDetailTest3 = new ExternalAccessPermsDetail("test_type", "test_instance", "*",
+ roles, "test_name");
+ extPermsDetailTest.setAction("*");
+ extPermsDetailTest.setDescription("test_name");
+ extPermsDetailTest.setType("test_type");
+ extPermsDetailTest.setInstance("test_instance");
+ extPermsDetailTest.setRoles(roles);
+ assertEquals(extPermsDetailTest.getAction(), mockExternalAccessPermsDetailTest().getAction());
+ assertEquals(extPermsDetailTest.getType(), mockExternalAccessPermsDetailTest().getType());
+ assertEquals(extPermsDetailTest.getInstance(), mockExternalAccessPermsDetailTest().getInstance());
+ assertEquals(extPermsDetailTest.getDescription(), mockExternalAccessPermsDetailTest().getDescription());
+ assertEquals(extPermsDetailTest.getRoles(), mockExternalAccessPermsDetailTest().getRoles());
+ assertEquals(extPermsDetailTest2.getAction(), mockExternalAccessPermsDetailTest().getAction());
+ assertEquals(extPermsDetailTest2.getType(), mockExternalAccessPermsDetailTest().getType());
+ assertEquals(extPermsDetailTest2.getInstance(), mockExternalAccessPermsDetailTest().getInstance());
+ assertEquals(extPermsDetailTest2.getDescription(), mockExternalAccessPermsDetailTest().getDescription());
+ assertEquals(extPermsDetailTest2.getRoles(), null);
+ assertEquals(extPermsDetailTest3.getAction(), mockExternalAccessPermsDetailTest().getAction());
+ assertEquals(extPermsDetailTest3.getType(), mockExternalAccessPermsDetailTest().getType());
+ assertEquals(extPermsDetailTest3.getInstance(), mockExternalAccessPermsDetailTest().getInstance());
+ assertEquals(extPermsDetailTest3.getDescription(), mockExternalAccessPermsDetailTest().getDescription());
+ assertEquals(extPermsDetailTest3.getRoles(), mockExternalAccessPermsDetailTest().getRoles());
+ }
+
+}
diff --git a/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessPermsTest.java b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessPermsTest.java
new file mode 100644
index 00000000..0f3a65a5
--- /dev/null
+++ b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessPermsTest.java
@@ -0,0 +1,86 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ *
+ */
+package org.onap.portalsdk.external.authorization.domain;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Test;
+
+public class ExternalAccessPermsTest {
+
+ public ExternalAccessPerms mockExternalAccessPermsTest() {
+ ExternalAccessPerms mockExtPermsTest = new ExternalAccessPerms();
+ mockExtPermsTest.setAction("*");
+ mockExtPermsTest.setDescription("test_name");
+ mockExtPermsTest.setType("test_type");
+ mockExtPermsTest.setInstance("test_instance");
+ return mockExtPermsTest;
+ }
+
+ @Test
+ public void externalAccessPermsTest() {
+ List<String> roles = new ArrayList<>();
+ roles.add("test_role");
+ roles.add("test_role2");
+ ExternalAccessPerms extPermsDetailTest = new ExternalAccessPerms();
+ ExternalAccessPerms extPermsDetailTest2 = new ExternalAccessPerms("test_type", "test_instance", "*");
+ ExternalAccessPerms extPermsDetailTest3 = new ExternalAccessPerms("test_type", "test_instance", "*",
+ "test_name");
+ extPermsDetailTest.setAction("*");
+ extPermsDetailTest.setDescription("test_name");
+ extPermsDetailTest.setType("test_type");
+ extPermsDetailTest.setInstance("test_instance");
+ assertEquals(extPermsDetailTest.getAction(), mockExternalAccessPermsTest().getAction());
+ assertEquals(extPermsDetailTest.getType(), mockExternalAccessPermsTest().getType());
+ assertEquals(extPermsDetailTest.getInstance(), mockExternalAccessPermsTest().getInstance());
+ assertEquals(extPermsDetailTest.getDescription(), mockExternalAccessPermsTest().getDescription());
+ assertEquals(extPermsDetailTest2.getAction(), mockExternalAccessPermsTest().getAction());
+ assertEquals(extPermsDetailTest2.getType(), mockExternalAccessPermsTest().getType());
+ assertEquals(extPermsDetailTest2.getInstance(), mockExternalAccessPermsTest().getInstance());
+ assertEquals(null, extPermsDetailTest2.getDescription());
+ assertEquals(extPermsDetailTest3.getAction(), mockExternalAccessPermsTest().getAction());
+ assertEquals(extPermsDetailTest3.getType(), mockExternalAccessPermsTest().getType());
+ assertEquals(extPermsDetailTest3.getInstance(), mockExternalAccessPermsTest().getInstance());
+ assertEquals(extPermsDetailTest3.getDescription(), mockExternalAccessPermsTest().getDescription());
+ assertEquals(true, new ExternalAccessPerms("test_type", "test_instance", "*", "test_name")
+ .equals(new ExternalAccessPerms("test_type", "test_instance", "*", "test_name")));
+ }
+}
diff --git a/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRolePermsTest.java b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRolePermsTest.java
new file mode 100644
index 00000000..acb14c65
--- /dev/null
+++ b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRolePermsTest.java
@@ -0,0 +1,68 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ *
+ */
+package org.onap.portalsdk.external.authorization.domain;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class ExternalAccessRolePermsTest {
+
+ public ExternalAccessRolePerms mockExternalAccessRolePermsTest() {
+ ExternalAccessPerms mockPerm = new ExternalAccessPerms();
+ mockPerm.setAction("*");
+ mockPerm.setDescription("test_name");
+ mockPerm.setType("test_type");
+ mockPerm.setInstance("test_instance");
+ ExternalAccessRolePerms mockExtRolePermsTest = new ExternalAccessRolePerms(mockPerm, "test_role");
+ return mockExtRolePermsTest;
+ }
+
+ @Test
+ public void externalAccessRolePermsTest() {
+ ExternalAccessPerms perm = new ExternalAccessPerms();
+ perm.setAction("*");
+ perm.setDescription("test_name");
+ perm.setType("test_type");
+ perm.setInstance("test_instance");
+ ExternalAccessRolePerms mockExtRolePermsTest = new ExternalAccessRolePerms(perm, "test_role");
+ assertEquals(mockExtRolePermsTest.getRole(), mockExternalAccessRolePermsTest().getRole());
+ assertEquals(mockExtRolePermsTest.getPerm(), mockExternalAccessRolePermsTest().getPerm());
+ }
+
+}
diff --git a/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRoleTest.java b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRoleTest.java
new file mode 100644
index 00000000..aa498aa0
--- /dev/null
+++ b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRoleTest.java
@@ -0,0 +1,59 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ *
+ */
+package org.onap.portalsdk.external.authorization.domain;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class ExternalAccessRoleTest {
+
+ public ExternalAccessRole mockExternalAccessRoleTest() {
+ ExternalAccessRole mockRole = new ExternalAccessRole();
+ mockRole.setName("test_role");
+ mockRole.setDescription("test_role_description");
+ return mockRole;
+ }
+
+ @Test
+ public void externalAccessRolePermsTest() {
+ ExternalAccessRole role = new ExternalAccessRole("test_role", "test_role_description");
+ assertEquals(role.getName(), mockExternalAccessRoleTest().getName());
+ assertEquals(role.getDescription(), mockExternalAccessRoleTest().getDescription());
+ }
+}
diff --git a/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessUserRoleDetailTest.java b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessUserRoleDetailTest.java
new file mode 100644
index 00000000..5e750543
--- /dev/null
+++ b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessUserRoleDetailTest.java
@@ -0,0 +1,99 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ *
+ */
+package org.onap.portalsdk.external.authorization.domain;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Test;
+
+public class ExternalAccessUserRoleDetailTest {
+
+ public ExternalAccessUserRoleDetail mockExternalAccessUserRoleDetailTest() {
+ List<ExternalAccessPerms> mockPerms = new ArrayList<>();
+ ExternalAccessPerms mockExtPermsTest = new ExternalAccessPerms();
+ mockExtPermsTest.setAction("*");
+ mockExtPermsTest.setDescription("test_name");
+ mockExtPermsTest.setType("test_type");
+ mockExtPermsTest.setInstance("test_instance");
+ mockPerms.add(mockExtPermsTest);
+ ExternalRoleDescription mockRoleDesc = new ExternalRoleDescription();
+ mockRoleDesc.setActive("true");
+ mockRoleDesc.setAppId("1");
+ mockRoleDesc.setAppRoleId("1");
+ mockRoleDesc.setId("1");
+ mockRoleDesc.setPriority("1");
+ mockRoleDesc.setName("test");
+ mockRoleDesc.setPermissions(mockPerms);
+ ExternalAccessUserRoleDetail mockExtUserRoleDetailTest = new ExternalAccessUserRoleDetail();
+ mockExtUserRoleDetailTest.setName("test");
+ mockExtUserRoleDetailTest.setDescription(mockRoleDesc);
+ return mockExtUserRoleDetailTest;
+ }
+
+ @Test
+ public void externalAccessPermsTest() {
+ List<ExternalAccessPerms> perms = new ArrayList<>();
+ ExternalAccessPerms extPermsTest = new ExternalAccessPerms();
+ extPermsTest.setAction("*");
+ extPermsTest.setDescription("test_name");
+ extPermsTest.setType("test_type");
+ extPermsTest.setInstance("test_instance");
+ perms.add(extPermsTest);
+ ExternalRoleDescription roleDesc = new ExternalRoleDescription();
+ roleDesc.setActive("true");
+ roleDesc.setAppId("1");
+ roleDesc.setAppRoleId("1");
+ roleDesc.setId("1");
+ roleDesc.setPriority("1");
+ roleDesc.setName("test");
+ roleDesc.setPermissions(perms);
+ ExternalAccessUserRoleDetail extUserRoleDetailTest = new ExternalAccessUserRoleDetail();
+ extUserRoleDetailTest.setName("test");
+ extUserRoleDetailTest.setDescription(roleDesc);
+ ExternalAccessUserRoleDetail extUserRoleDetailTest2 = new ExternalAccessUserRoleDetail("test", roleDesc);
+ assertEquals(extUserRoleDetailTest.getName(), mockExternalAccessUserRoleDetailTest().getName());
+ assertEquals(extUserRoleDetailTest.getDescription(), mockExternalAccessUserRoleDetailTest().getDescription());
+ assertEquals(extUserRoleDetailTest2.getName(), mockExternalAccessUserRoleDetailTest().getName());
+ assertEquals(extUserRoleDetailTest2.getDescription(), mockExternalAccessUserRoleDetailTest().getDescription());
+ assertEquals(true, new ExternalAccessUserRoleDetail("test",roleDesc)
+ .equals(new ExternalAccessUserRoleDetail("test",roleDesc)));
+ }
+}
diff --git a/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessUserTest.java b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessUserTest.java
new file mode 100644
index 00000000..18909b74
--- /dev/null
+++ b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessUserTest.java
@@ -0,0 +1,56 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ *
+ */
+package org.onap.portalsdk.external.authorization.domain;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class ExternalAccessUserTest {
+
+ public ExternalAccessUser mockExternalAccessUserTest() {
+ return new ExternalAccessUser("test", "test123");
+ }
+
+ @Test
+ public void externalAccessUserTest() {
+ ExternalAccessUser extUserTest = new ExternalAccessUser("test", "test123");
+ assertEquals(extUserTest.getUser(), mockExternalAccessUserTest().getUser());
+ assertEquals(extUserTest.getRole(), mockExternalAccessUserTest().getRole());
+ }
+}
diff --git a/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAuthUserRoleTest.java b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAuthUserRoleTest.java
new file mode 100644
index 00000000..c295a537
--- /dev/null
+++ b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAuthUserRoleTest.java
@@ -0,0 +1,64 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ *
+ */
+package org.onap.portalsdk.external.authorization.domain;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class ExternalAuthUserRoleTest {
+
+ public ExternalAuthUserRole mockExternalAccessUserTest() {
+ ExternalAuthUserRole mockExtAuthUserRole = new ExternalAuthUserRole();
+ mockExtAuthUserRole.setUser("test123");
+ mockExtAuthUserRole.setRole("test");
+ mockExtAuthUserRole.setExpiryDate("1/1/1111");
+ return mockExtAuthUserRole;
+ }
+
+ @Test
+ public void externalAuthUserRoleTest() {
+ ExternalAuthUserRole extAuthUserRole = new ExternalAuthUserRole();
+ extAuthUserRole.setUser("test123");
+ extAuthUserRole.setRole("test");
+ extAuthUserRole.setExpiryDate("1/1/1111");
+ assertEquals(extAuthUserRole.getRole(), mockExternalAccessUserTest().getRole());
+ assertEquals(extAuthUserRole.getUser(), mockExternalAccessUserTest().getUser());
+ assertEquals(extAuthUserRole.getExpiryDate(), mockExternalAccessUserTest().getExpiryDate());
+ }
+}
diff --git a/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalRoleDescriptionTest.java b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalRoleDescriptionTest.java
new file mode 100644
index 00000000..251f8303
--- /dev/null
+++ b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalRoleDescriptionTest.java
@@ -0,0 +1,94 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ *
+ */
+package org.onap.portalsdk.external.authorization.domain;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Test;
+
+public class ExternalRoleDescriptionTest {
+
+ public ExternalRoleDescription mockExternalRoleDescriptionTest() {
+ List<ExternalAccessPerms> mockPerms = new ArrayList<>();
+ ExternalAccessPerms mockExtPermsTest = new ExternalAccessPerms();
+ mockExtPermsTest.setAction("*");
+ mockExtPermsTest.setDescription("test_name");
+ mockExtPermsTest.setType("test_type");
+ mockExtPermsTest.setInstance("test_instance");
+ mockPerms.add(mockExtPermsTest);
+ ExternalRoleDescription mockExtRoleDesc = new ExternalRoleDescription();
+ mockExtRoleDesc.setActive("true");
+ mockExtRoleDesc.setAppRoleId("1");
+ mockExtRoleDesc.setAppId("1");
+ mockExtRoleDesc.setId("1");
+ mockExtRoleDesc.setName("test");
+ mockExtRoleDesc.setPermissions(mockPerms);
+ mockExtRoleDesc.setPriority("1");
+ return mockExtRoleDesc;
+ }
+
+ @Test
+ public void externalRoleDescriptionTest() {
+ List<ExternalAccessPerms> perms = new ArrayList<>();
+ ExternalAccessPerms extPermsTest = new ExternalAccessPerms();
+ extPermsTest.setAction("*");
+ extPermsTest.setDescription("test_name");
+ extPermsTest.setType("test_type");
+ extPermsTest.setInstance("test_instance");
+ perms.add(extPermsTest);
+ ExternalRoleDescription extRoleDesc = new ExternalRoleDescription();
+ extRoleDesc.setActive("true");
+ extRoleDesc.setAppRoleId("1");
+ extRoleDesc.setAppId("1");
+ extRoleDesc.setId("1");
+ extRoleDesc.setName("test");
+ extRoleDesc.setPermissions(perms);
+ extRoleDesc.setPriority("1");
+ assertEquals(extRoleDesc.getActive(), mockExternalRoleDescriptionTest().getActive());
+ assertEquals(extRoleDesc.getAppId(), mockExternalRoleDescriptionTest().getAppId());
+ assertEquals(extRoleDesc.getAppRoleId(), mockExternalRoleDescriptionTest().getAppRoleId());
+ assertEquals(extRoleDesc.getId(), mockExternalRoleDescriptionTest().getId());
+ assertEquals(extRoleDesc.getName(), mockExternalRoleDescriptionTest().getName());
+ assertEquals(extRoleDesc.getPriority(), mockExternalRoleDescriptionTest().getPriority());
+ assertEquals(extRoleDesc.getPermissions(), mockExternalRoleDescriptionTest().getPermissions());
+ assertEquals(true, extRoleDesc.equals(mockExternalRoleDescriptionTest()));
+ }
+}
diff --git a/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/service/LoginExternalAuthServiceImplTest.java b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/service/LoginExternalAuthServiceImplTest.java
new file mode 100644
index 00000000..ae6eb975
--- /dev/null
+++ b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/service/LoginExternalAuthServiceImplTest.java
@@ -0,0 +1,185 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ *
+ */
+package org.onap.portalsdk.external.authorization.service;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.onap.portalsdk.core.command.LoginBean;
+import org.onap.portalsdk.core.domain.App;
+import org.onap.portalsdk.core.domain.Role;
+import org.onap.portalsdk.core.domain.RoleFunction;
+import org.onap.portalsdk.core.domain.User;
+import org.onap.portalsdk.core.domain.UserApp;
+import org.onap.portalsdk.core.service.DataAccessService;
+import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.portalsdk.core.web.support.AppUtils;
+import org.onap.portalsdk.core.web.support.UserUtils;
+import org.onap.portalsdk.external.framework.MockitoTestSuite;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+@SuppressWarnings({ "unchecked", "rawtypes" })
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({AppUtils.class, UserUtils.class, SystemProperties.class})
+public class LoginExternalAuthServiceImplTest {
+
+ @InjectMocks
+ private LoginExternalAuthServiceImpl loginExternalAuthServiceImpl;
+
+ @Mock
+ private DataAccessService dataAccessService;
+
+ @Mock
+ private UserApiService userApiService;
+
+ MockitoTestSuite mockitoTestSuite = new MockitoTestSuite();
+
+ HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest();
+ HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse();
+
+ @Before
+ public void setup() {
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(UserUtils.class);
+ PowerMockito.mockStatic(SystemProperties.class);
+ }
+
+ private User userObj() {
+ User user = new User();
+ user.setEmail("test@mail.com");
+ user.setFirstName("Test_firstname");
+ user.setHrid("test_hrid");
+ user.setJobTitle("test_jobtitle");
+ user.setLastName("test_lastname");
+ user.setLoginId("test123");
+ user.setOrgManagerUserId("test456");
+ user.setMiddleInitial("test_middlename");
+ user.setOrgCode("testcode");
+ user.setOrgId(1l);
+ user.setOrgUserId("test123");
+ user.setActive(true);
+ user.setLastLoginDate(new Date());
+ RoleFunction roleFunction = new RoleFunction();
+ roleFunction.setId(12L);
+ roleFunction.setName("Role Function");
+
+ Set roleFunctions = new TreeSet();
+ roleFunctions.add(roleFunction);
+
+ Role role = new Role();
+ role.setName("Role");
+ role.setActive(true);
+ role.setRoleFunctions(roleFunctions);
+ Set userApps = new TreeSet();
+ UserApp userApp = new UserApp();
+ userApp.setUserId(1L);
+ userApp.setApp(getApp());
+ userApp.setRole(role);
+ userApps.add(userApp);
+ user.setUserApps(userApps);
+ return user;
+ }
+
+ public App getApp() {
+ App app = new App();
+ app.setId(new Long(1));
+ app.setName("Default");
+ return app;
+ }
+
+ @Test
+ public void findUserTest() throws Exception {
+ LoginBean bean = new LoginBean();
+ bean.setUserid("test123");
+ Map additionalParams = new HashMap<>();
+ User user = userObj();
+ user.setId(1l);
+ List usersId = new ArrayList<>();
+ usersId.add(user.getId());
+ List users = new ArrayList<>();
+ users.add(user);
+ Mockito.when(userApiService.getUser(bean.getUserid(), mockedRequest)).thenReturn(user);
+ Map<String, String> params = new HashMap<>();
+ params.put("orgUserId", "test123");
+ Mockito.when(dataAccessService.executeNamedQuery("getUserIdByorgUserId", params, null)).thenReturn(usersId);
+ Map<String, String> params2 = new HashMap<>();
+ params.put("org_user_id", "test123");
+ Mockito.when(dataAccessService.executeNamedQuery("getUserByOrgUserId", params2, new HashMap())).thenReturn(users);
+ LoginBean expected = loginExternalAuthServiceImpl.findUser(bean, "menu", additionalParams, mockedRequest);
+ assertNotNull(expected);
+ }
+
+ @Test
+ public void findUserForNewUserTest() throws Exception {
+ LoginBean bean = new LoginBean();
+ bean.setUserid("test123");
+ Map additionalParams = new HashMap<>();
+ User user = userObj();
+ List usersId = new ArrayList<>();
+ usersId.add(user.getId());
+ List users = new ArrayList<>();
+ users.add(user);
+ Mockito.when(userApiService.getUser(bean.getUserid(), mockedRequest)).thenReturn(user);
+ Map<String, String> params = new HashMap<>();
+ params.put("orgUserId", "test123");
+ Mockito.when(dataAccessService.executeNamedQuery("getUserIdByorgUserId", params, null)).thenReturn(usersId);
+ Map<String, String> params2 = new HashMap<>();
+ params.put("org_user_id", "test123");
+ Mockito.when(dataAccessService.executeNamedQuery("getUserByOrgUserId", params2, new HashMap())).thenReturn(null);
+ LoginBean expected = loginExternalAuthServiceImpl.findUser(bean, "menu", additionalParams, mockedRequest);
+ assertNotNull(expected);
+ }
+}
diff --git a/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/service/UserApiServiceImplTest.java b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/service/UserApiServiceImplTest.java
new file mode 100644
index 00000000..d93b03c1
--- /dev/null
+++ b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/service/UserApiServiceImplTest.java
@@ -0,0 +1,313 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ *
+ */
+package org.onap.portalsdk.external.authorization.service;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.json.JSONObject;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Matchers;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.onap.portalsdk.core.command.PostSearchBean;
+import org.onap.portalsdk.core.command.support.SearchResult;
+import org.onap.portalsdk.core.domain.App;
+import org.onap.portalsdk.core.domain.Role;
+import org.onap.portalsdk.core.domain.RoleFunction;
+import org.onap.portalsdk.core.domain.User;
+import org.onap.portalsdk.core.domain.UserApp;
+import org.onap.portalsdk.core.service.AppService;
+import org.onap.portalsdk.core.service.DataAccessService;
+import org.onap.portalsdk.core.service.LdapService;
+import org.onap.portalsdk.core.service.PostSearchService;
+import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.portalsdk.external.authorization.util.EcompExternalAuthProperties;
+import org.onap.portalsdk.external.authorization.util.EcompExternalAuthUtils;
+import org.onap.portalsdk.external.framework.MockitoTestSuite;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.client.RestTemplate;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+@SuppressWarnings({ "rawtypes", "unchecked" })
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({ EcompExternalAuthProperties.class, EcompExternalAuthUtils.class })
+public class UserApiServiceImplTest {
+
+ private static final String APP_ID = "appId";
+
+ private static final String PRIORITY = "priority";
+
+ private static final String ACTIVE = "active";
+
+ private static final String ROLE_NAME = "name";
+
+ private static final String APP_ROLE_ID = "appRoleId";
+
+ private static final String ID = "id";
+
+ @InjectMocks
+ private UserApiServiceImpl UserApiServiceImpl;
+
+ @Mock
+ private DataAccessService dataAccessService;
+
+ @Mock
+ private LoginExternalAuthService loginAAFService;
+
+ @Mock
+ private LdapService ldapService;
+
+ @Mock
+ private PostSearchService postSearchService;
+
+ @Mock
+ private AppService appService;
+
+ @Mock
+ RestTemplate template = new RestTemplate();
+
+ @Before
+ public void setup() throws Exception {
+ PowerMockito.mockStatic(EcompExternalAuthProperties.class);
+ PowerMockito.mockStatic(EcompExternalAuthUtils.class);
+ PowerMockito.mockStatic(SystemProperties.class);
+ Mockito.when(EcompExternalAuthProperties.getProperty(EcompExternalAuthProperties.EXTERNAL_AUTH_NAMESPACE))
+ .thenReturn("com.test.app2");
+ Mockito.when(EcompExternalAuthUtils.base64encodeKeyForAAFBasicAuth()).thenReturn(new HttpHeaders());
+ Mockito.when(EcompExternalAuthProperties.getProperty(EcompExternalAuthProperties.EXTERNAL_AUTH_USER_DOMAIN))
+ .thenReturn("@test.com");
+ MockitoAnnotations.initMocks(this);
+ }
+
+ MockitoTestSuite mockitoTestSuite = new MockitoTestSuite();
+
+ HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest();
+ HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse();
+
+ private User userObj() {
+ User user = new User();
+ user.setEmail("test@mail.com");
+ user.setFirstName("Test_firstname");
+ user.setHrid("test_hrid");
+ user.setJobTitle("test_jobtitle");
+ user.setLastName("test_lastname");
+ user.setLoginId("test123");
+ user.setOrgManagerUserId("test456");
+ user.setMiddleInitial("test_middlename");
+ user.setOrgCode("testcode");
+ user.setOrgId(1l);
+ user.setOrgUserId("test123");
+ user.setActive(true);
+ user.setLastLoginDate(new Date());
+ RoleFunction roleFunction = new RoleFunction();
+ roleFunction.setId(12L);
+ roleFunction.setName("Role Function");
+
+ Set roleFunctions = new TreeSet();
+ roleFunctions.add(roleFunction);
+
+ Role role = new Role();
+ role.setName("Role");
+ role.setActive(true);
+ role.setRoleFunctions(roleFunctions);
+ Set userApps = new TreeSet();
+ UserApp userApp = new UserApp();
+ userApp.setUserId(1L);
+ userApp.setApp(getApp());
+ userApp.setRole(role);
+ userApps.add(userApp);
+ user.setUserApps(userApps);
+ return user;
+ }
+
+ public App getApp() {
+ App app = new App();
+ app.setId(new Long(1));
+ app.setName("Default");
+ return app;
+ }
+
+ @Test
+ public void getUserTest() throws Exception {
+ ObjectMapper mapper = new ObjectMapper();
+ Map<String, String> roleDesc = new LinkedHashMap<>();
+ roleDesc.put(ID, "1");
+ roleDesc.put(ROLE_NAME, "test_role");
+ roleDesc.put(ACTIVE, String.valueOf(true));
+ roleDesc.put(PRIORITY, String.valueOf(1));
+ roleDesc.put(APP_ID, String.valueOf(1));
+ roleDesc.put(APP_ROLE_ID, String.valueOf(1l));
+ String addDesc = mapper.writeValueAsString(roleDesc);
+ JSONObject mockJsonObjectRole = new JSONObject();
+ JSONObject mockJsonObjectRole2 = new JSONObject();
+ JSONObject mockJsonObjectRole3 = new JSONObject();
+ JSONObject mockJsonObjectRole4 = new JSONObject();
+ JSONObject mockJsonObjectRole5 = new JSONObject();
+ JSONObject mockJsonObjectPerm1 = new JSONObject();
+ JSONObject mockJsonObjectPerm2 = new JSONObject();
+ mockJsonObjectPerm1.put("type", "com.test.app2.test_type");
+ mockJsonObjectPerm1.put("instance", "test_instance");
+ mockJsonObjectPerm1.put("action", "*");
+ mockJsonObjectPerm2.put("type", "com.test.app.test_type2");
+ mockJsonObjectPerm2.put("instance", "test_instance2");
+ mockJsonObjectPerm2.put("action", "*");
+ List<JSONObject> permsList = new ArrayList<>();
+ permsList.add(mockJsonObjectPerm1);
+ permsList.add(mockJsonObjectPerm2);
+ mockJsonObjectRole.put("name", "com.test.app2.test_role");
+ mockJsonObjectRole2.put("name", "com.test.app2.test_role2");
+ mockJsonObjectRole2.put("perms", permsList);
+ mockJsonObjectRole2.put("description", addDesc);
+ mockJsonObjectRole3.put("name", "com.test.app2.Account_Administrator");
+ mockJsonObjectRole4.put("name", "com.test.app2.admin");
+ mockJsonObjectRole5.put("name", "com.test.app2.owner");
+ List<JSONObject> userRolesList = new ArrayList<>();
+ JSONObject mockJsonObjectFinalUserRole = new JSONObject();
+ userRolesList.add(mockJsonObjectRole);
+ userRolesList.add(mockJsonObjectRole2);
+ userRolesList.add(mockJsonObjectRole3);
+ userRolesList.add(mockJsonObjectRole4);
+ userRolesList.add(mockJsonObjectRole5);
+ mockJsonObjectFinalUserRole.put("role", userRolesList);
+ Mockito.when(EcompExternalAuthUtils.isJSONValid(addDesc)).thenReturn(true);
+ ResponseEntity<String> response = new ResponseEntity<>(mockJsonObjectFinalUserRole.toString(), HttpStatus.OK);
+ Mockito.when(template.exchange(Matchers.anyString(), Matchers.eq(HttpMethod.GET),
+ Matchers.<HttpEntity<String>>any(), Matchers.eq(String.class))).thenReturn(response);
+ Mockito.when(EcompExternalAuthUtils.checkNameSpaceMatching(Matchers.anyString(), Matchers.anyString()))
+ .thenReturn(true);
+ Mockito.when(loginAAFService.findUserWithoutPwd("test123")).thenReturn(userObj());
+ Mockito.when(appService.getApp(1l)).thenReturn(getApp());
+ User actual = UserApiServiceImpl.getUser("test123", mockedRequest);
+ assertNotNull(actual);
+ }
+
+ @Test
+ public void getNewUserNullExceptionTest() throws Exception {
+ JSONObject mockJsonObjectRole = new JSONObject();
+ JSONObject mockJsonObjectRole2 = new JSONObject();
+ JSONObject mockJsonObjectRole3 = new JSONObject();
+ JSONObject mockJsonObjectPerm1 = new JSONObject();
+ JSONObject mockJsonObjectPerm2 = new JSONObject();
+ mockJsonObjectPerm1.put("type", "com.test.app2.test_type");
+ mockJsonObjectPerm1.put("instance", "test_instance");
+ mockJsonObjectPerm1.put("action", "*");
+ mockJsonObjectPerm2.put("type", "com.test.app.test_type2");
+ mockJsonObjectPerm2.put("instance", "test_instance2");
+ mockJsonObjectPerm2.put("action", "*");
+ List<JSONObject> permsList = new ArrayList<>();
+ permsList.add(mockJsonObjectPerm1);
+ permsList.add(mockJsonObjectPerm2);
+ mockJsonObjectRole.put("name", "com.test.app2.test_role");
+ mockJsonObjectRole2.put("name", "com.test.app2.test_role2");
+ mockJsonObjectRole2.put("perms", permsList);
+ mockJsonObjectRole3.put("name", "com.test.app2.Account_Administrator");
+ List<JSONObject> userRolesList = new ArrayList<>();
+ JSONObject mockJsonObjectFinalUserRole = new JSONObject();
+ userRolesList.add(mockJsonObjectRole);
+ userRolesList.add(mockJsonObjectRole2);
+ userRolesList.add(mockJsonObjectRole3);
+ mockJsonObjectFinalUserRole.put("role", userRolesList);
+ ResponseEntity<String> response = new ResponseEntity<>(mockJsonObjectFinalUserRole.toString(), HttpStatus.OK);
+ Mockito.when(template.exchange(Matchers.anyString(), Matchers.eq(HttpMethod.GET),
+ Matchers.<HttpEntity<String>>any(), Matchers.eq(String.class))).thenReturn(response);
+ Mockito.when(EcompExternalAuthUtils.checkNameSpaceMatching(Matchers.anyString(), Matchers.anyString()))
+ .thenReturn(true);
+ Mockito.when(loginAAFService.findUserWithoutPwd("test123")).thenReturn(null);
+ Mockito.when(appService.getApp(1l)).thenReturn(getApp());
+ PostSearchBean postSearchBean = new PostSearchBean();
+ postSearchBean.setOrgUserId("test123");
+ SearchResult result = new SearchResult();
+ result.add(userObj());
+ Mockito.when(ldapService.searchPost(postSearchBean.getUser(), postSearchBean.getSortBy1(),
+ postSearchBean.getSortBy2(), postSearchBean.getSortBy3(), postSearchBean.getPageNo(),
+ postSearchBean.getNewDataSize(), 1)).thenReturn(result);
+ User user = UserApiServiceImpl.getUser("test123", mockedRequest);
+ assertNull(user);
+ }
+
+ @Test
+ public void getRoleFunctionsTest() throws Exception {
+ JSONObject mockJsonObjectPerms = new JSONObject();
+ JSONObject mockJsonObjectPerm1 = new JSONObject();
+ JSONObject mockJsonObjectPerm2 = new JSONObject();
+ JSONObject mockJsonObjectPerm3 = new JSONObject();
+ mockJsonObjectPerm1.put("type", "com.test.app2.test_type");
+ mockJsonObjectPerm1.put("instance", "test_instance");
+ mockJsonObjectPerm1.put("action", "*");
+ mockJsonObjectPerm2.put("type", "com.test.app2.test_type2");
+ mockJsonObjectPerm2.put("instance", "test_instance2");
+ mockJsonObjectPerm2.put("action", "*");
+ mockJsonObjectPerm2.put("description", "test_name");
+ mockJsonObjectPerm3.put("type", "com.test.app3.test_type3");
+ mockJsonObjectPerm3.put("instance", "test_instance3");
+ mockJsonObjectPerm3.put("action", "*");
+ List<JSONObject> permsList = new ArrayList<>();
+ permsList.add(mockJsonObjectPerm1);
+ permsList.add(mockJsonObjectPerm2);
+ mockJsonObjectPerms.put("perm", permsList);
+ ResponseEntity<String> response = new ResponseEntity<>(mockJsonObjectPerms.toString(), HttpStatus.OK);
+ Mockito.when(template.exchange(Matchers.anyString(), Matchers.eq(HttpMethod.GET),
+ Matchers.<HttpEntity<String>>any(), Matchers.eq(String.class))).thenReturn(response);
+ List<RoleFunction> actual = UserApiServiceImpl.getRoleFunctions("test123");
+ assertNotNull(actual);
+ }
+}
diff --git a/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/util/EcompExternalAuthPropertiesTest.java b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/util/EcompExternalAuthPropertiesTest.java
new file mode 100644
index 00000000..24c19622
--- /dev/null
+++ b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/util/EcompExternalAuthPropertiesTest.java
@@ -0,0 +1,59 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ *
+ */
+package org.onap.portalsdk.external.authorization.util;
+
+import static org.junit.Assert.assertNull;
+
+import java.util.Properties;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({ Properties.class })
+public class EcompExternalAuthPropertiesTest {
+
+ @Test
+ public void getPropertyTest() {
+ String actual = EcompExternalAuthProperties.getProperty("test");
+ assertNull(actual);
+ }
+
+}
diff --git a/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/util/EcompExternalAuthUtilsTest.java b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/util/EcompExternalAuthUtilsTest.java
new file mode 100644
index 00000000..b35a1cda
--- /dev/null
+++ b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/util/EcompExternalAuthUtilsTest.java
@@ -0,0 +1,127 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ *
+ */
+package org.onap.portalsdk.external.authorization.util;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.onap.portalsdk.core.onboarding.util.CipherUtil;
+import org.onap.portalsdk.core.util.SystemProperties;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.springframework.http.HttpHeaders;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({ EcompExternalAuthProperties.class, CipherUtil.class })
+public class EcompExternalAuthUtilsTest {
+
+ public static final String EXT_EMPTY_JSON_STRING = "{}";
+ public static final String EXT_ROLE_FIELD = "role";
+ public static final String EXT_PERM_FIELD = "perm";
+ public static final String EXT_PERM_FIELD_TYPE = "type";
+ public static final String EXT_PERM_ACCESS = ".access";
+ public static final String EXT_ROLE_FIELD_NAME = "name";
+ public static final String EXT_NULL_VALUE = "null";
+ public static final String EXT_FIELD_DESCRIPTION = "description";
+ public static final String EXT_FIELD_PERMS = "perms";
+ public static final String EXT_ROLE_FIELD_OWNER = ".owner";
+ public static final String EXT_ROLE_FIELD_ADMIN = ".admin";
+
+ @Before
+ public void setup() {
+ PowerMockito.mockStatic(EcompExternalAuthProperties.class);
+ PowerMockito.mockStatic(CipherUtil.class);
+ Mockito.when(EcompExternalAuthProperties.getProperty(EcompExternalAuthProperties.EXTERNAL_AUTH_USER_NAME))
+ .thenReturn("test_username");
+ Mockito.when(EcompExternalAuthProperties.getProperty(EcompExternalAuthProperties.EXTERNAL_AUTH_PASSWORD))
+ .thenReturn("test_password");
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void base64encodeKeyForAAFBasicAuthTest() throws Exception {
+ Mockito.when(
+ CipherUtil.decryptPKC("test_password", SystemProperties.getProperty(SystemProperties.Decryption_Key)))
+ .thenReturn("test_decrypted_password");
+ HttpHeaders actual = EcompExternalAuthUtils.base64encodeKeyForAAFBasicAuth();
+ assertNotNull(actual);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void base64encodeKeyForAAFBasicAuthDecryptPassExceptionTest() throws Exception {
+ Mockito.when(
+ CipherUtil.decryptPKC("test_password", SystemProperties.getProperty(SystemProperties.Decryption_Key)))
+ .thenThrow(new NullPointerException());
+ EcompExternalAuthUtils.base64encodeKeyForAAFBasicAuth();
+ }
+
+ @Test
+ public void checkNameSpaceMatchingTest() throws Exception {
+ EcompExternalAuthUtils.checkNameSpaceMatching("com.test.app.role.name", "com.test.app.role");
+ }
+
+ @Test
+ public void checkNameSpaceNotMatchingTest() throws Exception {
+ PowerMockito.mockStatic(EcompExternalAuthProperties.class);
+ EcompExternalAuthUtils.checkNameSpaceMatching("com.test.app2.role.name", "com.test.app.role");
+ }
+
+ @Test
+ public void checkNameSpaceMatchingLengthTest() throws Exception {
+ EcompExternalAuthUtils.checkNameSpaceMatching("com.test.app2.role", "com.test.app2.role.test");
+ }
+
+ @Test
+ public void isJsonValidTest() {
+ boolean actual = EcompExternalAuthUtils.isJSONValid("{\"test\":\"test\"}");
+ assertTrue(actual);
+ }
+
+ @Test
+ public void isJsonValidFailTest() {
+ boolean actual = EcompExternalAuthUtils.isJSONValid("{\"test\":\"test\"");
+ assertFalse(actual);
+ }
+}
diff --git a/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/framework/MockitoTestSuite.java b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/framework/MockitoTestSuite.java
new file mode 100644
index 00000000..adc1b27a
--- /dev/null
+++ b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/framework/MockitoTestSuite.java
@@ -0,0 +1,94 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ *
+ */
+package org.onap.portalsdk.external.framework;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+
+@RunWith(MockitoJUnitRunner.class)
+public class MockitoTestSuite {
+
+
+ public MockHttpServletRequestWrapper mockedRequest = new MockHttpServletRequestWrapper(
+ Mockito.mock(HttpServletRequest.class));
+ public HttpServletResponse mockedResponse = Mockito.mock(HttpServletResponse.class);
+
+ public MockHttpServletRequestWrapper getMockedRequest() {
+ return mockedRequest;
+ }
+
+ public HttpServletResponse getMockedResponse() {
+ return mockedResponse;
+ }
+
+ public class MockHttpServletRequestWrapper extends HttpServletRequestWrapper {
+
+ HttpSession session = Mockito.mock(HttpSession.class);
+
+ public MockHttpServletRequestWrapper(HttpServletRequest request) {
+ super(request);
+
+ }
+
+ @Override
+ public HttpSession getSession() {
+
+ return session;
+ }
+
+ @Override
+ public HttpSession getSession(boolean create) {
+
+ return session;
+ }
+
+ }
+
+ @Test
+ public void test()
+ {
+ assert(true);
+ }
+}