package org.slc.sli.sandbox.idp.service;

import static org.junit.Assert.assertEquals;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

/**
 * Unit tests
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "/applicationContext-test.xml" })
public class LDAPUsersTest {
    
    @Autowired
    UserService userService;
    
    /**
     * Test SLIAdmin realm login
     * 
     * @throws AuthenticationException
     */
    @Test
    public void testSLIAdmin() throws AuthenticationException {
        UserService.User user = userService.authenticate("SLIAdmin", "slcoperator", "slcoperator1234");
        assertEquals("slcoperator", user.userId);
        assertEquals("SLC Operator", user.getAttributes().get("userName"));
        assertEquals(1, user.getAttributes().size());
        assertEquals(1, user.getRoles().size());
        assertEquals("SLC Operator", user.getRoles().get(0));
    }
    
    /**
     * SANDBOX
     * Test sandbox developer logging in to SLIAdmin realm
     * 
     * @throws AuthenticationException
     */
    @Test
    public void testDeveloperAdminLogin() throws AuthenticationException {
        UserService.User user = userService.authenticate("SLIAdmin", "testdeveloper", "testdeveloper1234");
        assertEquals("testdeveloper", user.userId);
        assertEquals("Test Developer", user.getAttributes().get("userName"));
        assertEquals("IL", user.getAttributes().get("Tenant"));
        assertEquals(1, user.getRoles().size());
        assertEquals("Application Developer", user.getRoles().get(0));
    }
    
    /**
     * SANDBOX
     * Test sandbox developer logging in to their realm
     * 
     * @throws AuthenticationException
     */
    @Test
    public void testGoodDeveloper() throws AuthenticationException {
        UserService.User user = userService.authenticate("SLIAdmin", "testdeveloper", "testdeveloper1234");
        assertEquals("testdeveloper", user.userId);
        assertEquals("Test Developer", user.getAttributes().get("userName"));
        assertEquals("IL", user.getAttributes().get("Tenant"));
        assertEquals(1, user.getRoles().size());
        assertEquals("Application Developer", user.getRoles().get(0));
    }
}

@@ -96,248 +96,58 @@
 org.
-junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.test.context.ContextConfiguration;%0Aimport org.springframework.test.context.junit4.SpringJUnit4ClassRunner
+springframework.beans.factory.annotation.Autowired
 ;%0A%0A/
@@ -167,16 +167,18 @@
 sts%0A */%0A
+//
 @RunWith
@@ -209,16 +209,18 @@
 .class)%0A
+//
 @Context
@@ -456,32 +456,34 @@
 ion%0A     */%0A    
+//
 @Test%0A    public
@@ -1075,32 +1075,34 @@
 ion%0A     */%0A    
+//
 @Test%0A    public
@@ -1737,16 +1737,18 @@
  */%0A    
+//
 @Test%0A  

disable non-unit test