Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.osee.authentication.admin.test')
-rw-r--r--plugins/org.eclipse.osee.authentication.admin.test/.classpath7
-rw-r--r--plugins/org.eclipse.osee.authentication.admin.test/.project28
-rw-r--r--plugins/org.eclipse.osee.authentication.admin.test/META-INF/MANIFEST.MF15
-rw-r--r--plugins/org.eclipse.osee.authentication.admin.test/build.properties4
-rw-r--r--plugins/org.eclipse.osee.authentication.admin.test/pom.xml30
-rw-r--r--plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/AuthAdminTestSuite.java24
-rw-r--r--plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/internal/AnonymousUserTest.java49
-rw-r--r--plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/internal/AuthenticationAdminImplTest.java263
-rw-r--r--plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/internal/AuthenticationConfigurationBuilderTest.java88
-rw-r--r--plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/internal/InternalTestSuite.java27
-rw-r--r--plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/internal/NoneAuthenticationProviderTest.java87
11 files changed, 622 insertions, 0 deletions
diff --git a/plugins/org.eclipse.osee.authentication.admin.test/.classpath b/plugins/org.eclipse.osee.authentication.admin.test/.classpath
new file mode 100644
index 00000000000..ad32c83a788
--- /dev/null
+++ b/plugins/org.eclipse.osee.authentication.admin.test/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.osee.authentication.admin.test/.project b/plugins/org.eclipse.osee.authentication.admin.test/.project
new file mode 100644
index 00000000000..318c92d86c0
--- /dev/null
+++ b/plugins/org.eclipse.osee.authentication.admin.test/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.osee.authentication.admin.test</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.osee.authentication.admin.test/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.authentication.admin.test/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..12ac3486b8c
--- /dev/null
+++ b/plugins/org.eclipse.osee.authentication.admin.test/META-INF/MANIFEST.MF
@@ -0,0 +1,15 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: OSEE Authentication Admin Test (Incubation)
+Bundle-SymbolicName: org.eclipse.osee.authentication.admin.test
+Bundle-Version: 0.17.0.qualifier
+Fragment-Host: org.eclipse.osee.authentication.admin
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-Vendor: Eclipse Open System Engineering Environment
+Import-Package: org.hamcrest.core,
+ org.junit,
+ org.junit.rules,
+ org.junit.runner,
+ org.junit.runners,
+ org.mockito,
+ org.mockito.stubbing
diff --git a/plugins/org.eclipse.osee.authentication.admin.test/build.properties b/plugins/org.eclipse.osee.authentication.admin.test/build.properties
new file mode 100644
index 00000000000..34d2e4d2dad
--- /dev/null
+++ b/plugins/org.eclipse.osee.authentication.admin.test/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/plugins/org.eclipse.osee.authentication.admin.test/pom.xml b/plugins/org.eclipse.osee.authentication.admin.test/pom.xml
new file mode 100644
index 00000000000..a6307ba38db
--- /dev/null
+++ b/plugins/org.eclipse.osee.authentication.admin.test/pom.xml
@@ -0,0 +1,30 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.eclipse.osee</groupId>
+ <artifactId>org.eclipse.osee.orcs.parent</artifactId>
+ <version>0.17.0-SNAPSHOT</version>
+ <relativePath>../../plugins/org.eclipse.osee.orcs.parent</relativePath>
+ </parent>
+
+ <artifactId>org.eclipse.osee.authentication.admin.test</artifactId>
+ <packaging>eclipse-test-plugin</packaging>
+ <name>OSEE Authentication Admin Test - (Incubation)</name>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-surefire-plugin</artifactId>
+ <version>${tycho-version}</version>
+ <configuration>
+ <testSuite>org.eclipse.osee.authentication.admin.test</testSuite>
+ <testClass>org.eclipse.osee.authentication.admin.AuthAdminTestSuite</testClass>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project> \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/AuthAdminTestSuite.java b/plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/AuthAdminTestSuite.java
new file mode 100644
index 00000000000..7a4308929ab
--- /dev/null
+++ b/plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/AuthAdminTestSuite.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.authentication.admin;
+
+import org.eclipse.osee.authentication.admin.internal.InternalTestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * @author Roberto E. Escobar
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({InternalTestSuite.class})
+public class AuthAdminTestSuite {
+ // Test Suite
+}
diff --git a/plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/internal/AnonymousUserTest.java b/plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/internal/AnonymousUserTest.java
new file mode 100644
index 00000000000..d4f898c8aec
--- /dev/null
+++ b/plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/internal/AnonymousUserTest.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.authentication.admin.internal;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.MockitoAnnotations.initMocks;
+import org.eclipse.osee.authentication.admin.AuthenticatedUser;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test Case for {@link AnonymousUser}
+ *
+ * @author Roberto E. Escobar
+ */
+public class AnonymousUserTest {
+
+ private static final String NAME = AnonymousUser.ANONYMOUS_NAME;
+ private AuthenticatedUser actual;
+
+ @Before
+ public void testSetup() {
+ initMocks(this);
+
+ actual = new AnonymousUser();
+ }
+
+ @Test
+ public void testUser() {
+ assertEquals(NAME, actual.getName());
+ assertEquals(NAME, actual.getDisplayName());
+
+ assertEquals("", actual.getUserName());
+ assertEquals("", actual.getEmailAddress());
+
+ assertEquals(false, actual.getRoles().iterator().hasNext());
+ assertEquals(true, actual.isActive());
+ assertEquals(false, actual.isAuthenticated());
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/internal/AuthenticationAdminImplTest.java b/plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/internal/AuthenticationAdminImplTest.java
new file mode 100644
index 00000000000..6ab99f1cc6a
--- /dev/null
+++ b/plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/internal/AuthenticationAdminImplTest.java
@@ -0,0 +1,263 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.authentication.admin.internal;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.mockito.MockitoAnnotations.initMocks;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import org.eclipse.osee.authentication.admin.AuthenticatedUser;
+import org.eclipse.osee.authentication.admin.AuthenticationConstants;
+import org.eclipse.osee.authentication.admin.AuthenticationProvider;
+import org.eclipse.osee.authentication.admin.AuthenticationRequest;
+import org.eclipse.osee.authentication.admin.AuthenticationRequestBuilder;
+import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException;
+import org.eclipse.osee.logger.Log;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.mockito.Mock;
+
+/**
+ * Test Case for {@link AuthenticationAdminImpl}
+ *
+ * @author Roberto E. Escobar
+ */
+public class AuthenticationAdminImplTest {
+
+ private static final String SCHEME_1 = "scheme1";
+ private static final String SCHEME_2 = "scheme2";
+
+ private static final String USERNAME = "my username";
+ private static final String PASSWORD = "my password";
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ // @formatter:off
+ @Mock private Log logger;
+
+ @Mock private AuthenticationProvider provider1;
+ @Mock private AuthenticationProvider provider2;
+
+ @Mock private AuthenticatedUser authenticatedUser;
+ // @formatter:on
+
+ private AuthenticationAdminImpl admin;
+
+ @Before
+ public void testSetup() {
+ initMocks(this);
+
+ admin = new AuthenticationAdminImpl();
+ admin.setLogger(logger);
+ admin.start(Collections.<String, Object> emptyMap());
+
+ when(provider1.getAuthenticationScheme()).thenReturn(SCHEME_1);
+ when(provider2.getAuthenticationScheme()).thenReturn(SCHEME_2);
+ }
+
+ @Test
+ public void testAddRemoveProvider() {
+ Iterable<String> iterable = admin.getAvailableSchemes();
+ assertEquals(false, iterable.iterator().hasNext());
+
+ admin.addAuthenticationProvider(provider1);
+ admin.addAuthenticationProvider(provider2);
+
+ iterable = admin.getAvailableSchemes();
+ Iterator<String> iterator = iterable.iterator();
+ assertEquals(SCHEME_1, iterator.next());
+ assertEquals(SCHEME_2, iterator.next());
+
+ admin.removeAuthenticationProvider(provider1);
+
+ iterable = admin.getAvailableSchemes();
+ iterator = iterable.iterator();
+ assertEquals(SCHEME_2, iterator.next());
+
+ admin.removeAuthenticationProvider(provider2);
+ iterable = admin.getAvailableSchemes();
+ assertEquals(false, iterable.iterator().hasNext());
+ }
+
+ @Test
+ public void testAuthenticateExceptionNoSchemeAvailable() {
+ AuthenticationRequest request = AuthenticationRequestBuilder.newBuilder()//
+ .scheme(SCHEME_1) //
+ .userName(USERNAME)//
+ .password(PASSWORD)//
+ .build();
+
+ thrown.expect(OseeArgumentException.class);
+ thrown.expectMessage("Authentication Error - scheme [" + SCHEME_1 + "] is not allowed. Schemes available [].");
+ admin.authenticate(request);
+ }
+
+ @Test
+ public void testAuthenticateSchemeAvailableButNotAllowed() {
+ admin.addAuthenticationProvider(provider1);
+
+ Iterable<String> iterable = admin.getAvailableSchemes();
+ assertEquals(SCHEME_1, iterable.iterator().next());
+
+ iterable = admin.getAllowedSchemes();
+ assertEquals(false, iterable.iterator().hasNext());
+
+ AuthenticationRequest request = AuthenticationRequestBuilder.newBuilder()//
+ .scheme(SCHEME_1) //
+ .userName(USERNAME)//
+ .password(PASSWORD)//
+ .build();
+
+ thrown.expect(OseeArgumentException.class);
+ thrown.expectMessage("Authentication Error - scheme [" + SCHEME_1 + "] is not allowed. Schemes available [].");
+ admin.authenticate(request);
+ }
+
+ @Test
+ public void testAuthenticateExceptionProviderReturnsNull() {
+ admin.addAuthenticationProvider(provider1);
+
+ Iterable<String> iterable = admin.getAvailableSchemes();
+ assertEquals(SCHEME_1, iterable.iterator().next());
+
+ iterable = admin.getAllowedSchemes();
+ assertEquals(false, iterable.iterator().hasNext());
+
+ Map<String, Object> properties = new HashMap<String, Object>();
+ properties.put(AuthenticationConstants.AUTHENTICATION_SCHEME_ALLOWED, SCHEME_1);
+ admin.update(properties);
+
+ iterable = admin.getAllowedSchemes();
+ assertEquals(SCHEME_1, iterable.iterator().next());
+
+ AuthenticationRequest request = AuthenticationRequestBuilder.newBuilder()//
+ .scheme(SCHEME_1) //
+ .userName(USERNAME)//
+ .password(PASSWORD)//
+ .build();
+
+ thrown.expect(OseeArgumentException.class);
+ thrown.expectMessage("Authentication Error - scheme [" + SCHEME_1 + "] returned null principal");
+ admin.authenticate(request);
+ }
+
+ @Test
+ public void testAuthenticate() {
+ admin.addAuthenticationProvider(provider1);
+
+ Iterable<String> iterable = admin.getAvailableSchemes();
+ assertEquals(SCHEME_1, iterable.iterator().next());
+
+ iterable = admin.getAllowedSchemes();
+ assertEquals(false, iterable.iterator().hasNext());
+
+ Map<String, Object> properties = new HashMap<String, Object>();
+ properties.put(AuthenticationConstants.AUTHENTICATION_SCHEME_ALLOWED, SCHEME_1);
+ admin.update(properties);
+
+ iterable = admin.getAllowedSchemes();
+ assertEquals(SCHEME_1, iterable.iterator().next());
+
+ AuthenticationRequest request = AuthenticationRequestBuilder.newBuilder()//
+ .scheme(SCHEME_1) //
+ .userName(USERNAME)//
+ .password(PASSWORD)//
+ .build();
+
+ when(provider1.authenticate(request)).thenReturn(authenticatedUser);
+
+ AuthenticatedUser actual = admin.authenticate(request);
+
+ verify(provider1).authenticate(request);
+ assertEquals(authenticatedUser, actual);
+ }
+
+ @Test
+ public void testGetAllowedSchemes() {
+ admin.addAuthenticationProvider(provider1);
+
+ Iterable<String> iterable = admin.getAvailableSchemes();
+ assertEquals(SCHEME_1, iterable.iterator().next());
+
+ iterable = admin.getAllowedSchemes();
+ assertEquals(false, iterable.iterator().hasNext());
+
+ Map<String, Object> properties = new HashMap<String, Object>();
+ properties.put(AuthenticationConstants.AUTHENTICATION_SCHEME_ALLOWED, SCHEME_1);
+ admin.update(properties);
+
+ iterable = admin.getAllowedSchemes();
+ assertEquals(SCHEME_1, iterable.iterator().next());
+ }
+
+ @Test
+ public void testIsSchemeAllowed() {
+ admin.addAuthenticationProvider(provider1);
+ admin.addAuthenticationProvider(provider2);
+
+ Iterable<String> iterable = admin.getAvailableSchemes();
+ Iterator<String> iterator = iterable.iterator();
+ assertEquals(SCHEME_1, iterator.next());
+ assertEquals(SCHEME_2, iterator.next());
+
+ boolean actual = admin.isSchemeAllowed(SCHEME_1);
+ assertEquals(false, actual);
+
+ actual = admin.isSchemeAllowed(SCHEME_2);
+ assertEquals(false, actual);
+
+ Map<String, Object> properties = new HashMap<String, Object>();
+ properties.put(AuthenticationConstants.AUTHENTICATION_SCHEME_ALLOWED, SCHEME_1);
+ admin.update(properties);
+
+ actual = admin.isSchemeAllowed(SCHEME_1);
+ assertEquals(true, actual);
+
+ actual = admin.isSchemeAllowed(SCHEME_2);
+ assertEquals(false, actual);
+
+ properties.put(AuthenticationConstants.AUTHENTICATION_SCHEME_ALLOWED, SCHEME_1 + "," + SCHEME_2);
+ admin.update(properties);
+
+ actual = admin.isSchemeAllowed(SCHEME_1);
+ assertEquals(true, actual);
+
+ actual = admin.isSchemeAllowed(SCHEME_2);
+ assertEquals(true, actual);
+ }
+
+ @Test
+ public void testConfigUpdate() {
+ Iterator<String> iterator = admin.getAllowedSchemes().iterator();
+ assertEquals(false, iterator.hasNext());
+
+ Map<String, Object> properties = new HashMap<String, Object>();
+ admin.update(properties);
+
+ iterator = admin.getAllowedSchemes().iterator();
+ assertEquals(false, iterator.hasNext());
+
+ properties.put(AuthenticationConstants.AUTHENTICATION_SCHEME_ALLOWED, SCHEME_1 + "," + SCHEME_2);
+ admin.update(properties);
+
+ iterator = admin.getAllowedSchemes().iterator();
+ assertEquals(SCHEME_1, iterator.next());
+ assertEquals(SCHEME_2, iterator.next());
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/internal/AuthenticationConfigurationBuilderTest.java b/plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/internal/AuthenticationConfigurationBuilderTest.java
new file mode 100644
index 00000000000..5a9c7a1b734
--- /dev/null
+++ b/plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/internal/AuthenticationConfigurationBuilderTest.java
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.authentication.admin.internal;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.MockitoAnnotations.initMocks;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import org.eclipse.osee.authentication.admin.AuthenticationConfiguration;
+import org.eclipse.osee.authentication.admin.AuthenticationConfigurationBuilder;
+import org.eclipse.osee.authentication.admin.AuthenticationConstants;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+/**
+ * Test Case for {@link AuthenticationConfigurationBuilder}
+ *
+ * @author Roberto E. Escobar
+ */
+public class AuthenticationConfigurationBuilderTest {
+
+ private static final String SCHEME_1 = "scheme1";
+ private static final String SCHEME_2 = "scheme2";
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private AuthenticationConfigurationBuilder builder;
+
+ @Before
+ public void testSetup() {
+ initMocks(this);
+
+ builder = AuthenticationConfigurationBuilder.newBuilder();
+ }
+
+ @Test
+ public void testAddSchemes() {
+ builder.scheme(SCHEME_1);
+ builder.scheme(SCHEME_2);
+
+ AuthenticationConfiguration actual = builder.build();
+
+ Iterator<String> iterator = actual.getAllowedSchemes().iterator();
+ assertEquals(SCHEME_1, iterator.next());
+ assertEquals(SCHEME_2, iterator.next());
+ }
+
+ @Test
+ public void testConfigProperties() {
+ Map<String, Object> properties = new HashMap<String, Object>();
+ properties.put(AuthenticationConstants.AUTHENTICATION_SCHEME_ALLOWED, SCHEME_2);
+ builder.properties(properties);
+
+ AuthenticationConfiguration actual = builder.build();
+
+ Iterator<String> iterator = actual.getAllowedSchemes().iterator();
+ assertEquals(SCHEME_2, iterator.next());
+ }
+
+ @Test
+ public void testNoChangeAfterBuild() {
+ builder.scheme(SCHEME_1);
+
+ AuthenticationConfiguration actual = builder.build();
+
+ Iterator<String> iterator = actual.getAllowedSchemes().iterator();
+ assertEquals(SCHEME_1, iterator.next());
+ assertEquals(false, iterator.hasNext());
+
+ builder.scheme(SCHEME_2);
+
+ iterator = actual.getAllowedSchemes().iterator();
+ assertEquals(SCHEME_1, iterator.next());
+ assertEquals(false, iterator.hasNext());
+ }
+}
diff --git a/plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/internal/InternalTestSuite.java b/plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/internal/InternalTestSuite.java
new file mode 100644
index 00000000000..849b7c5d229
--- /dev/null
+++ b/plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/internal/InternalTestSuite.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.authentication.admin.internal;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * @author Roberto E. Escobar
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ AnonymousUserTest.class,
+ AuthenticationAdminImplTest.class,
+ AuthenticationConfigurationBuilderTest.class,
+ NoneAuthenticationProviderTest.class})
+public class InternalTestSuite {
+ // Test Suite
+}
diff --git a/plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/internal/NoneAuthenticationProviderTest.java b/plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/internal/NoneAuthenticationProviderTest.java
new file mode 100644
index 00000000000..afef6b238a9
--- /dev/null
+++ b/plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/internal/NoneAuthenticationProviderTest.java
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.authentication.admin.internal;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.MockitoAnnotations.initMocks;
+import java.util.HashMap;
+import java.util.Map;
+import org.eclipse.osee.authentication.admin.AuthenticatedUser;
+import org.eclipse.osee.authentication.admin.AuthenticationConstants;
+import org.eclipse.osee.authentication.admin.AuthenticationRequest;
+import org.eclipse.osee.authentication.admin.AuthenticationRequestBuilder;
+import org.eclipse.osee.logger.Log;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+
+/**
+ * Test Case for {@link NoneAuthenticationProvider}
+ *
+ * @author Roberto E. Escobar
+ */
+public class NoneAuthenticationProviderTest {
+
+ private static final String NONE_SCHEME = "none";
+ private static final String USERNAME = "my username";
+ private static final String PASSWORD = "my password";
+
+ // @formatter:off
+ @Mock private Log logger;
+ // @formatter:on
+
+ private AuthenticationAdminImpl admin;
+
+ @Before
+ public void testSetup() {
+ initMocks(this);
+
+ admin = new AuthenticationAdminImpl();
+ admin.setLogger(logger);
+
+ NoneAuthenticationProvider provider = new NoneAuthenticationProvider();
+ admin.addAuthenticationProvider(provider);
+
+ Map<String, Object> properties = new HashMap<String, Object>();
+ properties.put(AuthenticationConstants.AUTHENTICATION_SCHEME_ALLOWED,
+ NoneAuthenticationProvider.AUTHENTICATION_TYPE);
+
+ admin.start(properties);
+ }
+
+ @Test
+ public void testAuthenticate() {
+ Iterable<String> iterable = admin.getAllowedSchemes();
+ assertEquals(NONE_SCHEME, iterable.iterator().next());
+
+ AuthenticationRequest request = AuthenticationRequestBuilder.newBuilder()//
+ .scheme(NONE_SCHEME) //
+ .userName(USERNAME)//
+ .password(PASSWORD)//
+ .build();
+
+ AuthenticatedUser actual = admin.authenticate(request);
+
+ assertNotNull(actual);
+
+ assertEquals(USERNAME, actual.getName());
+ assertEquals(USERNAME, actual.getUserName());
+ assertEquals(USERNAME, actual.getDisplayName());
+
+ assertEquals("", actual.getEmailAddress());
+
+ assertEquals(false, actual.getRoles().iterator().hasNext());
+ assertEquals(true, actual.isActive());
+ assertEquals(true, actual.isAuthenticated());
+ }
+
+}

Back to the top