summaryrefslogtreecommitdiffstats
path: root/src/test/java/org/onap/dmaap/commonauth/kafka/base
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/org/onap/dmaap/commonauth/kafka/base')
-rw-r--r--src/test/java/org/onap/dmaap/commonauth/kafka/base/authorization/AuthorizationProviderFactoryTest.java5
-rw-r--r--src/test/java/org/onap/dmaap/commonauth/kafka/base/authorization/Cadi3AAFProviderTest.java29
-rw-r--r--src/test/java/org/onap/dmaap/commonauth/kafka/base/authorization/JUnitTestSuite.java41
-rw-r--r--src/test/java/org/onap/dmaap/commonauth/kafka/base/authorization/TestRunner.java41
4 files changed, 12 insertions, 104 deletions
diff --git a/src/test/java/org/onap/dmaap/commonauth/kafka/base/authorization/AuthorizationProviderFactoryTest.java b/src/test/java/org/onap/dmaap/commonauth/kafka/base/authorization/AuthorizationProviderFactoryTest.java
index 7f441f0..bf7890e 100644
--- a/src/test/java/org/onap/dmaap/commonauth/kafka/base/authorization/AuthorizationProviderFactoryTest.java
+++ b/src/test/java/org/onap/dmaap/commonauth/kafka/base/authorization/AuthorizationProviderFactoryTest.java
@@ -20,6 +20,8 @@
*******************************************************************************/
package org.onap.dmaap.commonauth.kafka.base.authorization;
+import static org.junit.Assert.assertNotNull;
+
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
@@ -31,8 +33,7 @@ public class AuthorizationProviderFactoryTest {
@Test
public void testFactory() {
- AuthorizationProviderFactory.getProviderFactory().getProvider();
-
+ assertNotNull(AuthorizationProviderFactory.getProviderFactory().getProvider());
}
}
diff --git a/src/test/java/org/onap/dmaap/commonauth/kafka/base/authorization/Cadi3AAFProviderTest.java b/src/test/java/org/onap/dmaap/commonauth/kafka/base/authorization/Cadi3AAFProviderTest.java
index 1a2bd95..4f9de3d 100644
--- a/src/test/java/org/onap/dmaap/commonauth/kafka/base/authorization/Cadi3AAFProviderTest.java
+++ b/src/test/java/org/onap/dmaap/commonauth/kafka/base/authorization/Cadi3AAFProviderTest.java
@@ -3,6 +3,7 @@
* org.onap.dmaap
* ================================================================================
* Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Modification copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,6 +25,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.when;
import org.junit.Before;
@@ -31,11 +33,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.onap.aaf.cadi.PropAccess;
-import org.onap.aaf.cadi.aaf.AAFPermission;
import org.onap.aaf.cadi.aaf.v2_0.AAFAuthn;
-import org.onap.aaf.cadi.aaf.v2_0.AAFConHttp;
-import org.onap.aaf.cadi.aaf.v2_0.AbsAAFLur;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.modules.junit4.PowerMockRunner;
@@ -48,21 +46,15 @@ public class Cadi3AAFProviderTest {
@Mock
private static AAFAuthn<?> aafAuthn;
-
- @Mock
- private static AAFConHttp aafCon;
-
- @Mock
- private static AbsAAFLur<AAFPermission> aafLur;
- @Mock
- private static PropAccess access;
+ static {
+ System.setProperty("CADI_PROPERTIES", "src/test/resources/cadi.properties");
+ System.setProperty("enableCadi", "true");
+ }
@Before
- public void setUp() throws Exception {
+ public void setUp() {
MockitoAnnotations.initMocks(this);
- System.setProperty("enableCadi", "true");
- System.setProperty("CADI_PROPERTIES", "src/test/resources/cadi.properties");
cadi3AAFProvider = new Cadi3AAFProvider();
}
@@ -73,14 +65,12 @@ public class Cadi3AAFProviderTest {
@Test
public void testHasAdminPermission() {
- assertEquals(cadi3AAFProvider.hasPermission("admin", "permission", "instance", "action"), true);
+ assertTrue(cadi3AAFProvider.hasPermission("admin", "permission", "instance", "action"));
}
- @Test(expected = NullPointerException.class)
public void tesAuthenticate() throws Exception {
- System.setProperty("enableCadi", "true");
when(aafAuthn.validate("userId", "password")).thenReturn("valid");
- assertEquals(cadi3AAFProvider.authenticate("userId", "password"), "valid");
+ assertEquals("valid", cadi3AAFProvider.authenticate("userId", "password"));
}
@Test
@@ -92,5 +82,4 @@ public class Cadi3AAFProviderTest {
public void tesAuthenticateAdminwtWrongCred() throws Exception {
assertNotNull(cadi3AAFProvider.authenticate("kafkaUsername", "api"));
}
-
}
diff --git a/src/test/java/org/onap/dmaap/commonauth/kafka/base/authorization/JUnitTestSuite.java b/src/test/java/org/onap/dmaap/commonauth/kafka/base/authorization/JUnitTestSuite.java
deleted file mode 100644
index e9b52d1..0000000
--- a/src/test/java/org/onap/dmaap/commonauth/kafka/base/authorization/JUnitTestSuite.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy Engine
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.dmaap.commonauth.kafka.base.authorization;
-
-import junit.framework.TestSuite;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-import org.junit.runners.Suite.SuiteClasses;
-import org.apache.log4j.Logger;
-
-@RunWith(Suite.class)
-@SuiteClasses({ AuthorizationProviderFactoryTest.class, Cadi3AAFProviderTest.class })
-public class JUnitTestSuite {
- private static final Logger LOGGER = Logger.getLogger(JUnitTestSuite.class);
-
- public static void main(String[] args) {
- LOGGER.info("Running the test suite");
-
- TestSuite tstSuite = new TestSuite();
- LOGGER.info("Total Test Counts " + tstSuite.countTestCases());
- }
-
-}
diff --git a/src/test/java/org/onap/dmaap/commonauth/kafka/base/authorization/TestRunner.java b/src/test/java/org/onap/dmaap/commonauth/kafka/base/authorization/TestRunner.java
deleted file mode 100644
index 7f7ea11..0000000
--- a/src/test/java/org/onap/dmaap/commonauth/kafka/base/authorization/TestRunner.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy Engine
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.dmaap.commonauth.kafka.base.authorization;
-
-import org.junit.runner.JUnitCore;
-import org.junit.runner.Result;
-import org.junit.runner.notification.Failure;
-import org.apache.log4j.Logger;
-
-public class TestRunner {
- private static final Logger LOGGER = Logger.getLogger(TestRunner.class);
-
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Result result = JUnitCore.runClasses(JUnitTestSuite.class);
- for (Failure failure : result.getFailures()) {
- LOGGER.info(failure.toString());
-
- }
- LOGGER.info(result.wasSuccessful());
- }
-
-}