Improve code coverage for aaf cadi modules 99/16799/1
authorsg481n <sg481n@att.com>
Sun, 1 Oct 2017 19:47:49 +0000 (19:47 +0000)
committersg481n <sg481n@att.com>
Sun, 1 Oct 2017 19:47:53 +0000 (19:47 +0000)
Issue-ID: AAF-79
Change-Id: I9e12b64024aaa5dad13965fdbfc474c330bae864
Signed-off-by: sg481n <sg481n@att.com>
13 files changed:
aaf/pom.xml
aaf/src/test/java/com/onap/aaf/cadi/aaf/AAFPermissionTest.java [new file with mode: 0644]
cass/pom.xml
cass/src/test/java/org/onap/aaf/cadi/aaf/cass/AAFAuthenticatedUserTest.java [new file with mode: 0644]
cass/src/test/java/org/onap/aaf/cadi/aaf/cass/AAFAuthenticatorTest.java [new file with mode: 0644]
cass/src/test/java/org/onap/aaf/cadi/aaf/cass/AAFAuthorizerTest.java [new file with mode: 0644]
cass/src/test/java/org/onap/aaf/cadi/aaf/cass/AAFBaseTest.java [new file with mode: 0644]
cass/src/test/java/org/onap/aaf/cadi/aaf/cass/JU_CASS.java [new file with mode: 0644]
client/pom.xml
core/pom.xml
core/src/test/java/org/onap/aaf/cadi/CadiExceptionTest.java [new file with mode: 0644]
core/src/test/java/org/onap/aaf/cadi/UserTest.java [new file with mode: 0644]
pom.xml

index dcbf36a..7593df6 100644 (file)
                        <groupId>org.onap.aaf.authz</groupId>\r
                        <artifactId>authz-client</artifactId>\r
                </dependency> \r
+               <dependency>\r
+                       <groupId>org.mockito</groupId>\r
+                       <artifactId>mockito-all</artifactId>\r
+                       </dependency>\r
 \r
                  <dependency>\r
                        <groupId>org.onap.aaf.cadi</groupId>\r
                        </plugin> \r
                        \r
                        <plugin>\r
-                               <groupId>org.jacoco</groupId>\r
-                               <artifactId>jacoco-maven-plugin</artifactId>\r
-                               <version>0.7.7.201606060606</version>\r
-                               <configuration>\r
-                                       <dumpOnExit>true</dumpOnExit>\r
-                               </configuration>\r
-                               <executions>\r
-                                       <execution>\r
-                                               <id>pre-unit-test</id>\r
-                                               <goals>\r
-                                                       <goal>prepare-agent</goal>\r
-                                               </goals>\r
-                                               <configuration>\r
-                                                       <destFile>${project.build.directory}/coverage-reports/jacoco.exec</destFile>\r
-                                                       <!-- <append>true</append> -->\r
-                                               </configuration>\r
-                                       </execution>\r
-                                       <execution>\r
-                                               <id>pre-integration-test</id>\r
-                                               <phase>pre-integration-test</phase>\r
-                                               <goals>\r
-                                                       <goal>prepare-agent</goal>\r
-                                               </goals>\r
-                                               <configuration>\r
-                                                       <destFile>${project.build.directory}/coverage-reports/jacoco-it.exec</destFile>\r
-                                                       <!-- <append>true</append> -->\r
-                                               </configuration>\r
-                                       </execution>\r
-                                       <execution>\r
-                        <goals>\r
-                            <goal>merge</goal>\r
-                        </goals>\r
-                        <phase>post-integration-test</phase>\r
-                        <configuration>\r
-                            <fileSets>\r
-                                <fileSet implementation="org.apache.maven.shared.model.fileset.FileSet">\r
-                                    <directory>${project.build.directory}/coverage-reports</directory>\r
-                                    <includes>\r
-                                        <include>*.exec</include>\r
-                                    </includes>\r
-                                </fileSet>\r
-                            </fileSets>\r
-                            <destFile>${project.build.directory}/jacoco-dev.exec</destFile>\r
-                        </configuration>\r
-                    </execution>\r
-                               </executions>\r
-                       </plugin>\r
+          <groupId>org.jacoco</groupId>\r
+          <artifactId>jacoco-maven-plugin</artifactId>\r
+          <version>${jacoco.version}</version>\r
+          <configuration>\r
+            <!-- Note: This exclusion list should match <sonar.exclusions>\r
+         property above -->\r
+            <excludes>\r
+              <exclude>**/gen/**</exclude>\r
+              <exclude>**/generated-sources/**</exclude>\r
+              <exclude>**/yang-gen/**</exclude>\r
+              <exclude>**/pax/**</exclude>\r
+            </excludes>\r
+          </configuration>\r
+          <executions>\r
+            <!--\r
+        Prepares the property pointing to the JaCoCo runtime agent which\r
+        is passed as VM argument when Maven the Surefire plugin is executed.\r
+        -->\r
+            <execution>\r
+              <id>pre-unit-test</id>\r
+              <goals>\r
+                <goal>prepare-agent</goal>\r
+              </goals>\r
+              <configuration>\r
+                <!-- Sets the path to the file which contains the execution data. -->\r
+                <destFile>${project.build.directory}/code-coverage/jacoco-ut.exec</destFile>\r
+                <!--\r
+            Sets the name of the property containing the settings\r
+            for JaCoCo runtime agent.\r
+        -->\r
+                <propertyName>surefireArgLine</propertyName>\r
+              </configuration>\r
+            </execution>\r
+            <!--\r
+        Ensures that the code coverage report for unit tests is created after\r
+        unit tests have been run.\r
+        -->\r
+            <execution>\r
+              <id>post-unit-test</id>\r
+              <phase>test</phase>\r
+              <goals>\r
+                <goal>report</goal>\r
+              </goals>\r
+              <configuration>\r
+                <!-- Sets the path to the file which contains the execution data. -->\r
+                <dataFile>${project.build.directory}/code-coverage/jacoco-ut.exec</dataFile>\r
+                <!-- Sets the output directory for the code coverage report. -->\r
+                <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>\r
+              </configuration>\r
+            </execution>\r
+            <execution>\r
+              <id>pre-integration-test</id>\r
+              <phase>pre-integration-test</phase>\r
+              <goals>\r
+                <goal>prepare-agent</goal>\r
+              </goals>\r
+              <configuration>\r
+                <!-- Sets the path to the file which contains the execution data. -->\r
+                <destFile>${project.build.directory}/code-coverage/jacoco-it.exec</destFile>\r
+                <!--\r
+            Sets the name of the property containing the settings\r
+            for JaCoCo runtime agent.\r
+        -->\r
+                <propertyName>failsafeArgLine</propertyName>\r
+              </configuration>\r
+            </execution>\r
+            <!--\r
+        Ensures that the code coverage report for integration tests after\r
+        integration tests have been run.\r
+        -->\r
+            <execution>\r
+              <id>post-integration-test</id>\r
+              <phase>post-integration-test</phase>\r
+              <goals>\r
+                <goal>report</goal>\r
+              </goals>\r
+              <configuration>\r
+                <!-- Sets the path to the file which contains the execution data. -->\r
+                <dataFile>${project.build.directory}/code-coverage/jacoco-it.exec</dataFile>\r
+                <!-- Sets the output directory for the code coverage report. -->\r
+                <outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory>\r
+              </configuration>\r
+            </execution>\r
+          </executions>\r
+        </plugin>                    \r
+\r
                </plugins>\r
        </build>\r
                <distributionManagement>\r
diff --git a/aaf/src/test/java/com/onap/aaf/cadi/aaf/AAFPermissionTest.java b/aaf/src/test/java/com/onap/aaf/cadi/aaf/AAFPermissionTest.java
new file mode 100644 (file)
index 0000000..d0b2bde
--- /dev/null
@@ -0,0 +1,80 @@
+/*******************************************************************************\r
+ * ============LICENSE_START====================================================\r
+ * * org.onap.aaf\r
+ * * ===========================================================================\r
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
+ * * ===========================================================================\r
+ * * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * * you may not use this file except in compliance with the License.\r
+ * * You may obtain a copy of the License at\r
+ * * \r
+ *  *      http://www.apache.org/licenses/LICENSE-2.0\r
+ * * \r
+ *  * Unless required by applicable law or agreed to in writing, software\r
+ * * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * * See the License for the specific language governing permissions and\r
+ * * limitations under the License.\r
+ * * ============LICENSE_END====================================================\r
+ * *\r
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ * *\r
+ ******************************************************************************/\r
+package com.onap.aaf.cadi.aaf;\r
+\r
+import static org.hamcrest.CoreMatchers.is;\r
+import static org.junit.Assert.*;\r
+import static org.mockito.Mockito.when;\r
+\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import org.mockito.Mock;\r
+import org.mockito.MockitoAnnotations;\r
+import org.onap.aaf.cadi.aaf.AAFPermission;\r
+import org.onap.aaf.cadi.lur.LocalPermission;\r
+\r
+public class AAFPermissionTest {\r
+\r
+       private static final String INSTANCE = "*";\r
+       private static final String ACTION = "*";\r
+       private static final String TYPE = "Auth";\r
+       private static final String KEY =TYPE + '|' + INSTANCE + '|' + ACTION;\r
+       \r
+       private String STRINGVALUE =\r
+       "AAFPermission:\n\tType: " + TYPE + \r
+       "\n\tInstance: " + INSTANCE +\r
+       "\n\tAction: " + ACTION +\r
+       "\n\tKey: " + KEY;\r
+\r
+       @Mock\r
+       private LocalPermission localPermission;\r
+       \r
+       @Mock\r
+       private LocalPermission localPermission2;\r
+\r
+       @Before\r
+       public void setup() {\r
+               MockitoAnnotations.initMocks(this);\r
+               when(localPermission.getKey()).thenReturn(TYPE);\r
+               when(localPermission2.getKey()).thenReturn(TYPE+" Default");\r
+       }\r
+       \r
+       @Test\r
+       public void test() {\r
+               AAFPermission permission = new AAFPermission(TYPE, INSTANCE, ACTION);\r
+               \r
+               assertTrue("This should Match",permission.match(permission));\r
+               \r
+               assertTrue("This should Match", permission.match(localPermission));\r
+               \r
+               assertFalse("This should Not Match", permission.match(localPermission2));\r
+               \r
+               assertThat(permission.getKey(), is(KEY));\r
+               \r
+               assertThat(permission.permType(), is("AAF"));\r
+               \r
+               assertThat(permission.toString(), is(STRINGVALUE));\r
+               \r
+       }\r
+\r
+}\r
index df97868..97a1663 100644 (file)
                                </configuration>\r
                        </plugin> \r
                        <plugin>\r
-                               <groupId>org.jacoco</groupId>\r
-                               <artifactId>jacoco-maven-plugin</artifactId>\r
-                               <version>0.7.7.201606060606</version>\r
-                               <configuration>\r
-                                       <dumpOnExit>true</dumpOnExit>\r
-                               </configuration>\r
-                               <executions>\r
-                                       <execution>\r
-                                               <id>pre-unit-test</id>\r
-                                               <goals>\r
-                                                       <goal>prepare-agent</goal>\r
-                                               </goals>\r
-                                               <configuration>\r
-                                                       <destFile>${project.build.directory}/coverage-reports/jacoco.exec</destFile>\r
-                                                       <!-- <append>true</append> -->\r
-                                               </configuration>\r
-                                       </execution>\r
-                                       <execution>\r
-                                               <id>pre-integration-test</id>\r
-                                               <phase>pre-integration-test</phase>\r
-                                               <goals>\r
-                                                       <goal>prepare-agent</goal>\r
-                                               </goals>\r
-                                               <configuration>\r
-                                                       <destFile>${project.build.directory}/coverage-reports/jacoco-it.exec</destFile>\r
-                                                       <!-- <append>true</append> -->\r
-                                               </configuration>\r
-                                       </execution>\r
-                                       <execution>\r
-                        <goals>\r
-                            <goal>merge</goal>\r
-                        </goals>\r
-                        <phase>post-integration-test</phase>\r
-                        <configuration>\r
-                            <fileSets>\r
-                                <fileSet implementation="org.apache.maven.shared.model.fileset.FileSet">\r
-                                    <directory>${project.build.directory}/coverage-reports</directory>\r
-                                    <includes>\r
-                                        <include>*.exec</include>\r
-                                    </includes>\r
-                                </fileSet>\r
-                            </fileSets>\r
-                            <destFile>${project.build.directory}/jacoco-dev.exec</destFile>\r
-                        </configuration>\r
-                    </execution>\r
-                               </executions>\r
-                       </plugin>\r
+          <groupId>org.jacoco</groupId>\r
+          <artifactId>jacoco-maven-plugin</artifactId>\r
+          <version>${jacoco.version}</version>\r
+          <configuration>\r
+            <!-- Note: This exclusion list should match <sonar.exclusions>\r
+         property above -->\r
+            <excludes>\r
+              <exclude>**/gen/**</exclude>\r
+              <exclude>**/generated-sources/**</exclude>\r
+              <exclude>**/yang-gen/**</exclude>\r
+              <exclude>**/pax/**</exclude>\r
+            </excludes>\r
+          </configuration>\r
+          <executions>\r
+            <!--\r
+        Prepares the property pointing to the JaCoCo runtime agent which\r
+        is passed as VM argument when Maven the Surefire plugin is executed.\r
+        -->\r
+            <execution>\r
+              <id>pre-unit-test</id>\r
+              <goals>\r
+                <goal>prepare-agent</goal>\r
+              </goals>\r
+              <configuration>\r
+                <!-- Sets the path to the file which contains the execution data. -->\r
+                <destFile>${project.build.directory}/code-coverage/jacoco-ut.exec</destFile>\r
+                <!--\r
+            Sets the name of the property containing the settings\r
+            for JaCoCo runtime agent.\r
+        -->\r
+                <propertyName>surefireArgLine</propertyName>\r
+              </configuration>\r
+            </execution>\r
+            <!--\r
+        Ensures that the code coverage report for unit tests is created after\r
+        unit tests have been run.\r
+        -->\r
+            <execution>\r
+              <id>post-unit-test</id>\r
+              <phase>test</phase>\r
+              <goals>\r
+                <goal>report</goal>\r
+              </goals>\r
+              <configuration>\r
+                <!-- Sets the path to the file which contains the execution data. -->\r
+                <dataFile>${project.build.directory}/code-coverage/jacoco-ut.exec</dataFile>\r
+                <!-- Sets the output directory for the code coverage report. -->\r
+                <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>\r
+              </configuration>\r
+            </execution>\r
+            <execution>\r
+              <id>pre-integration-test</id>\r
+              <phase>pre-integration-test</phase>\r
+              <goals>\r
+                <goal>prepare-agent</goal>\r
+              </goals>\r
+              <configuration>\r
+                <!-- Sets the path to the file which contains the execution data. -->\r
+                <destFile>${project.build.directory}/code-coverage/jacoco-it.exec</destFile>\r
+                <!--\r
+            Sets the name of the property containing the settings\r
+            for JaCoCo runtime agent.\r
+        -->\r
+                <propertyName>failsafeArgLine</propertyName>\r
+              </configuration>\r
+            </execution>\r
+            <!--\r
+        Ensures that the code coverage report for integration tests after\r
+        integration tests have been run.\r
+        -->\r
+            <execution>\r
+              <id>post-integration-test</id>\r
+              <phase>post-integration-test</phase>\r
+              <goals>\r
+                <goal>report</goal>\r
+              </goals>\r
+              <configuration>\r
+                <!-- Sets the path to the file which contains the execution data. -->\r
+                <dataFile>${project.build.directory}/code-coverage/jacoco-it.exec</dataFile>\r
+                <!-- Sets the output directory for the code coverage report. -->\r
+                <outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory>\r
+              </configuration>\r
+            </execution>\r
+          </executions>\r
+        </plugin>                    \r
+\r
                </plugins>\r
        </build>\r
                <distributionManagement>\r
diff --git a/cass/src/test/java/org/onap/aaf/cadi/aaf/cass/AAFAuthenticatedUserTest.java b/cass/src/test/java/org/onap/aaf/cadi/aaf/cass/AAFAuthenticatedUserTest.java
new file mode 100644 (file)
index 0000000..edfc1b9
--- /dev/null
@@ -0,0 +1,247 @@
+/*******************************************************************************\r
+ * ============LICENSE_START====================================================\r
+ * * org.onap.aaf\r
+ * * ===========================================================================\r
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
+ * * ===========================================================================\r
+ * * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * * you may not use this file except in compliance with the License.\r
+ * * You may obtain a copy of the License at\r
+ * * \r
+ *  *      http://www.apache.org/licenses/LICENSE-2.0\r
+ * * \r
+ *  * Unless required by applicable law or agreed to in writing, software\r
+ * * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * * See the License for the specific language governing permissions and\r
+ * * limitations under the License.\r
+ * * ============LICENSE_END====================================================\r
+ * *\r
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ * *\r
+ ******************************************************************************/\r
+package org.onap.aaf.cadi.aaf.cass;\r
+\r
+import static org.junit.Assert.*;\r
+\r
+import org.junit.Test;\r
+import org.onap.aaf.cadi.aaf.cass.AAFAuthenticatedUser;\r
+import org.junit.After;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import static org.junit.Assert.*;\r
+\r
+public class AAFAuthenticatedUserTest\r
+{\r
+       \r
+\r
+       @Before\r
+       public void setUp()\r
+       {\r
+               \r
+       }\r
+\r
+       @After\r
+       public void tearDown()\r
+       {\r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): if: (endIndex >= 0)\r
+        */\r
+       @Test\r
+       public void test_method_AAFAuthenticatedUser_0_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:AAFAuthenticatedUser Branch:0");\r
+               \r
+               //Constructor\r
+\r
+               \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): else: Not (endIndex >= 0)\r
+        */\r
+       @Test\r
+       public void test_method_AAFAuthenticatedUser_0_branch_1()\r
+       {\r
+               System.out.println("Now Testing Method:AAFAuthenticatedUser Branch:1");\r
+               \r
+               //Constructor\r
+               \r
+\r
+       \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): Default\r
+        */\r
+       @Test\r
+       public void test_method_getFullName_1_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:getFullName Branch:0");\r
+               \r
+\r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): Default\r
+        */\r
+       @Test\r
+       public void test_method_getName_2_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:getName Branch:0");\r
+               \r
+       \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): Default\r
+        */\r
+       @Test\r
+       public void test_method_isAnonymous_3_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:isAnonymous Branch:0");\r
+       \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): Default\r
+        */\r
+       @Test\r
+       public void test_method_setAnonymous_4_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:setAnonymous Branch:0");\r
+               \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): Default\r
+        */\r
+       @Test\r
+       public void test_method_getAnonymous_5_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:getAnonymous Branch:0");\r
+               \r
+               \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): Default\r
+        */\r
+       @Test\r
+       public void test_method_isSuper_6_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:isSuper Branch:0");\r
+               \r
+               \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): Default\r
+        */\r
+       @Test\r
+       public void test_method_setSuper_7_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:setSuper Branch:0");\r
+               \r
+               \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): Default\r
+        */\r
+       @Test\r
+       public void test_method_getSuper_8_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:getSuper Branch:0");\r
+               \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): Default\r
+        */\r
+       @Test\r
+       public void test_method_isLocal_9_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:isLocal Branch:0");\r
+               \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): Default\r
+        */\r
+       @Test\r
+       public void test_method_setLocal_10_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:setLocal Branch:0");\r
+               \r
+               \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): if: (this == o)\r
+        */\r
+       @Test\r
+       public void test_method_equals_11_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:equals Branch:0");\r
+               \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): else: Not (this == o)\r
+        */\r
+       @Test\r
+       public void test_method_equals_11_branch_1()\r
+       {\r
+               System.out.println("Now Testing Method:equals Branch:1");\r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): if: (!(o instanceof AAFAuthenticatedUser))\r
+        */\r
+       @Test\r
+       public void test_method_equals_11_branch_2()\r
+       {\r
+               System.out.println("Now Testing Method:equals Branch:2");\r
+       \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): else: Not (!(o instanceof AAFAuthenticatedUser))\r
+        */\r
+       @Test\r
+       public void test_method_equals_11_branch_3()\r
+       {\r
+               System.out.println("Now Testing Method:equals Branch:3");\r
+               \r
+       \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): Default\r
+        */\r
+       @Test\r
+       public void test_method_hashCode_12_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:hashCode Branch:0");\r
+               \r
+               \r
+               \r
+       }\r
+\r
+}\r
diff --git a/cass/src/test/java/org/onap/aaf/cadi/aaf/cass/AAFAuthenticatorTest.java b/cass/src/test/java/org/onap/aaf/cadi/aaf/cass/AAFAuthenticatorTest.java
new file mode 100644 (file)
index 0000000..adda54e
--- /dev/null
@@ -0,0 +1,292 @@
+/*******************************************************************************\r
+ * ============LICENSE_START====================================================\r
+ * * org.onap.aaf\r
+ * * ===========================================================================\r
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
+ * * ===========================================================================\r
+ * * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * * you may not use this file except in compliance with the License.\r
+ * * You may obtain a copy of the License at\r
+ * * \r
+ *  *      http://www.apache.org/licenses/LICENSE-2.0\r
+ * * \r
+ *  * Unless required by applicable law or agreed to in writing, software\r
+ * * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * * See the License for the specific language governing permissions and\r
+ * * limitations under the License.\r
+ * * ============LICENSE_END====================================================\r
+ * *\r
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ * *\r
+ ******************************************************************************/\r
+package org.onap.aaf.cadi.aaf.cass;\r
+\r
+import static org.junit.Assert.*;\r
+\r
+import org.apache.cassandra.exceptions.AuthenticationException;\r
+import org.junit.Test;\r
+import org.onap.aaf.cadi.aaf.cass.AAFAuthenticator;\r
+import org.junit.After;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import static org.junit.Assert.*;\r
+\r
+public class AAFAuthenticatorTest\r
+{\r
+       \r
+\r
+       @Before\r
+       public void setUp()\r
+       {\r
+               \r
+       }\r
+\r
+       @After\r
+       public void tearDown()\r
+       {\r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): Default\r
+        */\r
+       @Test\r
+       public void test_method_requireAuthentication_0_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:requireAuthentication Branch:0");\r
+               \r
+               //Constructor\r
+               AAFAuthenticator instance = new AAFAuthenticator();\r
+               \r
+               //Get expected result and result\r
+               Object expResult = null;\r
+               Object result = instance.requireAuthentication();\r
+               \r
+               //Check Return value\r
+               assertEquals(expResult, result);\r
+               \r
+               //Check Test Verification Points\r
+               assertEquals(null, instance.requireAuthentication());\r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): if: (username == null)\r
+        */\r
+       @Test\r
+       public void test_method_authenticate_1_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:authenticate Branch:0");\r
+               \r
+       \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): else: Not (username == null)\r
+        */\r
+       @Test\r
+       public void test_method_authenticate_1_branch_1() throws AuthenticationException\r
+       {\r
+               System.out.println("Now Testing Method:authenticate Branch:1");\r
+               \r
+               //Constructor\r
+               AAFAuthenticator instance = new AAFAuthenticator();\r
+               \r
+               //Get expected result and result\r
+               Object expResult = null;\r
+               Object result = instance.authenticate(null);\r
+               \r
+               //Check Return value\r
+               assertEquals(expResult, result);\r
+               \r
+       \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): if: (password == null)\r
+        */\r
+       @Test\r
+       public void test_method_authenticate_1_branch_2()\r
+       {\r
+               System.out.println("Now Testing Method:authenticate Branch:2");\r
+               \r
+               \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): else: Not (password == null), if: (password.startsWith("bsf:"))\r
+        */\r
+       @Test\r
+       public void test_method_authenticate_1_branch_3()\r
+       {\r
+               System.out.println("Now Testing Method:authenticate Branch:3");\r
+               \r
+               \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): else: Not (password == null), else: Not (password.startsWith("bsf:")), if: (password.startsWith("enc:???"))\r
+        */\r
+       @Test\r
+       public void test_method_authenticate_1_branch_4()\r
+       {\r
+               System.out.println("Now Testing Method:authenticate Branch:4");\r
+       \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): else: Not (password == null), else: Not (password.startsWith("bsf:")), else: Not (password.startsWith("enc:???"))\r
+        */\r
+       @Test\r
+       public void test_method_authenticate_1_branch_5()\r
+       {\r
+               System.out.println("Now Testing Method:authenticate Branch:5");\r
+               \r
+               \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): if: (localLur!=null), if: (localLur.validate(fullName, Type.PASSWORD, password.getBytes()))\r
+        */\r
+       @Test\r
+       public void test_method_authenticate_1_branch_6()\r
+       {\r
+               System.out.println("Now Testing Method:authenticate Branch:6");\r
+               \r
+               \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): if: (localLur!=null), else: Not (localLur.validate(fullName, Type.PASSWORD, password.getBytes()))\r
+        */\r
+       @Test\r
+       public void test_method_authenticate_1_branch_7()\r
+       {\r
+               System.out.println("Now Testing Method:authenticate Branch:7");\r
+               \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): else: Not (localLur!=null)\r
+        */\r
+       @Test\r
+       public void test_method_authenticate_1_branch_8()\r
+       {\r
+               System.out.println("Now Testing Method:authenticate Branch:8");\r
+               \r
+               \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): if: (aafResponse != null)\r
+        */\r
+       @Test\r
+       public void test_method_authenticate_1_branch_9()\r
+       {\r
+               System.out.println("Now Testing Method:authenticate Branch:9");\r
+               \r
+       \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): else: Not (aafResponse != null)\r
+        */\r
+       @Test\r
+       public void test_method_authenticate_1_branch_10()\r
+       {\r
+               System.out.println("Now Testing Method:authenticate Branch:10");\r
+               \r
+               \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): Default\r
+        */\r
+       @Test\r
+       public void test_method_create_2_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:create Branch:0");\r
+               \r
+               \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): Default\r
+        */\r
+       @Test\r
+       public void test_method_alter_3_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:alter Branch:0");\r
+               \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): Default\r
+        */\r
+       @Test\r
+       public void test_method_drop_4_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:drop Branch:0");\r
+               \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): Default\r
+        */\r
+       @Test\r
+       public void test_method_evaluateResponse_5_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:evaluateResponse Branch:0");\r
+               \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): Default\r
+        */\r
+       @Test\r
+       public void test_method_isComplete_6_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:isComplete Branch:0");\r
+               \r
+       \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): Default\r
+        */\r
+       @Test\r
+       public void test_method_getAuthenticatedUser_7_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:getAuthenticatedUser Branch:0");\r
+               \r
+               \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): Default\r
+        */\r
+       @Test\r
+       public void test_method_newAuthenticator_8_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:newAuthenticator Branch:0");\r
+               \r
+               \r
+               \r
+       }\r
+\r
+}\r
diff --git a/cass/src/test/java/org/onap/aaf/cadi/aaf/cass/AAFAuthorizerTest.java b/cass/src/test/java/org/onap/aaf/cadi/aaf/cass/AAFAuthorizerTest.java
new file mode 100644 (file)
index 0000000..c547260
--- /dev/null
@@ -0,0 +1,378 @@
+/*******************************************************************************\r
+ * ============LICENSE_START====================================================\r
+ * * org.onap.aaf\r
+ * * ===========================================================================\r
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
+ * * ===========================================================================\r
+ * * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * * you may not use this file except in compliance with the License.\r
+ * * You may obtain a copy of the License at\r
+ * * \r
+ *  *      http://www.apache.org/licenses/LICENSE-2.0\r
+ * * \r
+ *  * Unless required by applicable law or agreed to in writing, software\r
+ * * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * * See the License for the specific language governing permissions and\r
+ * * limitations under the License.\r
+ * * ============LICENSE_END====================================================\r
+ * *\r
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ * *\r
+ ******************************************************************************/\r
+package org.onap.aaf.cadi.aaf.cass;\r
+\r
+import static org.junit.Assert.*;\r
+\r
+import org.junit.Test;\r
+\r
+import org.junit.After;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import static org.junit.Assert.*;\r
+\r
+public class AAFAuthorizerTest\r
+{\r
+       \r
+\r
+       @Before\r
+       public void setUp()\r
+       {\r
+               \r
+       }\r
+\r
+       @After\r
+       public void tearDown()\r
+       {\r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): if: (user instanceof AAFAuthenticatedUser), if: (aafUser.isLocal())\r
+        */\r
+       @Test\r
+       public void test_method_authorize_0_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:authorize Branch:0");\r
+               \r
+       \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): if: (user instanceof AAFAuthenticatedUser), else: Not (aafUser.isLocal())\r
+        */\r
+       @Test\r
+       public void test_method_authorize_0_branch_1()\r
+       {\r
+               System.out.println("Now Testing Method:authorize Branch:1");\r
+               \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): else: Not (user instanceof AAFAuthenticatedUser)\r
+        */\r
+       @Test\r
+       public void test_method_authorize_0_branch_2()\r
+       {\r
+               System.out.println("Now Testing Method:authorize Branch:2");\r
+               \r
+       \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): Default\r
+        */\r
+       @Test\r
+       public void test_method_PermHolder_1_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:PermHolder Branch:0");\r
+               \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): Default\r
+        */\r
+       @Test\r
+       public void test_method_PermHolder_2_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:PermHolder Branch:0");\r
+               \r
+               \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): if: (permissions==Permission.NONE)\r
+        */\r
+       @Test\r
+       public void test_method_mutable_3_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:mutable Branch:0");\r
+               \r
+       \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): else: Not (permissions==Permission.NONE)\r
+        */\r
+       @Test\r
+       public void test_method_mutable_3_branch_1()\r
+       {\r
+               System.out.println("Now Testing Method:mutable Branch:1");\r
+               \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): Default\r
+        */\r
+       @Test\r
+       public void test_method_mutable_4_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:mutable Branch:0");\r
+               \r
+               \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): Default\r
+        */\r
+       @Test\r
+       public void test_method_mutable_5_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:mutable Branch:0");\r
+               \r
+               \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): Default\r
+        */\r
+       @Test\r
+       public void test_method_getName_6_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:getName Branch:0");\r
+               \r
+               \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): Default\r
+        */\r
+       @Test\r
+       public void test_method_exec_7_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:exec Branch:0");\r
+               \r
+               \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): Default\r
+        */\r
+       @Test\r
+       public void test_method_getName_8_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:getName Branch:0");\r
+               \r
+               \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): Default\r
+        */\r
+       @Test\r
+       public void test_method_exec_9_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:exec Branch:0");\r
+               \r
+               \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): Default\r
+        */\r
+       @Test\r
+       public void test_method_getName_10_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:getName Branch:0");\r
+               \r
+               \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): Default\r
+        */\r
+       @Test\r
+       public void test_method_exec_11_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:exec Branch:0");\r
+               \r
+       \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): Default\r
+        */\r
+       @Test\r
+       public void test_method_getName_12_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:getName Branch:0");\r
+               \r
+       \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): Default\r
+        */\r
+       @Test\r
+       public void test_method_exec_13_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:exec Branch:0");\r
+               \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): Default\r
+        */\r
+       @Test\r
+       public void test_method_getName_14_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:getName Branch:0");\r
+               \r
+       \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): Default\r
+        */\r
+       @Test\r
+       public void test_method_exec_15_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:exec Branch:0");\r
+       \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): Default\r
+        */\r
+       @Test\r
+       public void test_method_getName_16_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:getName Branch:0");\r
+       \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): Default\r
+        */\r
+       @Test\r
+       public void test_method_exec_17_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:exec Branch:0");\r
+               \r
+               \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): Default\r
+        */\r
+       @Test\r
+       public void test_method_getName_18_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:getName Branch:0");\r
+               \r
+               //Constructor\r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): Default\r
+        */\r
+       @Test\r
+       public void test_method_exec_19_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:exec Branch:0");\r
+               \r
+       \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): Default\r
+        */\r
+       @Test\r
+       public void test_method_grant_20_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:grant Branch:0");\r
+               \r
+       \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): Default\r
+        */\r
+       @Test\r
+       public void test_method_revoke_21_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:revoke Branch:0");\r
+               \r
+               \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): Default\r
+        */\r
+       @Test\r
+       public void test_method_list_22_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:list Branch:0");\r
+               \r
+       \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): Default\r
+        */\r
+       @Test\r
+       public void test_method_revokeAll_23_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:revokeAll Branch:0");\r
+               \r
+               \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): Default\r
+        */\r
+       @Test\r
+       public void test_method_revokeAll_24_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:revokeAll Branch:0");\r
+               \r
+               \r
+               \r
+       }\r
+\r
+}\r
diff --git a/cass/src/test/java/org/onap/aaf/cadi/aaf/cass/AAFBaseTest.java b/cass/src/test/java/org/onap/aaf/cadi/aaf/cass/AAFBaseTest.java
new file mode 100644 (file)
index 0000000..c9fc0b4
--- /dev/null
@@ -0,0 +1,399 @@
+/*******************************************************************************\r
+ * ============LICENSE_START====================================================\r
+ * * org.onap.aaf\r
+ * * ===========================================================================\r
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
+ * * ===========================================================================\r
+ * * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * * you may not use this file except in compliance with the License.\r
+ * * You may obtain a copy of the License at\r
+ * * \r
+ *  *      http://www.apache.org/licenses/LICENSE-2.0\r
+ * * \r
+ *  * Unless required by applicable law or agreed to in writing, software\r
+ * * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * * See the License for the specific language governing permissions and\r
+ * * limitations under the License.\r
+ * * ============LICENSE_END====================================================\r
+ * *\r
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ * *\r
+ ******************************************************************************/\r
+package org.onap.aaf.cadi.aaf.cass;\r
+\r
+import org.junit.After;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import org.onap.aaf.cadi.aaf.cass.AAFBase;\r
+\r
+import static org.junit.Assert.*;\r
+\r
+public class AAFBaseTest\r
+{\r
+       \r
+\r
+       @Before\r
+       public void setUp()\r
+       {\r
+               \r
+       }\r
+\r
+       @After\r
+       public void tearDown()\r
+       {\r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): Default\r
+        */\r
+       @Test\r
+       public void test_method_setAccess_0_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:setAccess Branch:0");\r
+               \r
+               //Call Method\r
+               AAFBase.setAccess(null);\r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): if: (!props_ok)\r
+        */\r
+       @Test\r
+       public void test_method_validateConfiguration_1_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:validateConfiguration Branch:0");\r
+               \r
+               \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): else: Not (!props_ok)\r
+        */\r
+       @Test\r
+       public void test_method_validateConfiguration_1_branch_1()\r
+       {\r
+               System.out.println("Now Testing Method:validateConfiguration Branch:1");\r
+               \r
+       \r
+               \r
+               //Call Method\r
+       \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): if: (aafAuthn == null), if: (access==null), if: (cadi_props == null), if: (cp.exists())\r
+        */\r
+       @Test\r
+       public void test_method_setup_2_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:setup Branch:0");\r
+               \r
+\r
+               \r
+       \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): if: (aafAuthn == null), if: (access==null), if: (cadi_props == null), else: Not (cp.exists())\r
+        */\r
+       @Test\r
+       public void test_method_setup_2_branch_1()\r
+       {\r
+               System.out.println("Now Testing Method:setup Branch:1");\r
+               \r
+\r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): if: (aafAuthn == null), if: (access==null), else: Not (cadi_props == null)\r
+        */\r
+       @Test\r
+       public void test_method_setup_2_branch_2()\r
+       {\r
+               System.out.println("Now Testing Method:setup Branch:2");\r
+               \r
+\r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): if: (aafAuthn == null), else: Not (access==null)\r
+        */\r
+       @Test\r
+       public void test_method_setup_2_branch_3()\r
+       {\r
+               System.out.println("Now Testing Method:setup Branch:3");\r
+               \r
+\r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): if: (aafAuthn == null), if: ((perm_type = Config.logProp(access, "cass_group_name",null))==null)\r
+        */\r
+       @Test\r
+       public void test_method_setup_2_branch_4()\r
+       {\r
+               System.out.println("Now Testing Method:setup Branch:4");\r
+               \r
+\r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): if: (aafAuthn == null), else: Not ((perm_type = Config.logProp(access, "cass_group_name",null))==null)\r
+        */\r
+       @Test\r
+       public void test_method_setup_2_branch_5()\r
+       {\r
+               System.out.println("Now Testing Method:setup Branch:5");\r
+               \r
+\r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): if: (aafAuthn == null), if: ((cluster_name = Config.logProp(access,"cass_cluster_name",null))==null), if: ((cluster_name = DatabaseDescriptor.getClusterName())==null)\r
+        */\r
+       @Test\r
+       public void test_method_setup_2_branch_6()\r
+       {\r
+               System.out.println("Now Testing Method:setup Branch:6");\r
+               \r
+\r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): if: (aafAuthn == null), if: ((cluster_name = Config.logProp(access,"cass_cluster_name",null))==null), else: Not ((cluster_name = DatabaseDescriptor.getClusterName())==null)\r
+        */\r
+       @Test\r
+       public void test_method_setup_2_branch_7()\r
+       {\r
+               System.out.println("Now Testing Method:setup Branch:7");\r
+               \r
+\r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): if: (aafAuthn == null), else: Not ((cluster_name = Config.logProp(access,"cass_cluster_name",null))==null)\r
+        */\r
+       @Test\r
+       public void test_method_setup_2_branch_8()\r
+       {\r
+               System.out.println("Now Testing Method:setup Branch:8");\r
+               \r
+\r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): if: (aafAuthn == null), if: ((default_realm = Config.logProp(access, Config.AAF_DEFAULT_REALM, null))==null)\r
+        */\r
+       @Test\r
+       public void test_method_setup_2_branch_9()\r
+       {\r
+               System.out.println("Now Testing Method:setup Branch:9");\r
+               \r
+\r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): if: (aafAuthn == null), else: Not ((default_realm = Config.logProp(access, Config.AAF_DEFAULT_REALM, null))==null)\r
+        */\r
+       @Test\r
+       public void test_method_setup_2_branch_10()\r
+       {\r
+               System.out.println("Now Testing Method:setup Branch:10");\r
+\r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): if: (aafAuthn == null), if: (props_ok==false)\r
+        */\r
+       @Test\r
+       public void test_method_setup_2_branch_11()\r
+       {\r
+               System.out.println("Now Testing Method:setup Branch:11");\r
+\r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): if: (aafAuthn == null), else: Not (props_ok==false)\r
+        */\r
+       @Test\r
+       public void test_method_setup_2_branch_12()\r
+       {\r
+               System.out.println("Now Testing Method:setup Branch:12");\r
+               \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): if: (aafAuthn == null), if: (lur instanceof EpiLur), for: (int i=0; (lur = elur.get(i))!=null;++i), if: (lur instanceof AbsAAFLur)\r
+        */\r
+       @Test\r
+       public void test_method_setup_2_branch_13()\r
+       {\r
+               System.out.println("Now Testing Method:setup Branch:13");\r
+               \r
+\r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): if: (aafAuthn == null), if: (lur instanceof EpiLur), for: (int i=0; (lur = elur.get(i))!=null;++i), else: Not (lur instanceof AbsAAFLur), if: (lur instanceof LocalLur)\r
+        */\r
+       @Test\r
+       public void test_method_setup_2_branch_14()\r
+       {\r
+               System.out.println("Now Testing Method:setup Branch:14");\r
+               \r
+\r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): if: (aafAuthn == null), if: (lur instanceof EpiLur), for: (int i=0; (lur = elur.get(i))!=null;++i), else: Not (lur instanceof AbsAAFLur), else: Not (lur instanceof LocalLur)\r
+        */\r
+       @Test\r
+       public void test_method_setup_2_branch_15()\r
+       {\r
+               System.out.println("Now Testing Method:setup Branch:15");\r
+               \r
+       \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): if: (aafAuthn == null), if: (lur instanceof EpiLur), for: Not (int i=0; (lur = elur.get(i))!=null;++i)\r
+        */\r
+       @Test\r
+       public void test_method_setup_2_branch_16()\r
+       {\r
+               System.out.println("Now Testing Method:setup Branch:16");\r
+\r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): if: (aafAuthn == null), else: Not (lur instanceof EpiLur), if: (lur instanceof AbsAAFLur)\r
+        */\r
+       @Test\r
+       public void test_method_setup_2_branch_17()\r
+       {\r
+               System.out.println("Now Testing Method:setup Branch:17");\r
+               \r
+       \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): if: (aafAuthn == null), else: Not (lur instanceof EpiLur), else: Not (lur instanceof AbsAAFLur)\r
+        */\r
+       @Test\r
+       public void test_method_setup_2_branch_18()\r
+       {\r
+               System.out.println("Now Testing Method:setup Branch:18");\r
+               \r
+       \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): if: (aafAuthn == null), if: (aafAuthn==null)\r
+        */\r
+       @Test\r
+       public void test_method_setup_2_branch_19()\r
+       {\r
+               System.out.println("Now Testing Method:setup Branch:19");\r
+               \r
+       \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): if: (aafAuthn == null), else: Not (aafAuthn==null)\r
+        */\r
+       @Test\r
+       public void test_method_setup_2_branch_20()\r
+       {\r
+               System.out.println("Now Testing Method:setup Branch:20");\r
+               \r
+       \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): if: (aafAuthn == null), if: (access!=null)\r
+        */\r
+       @Test\r
+       public void test_method_setup_2_branch_21()\r
+       {\r
+               System.out.println("Now Testing Method:setup Branch:21");\r
+               \r
+               \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): if: (aafAuthn == null), else: Not (access!=null)\r
+        */\r
+       @Test\r
+       public void test_method_setup_2_branch_22()\r
+       {\r
+               System.out.println("Now Testing Method:setup Branch:22");\r
+               \r
+       \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): else: Not (aafAuthn == null)\r
+        */\r
+       @Test\r
+       public void test_method_setup_2_branch_23()\r
+       {\r
+               System.out.println("Now Testing Method:setup Branch:23");\r
+       \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): Default\r
+        */\r
+       @Test\r
+       public void test_method_protectedResources_3_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:protectedResources Branch:0");\r
+               \r
+               \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): Default\r
+        */\r
+       @Test\r
+       public void test_method_supportedOptions_4_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:supportedOptions Branch:0");\r
+               \r
+       \r
+       }\r
+\r
+       /*\r
+        * Testing Conditon(s): Default\r
+        */\r
+       @Test\r
+       public void test_method_alterableOptions_5_branch_0()\r
+       {\r
+               System.out.println("Now Testing Method:alterableOptions Branch:0");\r
+               \r
+       \r
+               \r
+       }\r
+\r
+}\r
diff --git a/cass/src/test/java/org/onap/aaf/cadi/aaf/cass/JU_CASS.java b/cass/src/test/java/org/onap/aaf/cadi/aaf/cass/JU_CASS.java
new file mode 100644 (file)
index 0000000..bce8e0b
--- /dev/null
@@ -0,0 +1,106 @@
+/*******************************************************************************\r
+ * ============LICENSE_START====================================================\r
+ * * org.onap.aaf\r
+ * * ===========================================================================\r
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
+ * * ===========================================================================\r
+ * * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * * you may not use this file except in compliance with the License.\r
+ * * You may obtain a copy of the License at\r
+ * * \r
+ *  *      http://www.apache.org/licenses/LICENSE-2.0\r
+ * * \r
+ *  * Unless required by applicable law or agreed to in writing, software\r
+ * * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * * See the License for the specific language governing permissions and\r
+ * * limitations under the License.\r
+ * * ============LICENSE_END====================================================\r
+ * *\r
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ * *\r
+ ******************************************************************************/\r
+package org.onap.aaf.cadi.aaf.cass;\r
+\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+import java.util.Set;\r
+\r
+import org.apache.cassandra.auth.AuthenticatedUser;\r
+import org.apache.cassandra.auth.IResource;\r
+import org.apache.cassandra.auth.Permission;\r
+import org.junit.AfterClass;\r
+import org.junit.Assert;\r
+import org.junit.BeforeClass;\r
+import org.junit.Test;\r
+import org.onap.aaf.cadi.aaf.cass.AAFAuthenticator;\r
+import org.onap.aaf.cadi.aaf.cass.AAFAuthorizer;\r
+\r
+public class JU_CASS {\r
+\r
+       private static AAFAuthenticator aa;\r
+       private static AAFAuthorizer an;\r
+\r
+       @BeforeClass\r
+       public static void setUpBeforeClass() throws Exception {\r
+               System.setProperty("cadi_prop_files", "etc/cadi.properties");\r
+               \r
+               aa = new AAFAuthenticator();\r
+               an = new AAFAuthorizer();\r
+\r
+               aa.setup();\r
+               an.setup(); // does nothing after aa.\r
+               \r
+               aa.validateConfiguration();\r
+               \r
+       }\r
+\r
+       @AfterClass\r
+       public static void tearDownAfterClass() throws Exception {\r
+       }\r
+\r
+       @Test\r
+       public void test() throws Exception {\r
+                       Map<String,String> creds = new HashMap<String,String>();\r
+                       creds.put("username", "XXX@NS");\r
+                       creds.put("password", "enc:???");\r
+                       AuthenticatedUser aaf = aa.authenticate(creds);\r
+\r
+                       // Test out "aaf_default_domain\r
+                       creds.put("username", "XX");\r
+                       aaf = aa.authenticate(creds);\r
+                       \r
+                       IResource resource = new IResource() {\r
+                               public String getName() {\r
+                                       return "data/authz";\r
+                               }\r
+\r
+                               public IResource getParent() {\r
+                                       return null;\r
+                               }\r
+\r
+                               public boolean hasParent() {\r
+                                       return false;\r
+                               }\r
+\r
+                               public boolean exists() {\r
+                                       return true;\r
+                               }\r
+                               \r
+                       };\r
+                       \r
+                       Set<Permission> perms = an.authorize(aaf, resource);\r
+                       \r
+                       // Test out "AAF" access\r
+                       creds.put("username", "XXX@NS");\r
+                       creds.put("password", "enc:???");\r
+                       aaf = aa.authenticate(creds);\r
+                       perms = an.authorize(aaf, resource);\r
+                       Assert.assertFalse(perms.isEmpty());\r
+\r
+                       perms = an.authorize(aaf, resource);\r
+                       Assert.assertFalse(perms.isEmpty());\r
+                       \r
+       }\r
+\r
+}\r
index 23294d9..82c0bb8 100644 (file)
                        </plugin>\r
 \r
 <plugin>\r
-                               <groupId>org.jacoco</groupId>\r
-                               <artifactId>jacoco-maven-plugin</artifactId>\r
-                               <version>0.7.7.201606060606</version>\r
-                               <configuration>\r
-                                       <dumpOnExit>true</dumpOnExit>\r
-                               </configuration>\r
-                               <executions>\r
-                                       <execution>\r
-                                               <id>pre-unit-test</id>\r
-                                               <goals>\r
-                                                       <goal>prepare-agent</goal>\r
-                                               </goals>\r
-                                               <configuration>\r
-                                                       <destFile>${project.build.directory}/coverage-reports/jacoco.exec</destFile>\r
-                                                       <!-- <append>true</append> -->\r
-                                               </configuration>\r
-                                       </execution>\r
-                                       <execution>\r
-                                               <id>pre-integration-test</id>\r
-                                               <phase>pre-integration-test</phase>\r
-                                               <goals>\r
-                                                       <goal>prepare-agent</goal>\r
-                                               </goals>\r
-                                               <configuration>\r
-                                                       <destFile>${project.build.directory}/coverage-reports/jacoco-it.exec</destFile>\r
-                                                       <!-- <append>true</append> -->\r
-                                               </configuration>\r
-                                       </execution>\r
-                                       <execution>\r
-                        <goals>\r
-                            <goal>merge</goal>\r
-                        </goals>\r
-                        <phase>post-integration-test</phase>\r
-                        <configuration>\r
-                            <fileSets>\r
-                                <fileSet implementation="org.apache.maven.shared.model.fileset.FileSet">\r
-                                    <directory>${project.build.directory}/coverage-reports</directory>\r
-                                    <includes>\r
-                                        <include>*.exec</include>\r
-                                    </includes>\r
-                                </fileSet>\r
-                            </fileSets>\r
-                            <destFile>${project.build.directory}/jacoco-dev.exec</destFile>\r
-                        </configuration>\r
-                    </execution>\r
-                               </executions>\r
-                       </plugin>                       \r
+          <groupId>org.jacoco</groupId>\r
+          <artifactId>jacoco-maven-plugin</artifactId>\r
+          <version>${jacoco.version}</version>\r
+          <configuration>\r
+            <!-- Note: This exclusion list should match <sonar.exclusions>\r
+         property above -->\r
+            <excludes>\r
+              <exclude>**/gen/**</exclude>\r
+              <exclude>**/generated-sources/**</exclude>\r
+              <exclude>**/yang-gen/**</exclude>\r
+              <exclude>**/pax/**</exclude>\r
+            </excludes>\r
+          </configuration>\r
+          <executions>\r
+            <!--\r
+        Prepares the property pointing to the JaCoCo runtime agent which\r
+        is passed as VM argument when Maven the Surefire plugin is executed.\r
+        -->\r
+            <execution>\r
+              <id>pre-unit-test</id>\r
+              <goals>\r
+                <goal>prepare-agent</goal>\r
+              </goals>\r
+              <configuration>\r
+                <!-- Sets the path to the file which contains the execution data. -->\r
+                <destFile>${project.build.directory}/code-coverage/jacoco-ut.exec</destFile>\r
+                <!--\r
+            Sets the name of the property containing the settings\r
+            for JaCoCo runtime agent.\r
+        -->\r
+                <propertyName>surefireArgLine</propertyName>\r
+              </configuration>\r
+            </execution>\r
+            <!--\r
+        Ensures that the code coverage report for unit tests is created after\r
+        unit tests have been run.\r
+        -->\r
+            <execution>\r
+              <id>post-unit-test</id>\r
+              <phase>test</phase>\r
+              <goals>\r
+                <goal>report</goal>\r
+              </goals>\r
+              <configuration>\r
+                <!-- Sets the path to the file which contains the execution data. -->\r
+                <dataFile>${project.build.directory}/code-coverage/jacoco-ut.exec</dataFile>\r
+                <!-- Sets the output directory for the code coverage report. -->\r
+                <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>\r
+              </configuration>\r
+            </execution>\r
+            <execution>\r
+              <id>pre-integration-test</id>\r
+              <phase>pre-integration-test</phase>\r
+              <goals>\r
+                <goal>prepare-agent</goal>\r
+              </goals>\r
+              <configuration>\r
+                <!-- Sets the path to the file which contains the execution data. -->\r
+                <destFile>${project.build.directory}/code-coverage/jacoco-it.exec</destFile>\r
+                <!--\r
+            Sets the name of the property containing the settings\r
+            for JaCoCo runtime agent.\r
+        -->\r
+                <propertyName>failsafeArgLine</propertyName>\r
+              </configuration>\r
+            </execution>\r
+            <!--\r
+        Ensures that the code coverage report for integration tests after\r
+        integration tests have been run.\r
+        -->\r
+            <execution>\r
+              <id>post-integration-test</id>\r
+              <phase>post-integration-test</phase>\r
+              <goals>\r
+                <goal>report</goal>\r
+              </goals>\r
+              <configuration>\r
+                <!-- Sets the path to the file which contains the execution data. -->\r
+                <dataFile>${project.build.directory}/code-coverage/jacoco-it.exec</dataFile>\r
+                <!-- Sets the output directory for the code coverage report. -->\r
+                <outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory>\r
+              </configuration>\r
+            </execution>\r
+          </executions>\r
+        </plugin>                    \r
+\r
                </plugins>\r
        </build>\r
                <distributionManagement>\r
index a838ece..3088b20 100644 (file)
        </properties>\r
        <dependencies>\r
 \r
+               <dependency>\r
+                       <groupId>org.mockito</groupId>\r
+                       <artifactId>mockito-all</artifactId>\r
+               </dependency>\r
                <dependency>\r
                        <groupId>javax.servlet</groupId>\r
                        <artifactId>servlet-api</artifactId>\r
                        </plugin> \r
                        \r
                        <plugin>\r
-                               <groupId>org.jacoco</groupId>\r
-                               <artifactId>jacoco-maven-plugin</artifactId>\r
-                               <version>0.7.7.201606060606</version>\r
-                               <configuration>\r
-                                       <dumpOnExit>true</dumpOnExit>\r
-                               </configuration>\r
-                               <executions>\r
-                                       <execution>\r
-                                               <id>pre-unit-test</id>\r
-                                               <goals>\r
-                                                       <goal>prepare-agent</goal>\r
-                                               </goals>\r
-                                               <configuration>\r
-                                                       <destFile>${project.build.directory}/coverage-reports/jacoco.exec</destFile>\r
-                                                       <!-- <append>true</append> -->\r
-                                               </configuration>\r
-                                       </execution>\r
-                                       <execution>\r
-                                               <id>pre-integration-test</id>\r
-                                               <phase>pre-integration-test</phase>\r
-                                               <goals>\r
-                                                       <goal>prepare-agent</goal>\r
-                                               </goals>\r
-                                               <configuration>\r
-                                                       <destFile>${project.build.directory}/coverage-reports/jacoco-it.exec</destFile>\r
-                                                       <!-- <append>true</append> -->\r
-                                               </configuration>\r
-                                       </execution>\r
-                                       <execution>\r
-                        <goals>\r
-                            <goal>merge</goal>\r
-                        </goals>\r
-                        <phase>post-integration-test</phase>\r
-                        <configuration>\r
-                            <fileSets>\r
-                                <fileSet implementation="org.apache.maven.shared.model.fileset.FileSet">\r
-                                    <directory>${project.build.directory}/coverage-reports</directory>\r
-                                    <includes>\r
-                                        <include>*.exec</include>\r
-                                    </includes>\r
-                                </fileSet>\r
-                            </fileSets>\r
-                            <destFile>${project.build.directory}/jacoco-dev.exec</destFile>\r
-                        </configuration>\r
-                    </execution>\r
-                               </executions>\r
-                       </plugin>\r
+          <groupId>org.jacoco</groupId>\r
+          <artifactId>jacoco-maven-plugin</artifactId>\r
+          <version>${jacoco.version}</version>\r
+          <configuration>\r
+            <!-- Note: This exclusion list should match <sonar.exclusions>\r
+         property above -->\r
+            <excludes>\r
+              <exclude>**/gen/**</exclude>\r
+              <exclude>**/generated-sources/**</exclude>\r
+              <exclude>**/yang-gen/**</exclude>\r
+              <exclude>**/pax/**</exclude>\r
+            </excludes>\r
+          </configuration>\r
+          <executions>\r
+            <!--\r
+        Prepares the property pointing to the JaCoCo runtime agent which\r
+        is passed as VM argument when Maven the Surefire plugin is executed.\r
+        -->\r
+            <execution>\r
+              <id>pre-unit-test</id>\r
+              <goals>\r
+                <goal>prepare-agent</goal>\r
+              </goals>\r
+              <configuration>\r
+                <!-- Sets the path to the file which contains the execution data. -->\r
+                <destFile>${project.build.directory}/code-coverage/jacoco-ut.exec</destFile>\r
+                <!--\r
+            Sets the name of the property containing the settings\r
+            for JaCoCo runtime agent.\r
+        -->\r
+                <propertyName>surefireArgLine</propertyName>\r
+              </configuration>\r
+            </execution>\r
+            <!--\r
+        Ensures that the code coverage report for unit tests is created after\r
+        unit tests have been run.\r
+        -->\r
+            <execution>\r
+              <id>post-unit-test</id>\r
+              <phase>test</phase>\r
+              <goals>\r
+                <goal>report</goal>\r
+              </goals>\r
+              <configuration>\r
+                <!-- Sets the path to the file which contains the execution data. -->\r
+                <dataFile>${project.build.directory}/code-coverage/jacoco-ut.exec</dataFile>\r
+                <!-- Sets the output directory for the code coverage report. -->\r
+                <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>\r
+              </configuration>\r
+            </execution>\r
+            <execution>\r
+              <id>pre-integration-test</id>\r
+              <phase>pre-integration-test</phase>\r
+              <goals>\r
+                <goal>prepare-agent</goal>\r
+              </goals>\r
+              <configuration>\r
+                <!-- Sets the path to the file which contains the execution data. -->\r
+                <destFile>${project.build.directory}/code-coverage/jacoco-it.exec</destFile>\r
+                <!--\r
+            Sets the name of the property containing the settings\r
+            for JaCoCo runtime agent.\r
+        -->\r
+                <propertyName>failsafeArgLine</propertyName>\r
+              </configuration>\r
+            </execution>\r
+            <!--\r
+        Ensures that the code coverage report for integration tests after\r
+        integration tests have been run.\r
+        -->\r
+            <execution>\r
+              <id>post-integration-test</id>\r
+              <phase>post-integration-test</phase>\r
+              <goals>\r
+                <goal>report</goal>\r
+              </goals>\r
+              <configuration>\r
+                <!-- Sets the path to the file which contains the execution data. -->\r
+                <dataFile>${project.build.directory}/code-coverage/jacoco-it.exec</dataFile>\r
+                <!-- Sets the output directory for the code coverage report. -->\r
+                <outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory>\r
+              </configuration>\r
+            </execution>\r
+          </executions>\r
+        </plugin>                    \r
+\r
                </plugins>\r
        </build>\r
        <distributionManagement>\r
diff --git a/core/src/test/java/org/onap/aaf/cadi/CadiExceptionTest.java b/core/src/test/java/org/onap/aaf/cadi/CadiExceptionTest.java
new file mode 100644 (file)
index 0000000..29a0a8b
--- /dev/null
@@ -0,0 +1,61 @@
+/*******************************************************************************\r
+ * ============LICENSE_START====================================================\r
+ * * org.onap.aaf\r
+ * * ===========================================================================\r
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
+ * * ===========================================================================\r
+ * * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * * you may not use this file except in compliance with the License.\r
+ * * You may obtain a copy of the License at\r
+ * * \r
+ *  *      http://www.apache.org/licenses/LICENSE-2.0\r
+ * * \r
+ *  * Unless required by applicable law or agreed to in writing, software\r
+ * * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * * See the License for the specific language governing permissions and\r
+ * * limitations under the License.\r
+ * * ============LICENSE_END====================================================\r
+ * *\r
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ * *\r
+ ******************************************************************************/\r
+package org.onap.aaf.cadi;\r
+\r
+import static org.hamcrest.CoreMatchers.is;\r
+import static org.junit.Assert.*;\r
+\r
+import org.junit.Test;\r
+\r
+public class CadiExceptionTest {\r
+\r
+       @Test\r
+       public void testCadiException() {\r
+               CadiException exception = new CadiException();\r
+               \r
+               assertNotNull(exception);\r
+       }\r
+\r
+       @Test\r
+       public void testCadiExceptionString() {\r
+               CadiException exception = new CadiException("New Exception");\r
+               assertNotNull(exception);\r
+               assertThat(exception.getMessage(), is("New Exception"));\r
+       }\r
+\r
+       @Test\r
+       public void testCadiExceptionThrowable() {\r
+               CadiException exception = new CadiException(new Throwable("New Exception"));\r
+               assertNotNull(exception);\r
+               assertThat(exception.getMessage(), is("java.lang.Throwable: New Exception"));\r
+       }\r
+\r
+       @Test\r
+       public void testCadiExceptionStringThrowable() {\r
+               CadiException exception = new CadiException("New Exception",new Throwable("New Exception"));\r
+               assertNotNull(exception);\r
+               assertThat(exception.getMessage(), is("New Exception"));\r
+\r
+       }\r
+\r
+}\r
diff --git a/core/src/test/java/org/onap/aaf/cadi/UserTest.java b/core/src/test/java/org/onap/aaf/cadi/UserTest.java
new file mode 100644 (file)
index 0000000..3e8254b
--- /dev/null
@@ -0,0 +1,107 @@
+/*******************************************************************************\r
+ * ============LICENSE_START====================================================\r
+ * * org.onap.aaf\r
+ * * ===========================================================================\r
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
+ * * ===========================================================================\r
+ * * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * * you may not use this file except in compliance with the License.\r
+ * * You may obtain a copy of the License at\r
+ * * \r
+ *  *      http://www.apache.org/licenses/LICENSE-2.0\r
+ * * \r
+ *  * Unless required by applicable law or agreed to in writing, software\r
+ * * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * * See the License for the specific language governing permissions and\r
+ * * limitations under the License.\r
+ * * ============LICENSE_END====================================================\r
+ * *\r
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ * *\r
+ ******************************************************************************/\r
+package org.onap.aaf.cadi;\r
+\r
+import static org.hamcrest.CoreMatchers.is;\r
+import static org.junit.Assert.*;\r
+import static org.mockito.Mockito.when;\r
+\r
+import java.security.Principal;\r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import org.mockito.Mock;\r
+import org.mockito.MockitoAnnotations;\r
+import org.onap.aaf.cadi.lur.LocalPermission;\r
+\r
+public class UserTest {\r
+\r
+       @Mock\r
+       private Principal principal;\r
+       \r
+       @Mock\r
+       private LocalPermission permission;\r
+       \r
+       @Before\r
+       public void setup() {\r
+               MockitoAnnotations.initMocks(this);\r
+               \r
+               when(principal.getName()).thenReturn("Principal");\r
+               \r
+               when(permission.getKey()).thenReturn("NewKey");\r
+               when(permission.match(permission)).thenReturn(true);\r
+       }\r
+       \r
+       @Test\r
+       public void testCountCheck() {\r
+               User<Permission> user = new User<Permission>(principal);\r
+               user.resetCount();\r
+               assertThat(user.count, is(0));\r
+               user.incCount();\r
+               assertThat(user.count, is(1));\r
+       }\r
+\r
+       @Test\r
+       public void testPerm() throws InterruptedException {\r
+               User<Permission> user = new User<Permission>(principal);\r
+               assertThat(user.permExpires(), is(Long.MAX_VALUE));\r
+               user.renewPerm();\r
+               Thread.sleep(1);\r
+               assertThat(user.permExpired(), is(true));\r
+               user = new User<Permission>(principal,100);\r
+               assertTrue(user.noPerms());\r
+               user.add(permission);\r
+               assertFalse(user.noPerms());\r
+               user.setNoPerms();\r
+               assertThat(user.permExpired(), is(false));\r
+               assertFalse(user.permsUnloaded());\r
+               user.perms = null;\r
+               assertTrue(user.permsUnloaded());\r
+               assertTrue(user.noPerms());\r
+       }\r
+       \r
+       @Test\r
+       public void testAddValuesToNewMap() {\r
+               User<Permission> user = new User<Permission>(principal);\r
+               Map<String, Permission> newMap = new HashMap<String,Permission>();\r
+               \r
+               assertFalse(user.contains(permission));\r
+               \r
+               user.add(newMap, permission);\r
+               user.setMap(newMap);\r
+               \r
+               assertTrue(user.contains(permission));\r
+               \r
+               List<Permission> sink = new ArrayList<Permission>();\r
+               user.copyPermsTo(sink);\r
+               \r
+               assertThat(sink.size(), is(1));\r
+               assertTrue(sink.contains(permission));\r
+               \r
+               assertThat(user.toString(), is("Principal|:NewKey"));\r
+       }\r
+}\r
diff --git a/pom.xml b/pom.xml
index cbbb8e9..9690398 100644 (file)
--- a/pom.xml
+++ b/pom.xml
        <!-- ============================================================== -->
        <dependencyManagement>
                <dependencies>
+                       <dependency>
+                       <groupId>org.mockito</groupId>
+                       <artifactId>mockito-all</artifactId>
+                       <version>1.9.5</version>
+                       <scope>test</scope>
+                       </dependency>
                        <dependency>
                                <groupId>org.onap.aaf.authz</groupId>
                                <artifactId>authz-client</artifactId>
                        </plugin> 
                        
                        <plugin>
-                               <groupId>org.jacoco</groupId>
-                               <artifactId>jacoco-maven-plugin</artifactId>
-                               <version>0.7.7.201606060606</version>
-                               <configuration>
-                                       <dumpOnExit>true</dumpOnExit>
+          <groupId>org.jacoco</groupId>
+          <artifactId>jacoco-maven-plugin</artifactId>
+          <version>${jacoco.version}</version>
+          <configuration>
+            <!-- Note: This exclusion list should match <sonar.exclusions>
+         property above -->
+            <excludes>
+              <exclude>**/gen/**</exclude>
+              <exclude>**/generated-sources/**</exclude>
+              <exclude>**/yang-gen/**</exclude>
+              <exclude>**/pax/**</exclude>
+            </excludes>
+          </configuration>
+          <executions>
+            <!--
+        Prepares the property pointing to the JaCoCo runtime agent which
+        is passed as VM argument when Maven the Surefire plugin is executed.
+        -->
+            <execution>
+              <id>pre-unit-test</id>
+              <goals>
+                <goal>prepare-agent</goal>
+              </goals>
+              <configuration>
+                <!-- Sets the path to the file which contains the execution data. -->
+                <destFile>${project.build.directory}/code-coverage/jacoco-ut.exec</destFile>
+                <!--
+            Sets the name of the property containing the settings
+            for JaCoCo runtime agent.
+        -->
+                <propertyName>surefireArgLine</propertyName>
+              </configuration>
+            </execution>
+            <!--
+        Ensures that the code coverage report for unit tests is created after
+        unit tests have been run.
+        -->
+            <execution>
+              <id>post-unit-test</id>
+              <phase>test</phase>
+              <goals>
+                <goal>report</goal>
+              </goals>
+              <configuration>
+                <!-- Sets the path to the file which contains the execution data. -->
+                <dataFile>${project.build.directory}/code-coverage/jacoco-ut.exec</dataFile>
+                <!-- Sets the output directory for the code coverage report. -->
+                <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
+              </configuration>
+            </execution>
+            <execution>
+              <id>pre-integration-test</id>
+              <phase>pre-integration-test</phase>
+              <goals>
+                <goal>prepare-agent</goal>
+              </goals>
+              <configuration>
+                <!-- Sets the path to the file which contains the execution data. -->
+                <destFile>${project.build.directory}/code-coverage/jacoco-it.exec</destFile>
+                <!--
+            Sets the name of the property containing the settings
+            for JaCoCo runtime agent.
+        -->
+                <propertyName>failsafeArgLine</propertyName>
+              </configuration>
+            </execution>
+            <!--
+        Ensures that the code coverage report for integration tests after
+        integration tests have been run.
+        -->
+            <execution>
+              <id>post-integration-test</id>
+              <phase>post-integration-test</phase>
+              <goals>
+                <goal>report</goal>
+              </goals>
+              <configuration>
+                <!-- Sets the path to the file which contains the execution data. -->
+                <dataFile>${project.build.directory}/code-coverage/jacoco-it.exec</dataFile>
+                <!-- Sets the output directory for the code coverage report. -->
+                <outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory>
+              </configuration>
+            </execution>
+          </executions>
+        </plugin>                    
 
-                               </configuration>
-                               <executions>
-                                       <execution>
-                                               <id>pre-unit-test</id>
-                                               <goals>
-                                                       <goal>prepare-agent</goal>
-                                               </goals>
-                                               <configuration>
-                                                       <destFile>${project.build.directory}/coverage-reports/jacoco.exec</destFile>
-                                                       <!-- <append>true</append> -->
-                                               </configuration>
-                                       </execution>
-                                       <execution>
-                                               <id>pre-integration-test</id>
-                                               <phase>pre-integration-test</phase>
-                                               <goals>
-                                                       <goal>prepare-agent</goal>
-                                               </goals>
-                                               <configuration>
-                                                       <destFile>${project.build.directory}/coverage-reports/jacoco-it.exec</destFile>
-                                                       <!-- <append>true</append> -->
-                                               </configuration>
-                                       </execution>
-                                       <execution>
-                        <goals>
-                            <goal>merge</goal>
-                        </goals>
-                        <phase>post-integration-test</phase>
-                        <configuration>
-                            <fileSets>
-                                <fileSet implementation="org.apache.maven.shared.model.fileset.FileSet">
-                                    <directory>${project.build.directory}/coverage-reports</directory>
-                                    <includes>
-                                        <include>*.exec</include>
-                                    </includes>
-                                </fileSet>
-                            </fileSets>
-                            <destFile>${project.build.directory}/jacoco-dev.exec</destFile>
-                        </configuration>
-                    </execution>
-                               </executions>
-                       </plugin>
                        </plugins>                      
        </build>
        <distributionManagement>