ISSUE: Some changes to Authorization
[controller.git] / opendaylight / usermanager / src / test / java / org / opendaylight / controller / usermanager / internal / UserManagerImplTest.java
index 5b65028ca485c8ddc0da754f7e4cdb44b1a4f5d7..ec7b13603943cd348b3393a94a66749fdc608cba 100644 (file)
@@ -13,8 +13,10 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
+import java.util.Date;
 import java.util.concurrent.ConcurrentHashMap;
 
+import org.junit.Assert;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.opendaylight.controller.sal.authorization.AuthResultEnum;
@@ -228,4 +230,19 @@ public class UserManagerImplTest {
        public void testReadObject() {
                // fail("Not yet implemented");
        }
+       
+       @Test
+       public void testGetUserLevel() {
+               um.addLocalUser(new UserConfig("Jack", "password",
+                               UserLevel.SYSTEMADMIN.toString()));
+               um.authenticate("Jack", "password");
+               
+               um.addLocalUser(new UserConfig("John", "password",
+                               UserLevel.NETWORKOPERATOR.toString()));
+               // Run the check on authenticated user
+               Assert.assertTrue(um.getUserLevel("Jack") == UserLevel.SYSTEMADMIN);
+               // Run the check on configured users
+               Assert.assertTrue(um.getUserLevel("John") == UserLevel.NETWORKOPERATOR);
+               Assert.assertTrue(um.getUserLevel("Andrew") == UserLevel.NOUSER);
+       }
 }