From fa5f20d91c416a855f0d6afe157db8250574617c Mon Sep 17 00:00:00 2001 From: st398c Date: Thu, 28 Mar 2019 16:30:03 -0400 Subject: Fortify, version, Junit Issue-ID: PORTAL-543, PORTAL-273, PORTAL-544 Change-Id: Ib864ef78bbd534170cab90d9314f2d8943f78872 Signed-off-by: Thota, Saisree --- .../authorization/domain/ExternalAccessPerms.java | 12 +- .../authorization/domain/ExternalAccessRole.java | 17 +-- .../domain/ExternalAccessRoleDescription.java | 142 --------------------- .../domain/ExternalAccessPermsTest.java | 12 -- .../domain/ExternalAccessRoleDescriptionTest.java | 74 ----------- .../domain/ExternalAccessRoleTest.java | 10 +- .../domain/ExternalAccessUserRoleDetailTest.java | 10 -- .../util/EcompExternalAuthUtilsTest.java | 14 -- 8 files changed, 5 insertions(+), 286 deletions(-) delete mode 100644 ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRoleDescription.java delete mode 100644 ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRoleDescriptionTest.java (limited to 'ecomp-sdk/epsdk-aaf/src') 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 a598a4c4..50496b5b 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 @@ -39,7 +39,7 @@ package org.onap.portalsdk.external.authorization.domain; import java.io.Serializable; -public class ExternalAccessPerms implements Serializable, Comparable { +public class ExternalAccessPerms implements Serializable { /** * @@ -122,16 +122,6 @@ public class ExternalAccessPerms implements Serializable, Comparable { this.description = description; } - @Override - public int compareTo(Object obj) { - ExternalAccessPerms other = (ExternalAccessPerms) obj; - - String c1 = getInstance(); - String c2 = other.getInstance(); - - return (c1 == null || c2 == null) ? 1 : c1.compareTo(c2); - } - @Override public int hashCode() { final int prime = 31; 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 2c6f3ff7..21c33ed3 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 @@ -46,18 +46,16 @@ public class ExternalAccessRole implements Serializable { public String name; private List perms; - public ExternalAccessRoleDescription description; public ExternalAccessRole() { super(); } - public ExternalAccessRole(String name, List ecPerms, ExternalAccessRoleDescription description) { + public ExternalAccessRole(String name, List ecPerms) { super(); this.name = name; this.perms = ecPerms; - this.description = description; } public String getName() { @@ -76,18 +74,10 @@ public class ExternalAccessRole implements Serializable { this.perms = perms; } - public ExternalAccessRoleDescription getDescription() { - return description; - } - public void setDescription(ExternalAccessRoleDescription description) { - this.description = description; - } - @Override public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((description == null) ? 0 : description.hashCode()); result = prime * result + ((name == null) ? 0 : name.hashCode()); result = prime * result + ((perms == null) ? 0 : perms.hashCode()); return result; @@ -102,11 +92,6 @@ public class ExternalAccessRole implements Serializable { if (getClass() != obj.getClass()) return false; ExternalAccessRole other = (ExternalAccessRole) obj; - if (description == null) { - if (other.description != null) - return false; - } else if (!description.equals(other.description)) - return false; if (name == null) { if (other.name != null) return false; diff --git a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRoleDescription.java b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRoleDescription.java deleted file mode 100644 index e7e18749..00000000 --- a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRoleDescription.java +++ /dev/null @@ -1,142 +0,0 @@ -/*- - * ============LICENSE_START========================================== - * ONAP Portal SDK - * =================================================================== - * Copyright (C) 2017-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; - -public class ExternalAccessRoleDescription { - - private String id; - private String name; - private String active; - private String priority; - private String appId; - private String appRoleId; - - public String getId() { - return id; - } - public void setId(String id) { - this.id = id; - } - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } - public String getActive() { - return active; - } - public void setActive(String active) { - this.active = active; - } - public String getPriority() { - return priority; - } - public void setPriority(String priority) { - this.priority = priority; - } - public String getAppId() { - return appId; - } - public void setAppId(String appId) { - this.appId = appId; - } - public String getAppRoleId() { - return appRoleId; - } - public void setAppRoleId(String appRoleId) { - this.appRoleId = appRoleId; - } - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((active == null) ? 0 : active.hashCode()); - result = prime * result + ((appId == null) ? 0 : appId.hashCode()); - result = prime * result + ((appRoleId == null) ? 0 : appRoleId.hashCode()); - result = prime * result + ((id == null) ? 0 : id.hashCode()); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((priority == null) ? 0 : priority.hashCode()); - return result; - } - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - ExternalAccessRoleDescription other = (ExternalAccessRoleDescription) obj; - if (active == null) { - if (other.active != null) - return false; - } else if (!active.equals(other.active)) - return false; - if (appId == null) { - if (other.appId != null) - return false; - } else if (!appId.equals(other.appId)) - return false; - if (appRoleId == null) { - if (other.appRoleId != null) - return false; - } else if (!appRoleId.equals(other.appRoleId)) - return false; - if (id == null) { - if (other.id != null) - return false; - } else if (!id.equals(other.id)) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (priority == null) { - if (other.priority != null) - return false; - } else if (!priority.equals(other.priority)) - return false; - return true; - } - - - - -} 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 index b118811b..b5645242 100644 --- 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 @@ -86,18 +86,6 @@ public class ExternalAccessPermsTest { .equals(new ExternalAccessPerms("test_type", "test_instance", "*", "test_name"))); } - @Test - public void testCompareTo() - { - ExternalAccessPerms extPermsDetailTest1 = new ExternalAccessPerms("test_type", "test_instance", "*"); - ExternalAccessPerms extPermsDetailTest2 = new ExternalAccessPerms("test_type", "test_instance", "*", - "test_name"); - extPermsDetailTest1.setInstance("test_instance"); - extPermsDetailTest2.setInstance("test_instance"); - int result= extPermsDetailTest1.compareTo(extPermsDetailTest2); - assertEquals(0, result); - } - @Test public void testHashCode() { diff --git a/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRoleDescriptionTest.java b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRoleDescriptionTest.java deleted file mode 100644 index 9e7970b2..00000000 --- a/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRoleDescriptionTest.java +++ /dev/null @@ -1,74 +0,0 @@ -/*- - * ============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 ExternalAccessRoleDescriptionTest { - - public ExternalAccessRoleDescription mockExternalRoleDescriptionTest() { - ExternalAccessRoleDescription mockExtRoleDesc = new ExternalAccessRoleDescription(); - mockExtRoleDesc.setActive("true"); - mockExtRoleDesc.setAppRoleId("1"); - mockExtRoleDesc.setAppId("1"); - mockExtRoleDesc.setId("1"); - mockExtRoleDesc.setName("test"); - mockExtRoleDesc.setPriority("1"); - return mockExtRoleDesc; - } - - @Test - public void externalRoleDescriptionTest() { - ExternalAccessRoleDescription extRoleDesc = new ExternalAccessRoleDescription(); - extRoleDesc.setActive("true"); - extRoleDesc.setAppRoleId("1"); - extRoleDesc.setAppId("1"); - extRoleDesc.setId("1"); - extRoleDesc.setName("test"); - 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(true, extRoleDesc.equals(mockExternalRoleDescriptionTest())); - } -} 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 index 557f5444..c4595a6d 100644 --- 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 @@ -56,18 +56,15 @@ public class ExternalAccessRoleTest { public ExternalAccessRole mockExternalAccessRoleTest() { ExternalAccessRole mockRole = new ExternalAccessRole(); - ExternalAccessRoleDescription roleDesc = new ExternalAccessRoleDescription(); + String roleDesc = ""; ExternalAccessPerms ecPerm = new ExternalAccessPerms(); List ecPerms = new ArrayList<>(); ecPerm.setAction("test_action"); ecPerm.setType("test_type"); ecPerm.setInstance("test_instance"); ecPerm.setDescription("test_description"); - roleDesc.setActive("true"); - roleDesc.setAppId("1"); mockRole.setName("test_role"); mockRole.setPerms(ecPerms); - mockRole.setDescription(roleDesc); return mockRole; } @@ -75,8 +72,8 @@ public class ExternalAccessRoleTest { public void setUp() { mockRole = mockExternalAccessRoleTest(); - role = new ExternalAccessRole(mockRole.getName(), mockRole.getPerms(), mockRole.getDescription()); - role1= new ExternalAccessRole(mockRole.getName(), mockRole.getPerms(), mockRole.getDescription());; + role = new ExternalAccessRole(mockRole.getName(), mockRole.getPerms()); + role1= new ExternalAccessRole(mockRole.getName(), mockRole.getPerms()); } @Test @@ -84,7 +81,6 @@ public class ExternalAccessRoleTest { assertEquals(role.getName(), mockExternalAccessRoleTest().getName()); assertEquals(role.getPerms(), mockExternalAccessRoleTest().getPerms()); - assertEquals(role.getDescription(), mockExternalAccessRoleTest().getDescription()); } @Test 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 index f0a0a69e..fd6d5309 100644 --- 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 @@ -58,16 +58,7 @@ public class ExternalAccessUserRoleDetailTest { mockExtPermsTest.setType("test_type"); mockExtPermsTest.setInstance("test_instance"); mockPerms.add(mockExtPermsTest); - ExternalAccessRoleDescription mockRoleDesc = new ExternalAccessRoleDescription(); - mockRoleDesc.setActive("true"); - mockRoleDesc.setAppId("1"); - mockRoleDesc.setAppRoleId("1"); - mockRoleDesc.setId("1"); - mockRoleDesc.setPriority("1"); - mockRoleDesc.setName("test"); - mockRoleDesc.setName("com.test.app.rolename"); role.setPerms(mockPerms); - role.setDescription(mockRoleDesc); ExternalAccessUserRoleDetail mockExtUserRoleDetailTest = new ExternalAccessUserRoleDetail(role); return mockExtUserRoleDetailTest; } @@ -78,7 +69,6 @@ public class ExternalAccessUserRoleDetailTest { ExternalAccessRole role = extUserRoleDetailTest2.getRole(); assertEquals(role.getName(), mockExternalAccessUserRoleDetailTest().getRole().getName()); assertEquals(role.getPerms(), mockExternalAccessUserRoleDetailTest().getRole().getPerms()); - assertEquals(role.getDescription(), mockExternalAccessUserRoleDetailTest().getRole().getDescription()); } 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 index 98260e20..d2f64725 100644 --- 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 @@ -37,9 +37,7 @@ */ 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 javax.xml.bind.DatatypeConverter; @@ -108,16 +106,4 @@ public class EcompExternalAuthUtilsTest { 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); - } } -- cgit 1.2.3-korg