Examples of AdminAPI


Examples of gwtappcontainer.server.apis.admin.AdminAPI

   
    @Test
    public void addingExistingEmailGivesResourceAlreadyExistsError() {
      MockGateKeeper mockGateKeeper = new MockGateKeeper();
      mockGateKeeper.allowRoleToUser("test@example.com", Role.PORTAL_ADMIN);
      AdminAPI api = new AdminAPI();
      api.setGateKeeper(mockGateKeeper);
     
      User user = UserServiceFactory.getUserService().getCurrentUser();
     
      String email = "dummy_" + UUID.randomUUID() + "@dummy.com";
      APIResponse resp = api.addUser(email, user);
      assertTrue(resp.statusCode == Status.SUCCESS);
     
      resp = api.addUser(email, user);
      assertTrue(resp.statusCode == Status.ERROR_RESOURCE_ALREADY_EXISTS);
    }
View Full Code Here

Examples of gwtappcontainer.server.apis.admin.AdminAPI

     
      //1. create a gatekeeper and assign test@example.com as developer
    MockGateKeeper mockGateKeeper = new MockGateKeeper();
    mockGateKeeper.allowRoleToUser("test@example.com", Role.DEVELOPER);
   
      AdminAPI api = new AdminAPI();     
      api.setGateKeeper(mockGateKeeper);
     
      //2. add a role and ensure it is present
      User user = UserServiceFactory.getUserService().getCurrentUser();
      String role = "testdummy_" + UUID.randomUUID();
      APIResponse resp = api.addRole(role, user);
      assertTrue(resp.statusCode == Status.SUCCESS);
     
    List<RoleProp> roles = (List<RoleProp>) api.getAllRoles().object;
   
    assertTrue("added role should be present",
          isRolePresent(roles, role.toUpperCase()));  
     
      //3. rename a role and ensure the entity in datastore is updated
      String newRole = role + "_new";
      resp = api.renameRole(role, newRole, user);
      assertTrue(resp.statusCode == Status.SUCCESS);     
     
      roles = (List<RoleProp>) api.getAllRoles().object;
           
      assertTrue("new role should be present",
          isRolePresent(roles, newRole.toUpperCase()));           
      assertTrue("old role should not be present",
          (false == isRolePresent(roles, role.toUpperCase())));
     
      //4. delete the role and ensure it is deleted from datastore
      resp = api.deleteRole(newRole, user);
      assertTrue("deletion should be success",
          resp.statusCode == Status.SUCCESS);
      roles = (List<RoleProp>) api.getAllRoles().object;
      assertTrue("role after deletion should not be present",
          (false == isRolePresent(roles, newRole.toUpperCase())));
    }
View Full Code Here

Examples of gwtappcontainer.server.apis.admin.AdminAPI

  @Test
  public void loginNotRequiredToViewRoles() {
    //1. create a gatekeeper that allows developer
    MockGateKeeper mockGateKeeper = new MockGateKeeper();
    mockGateKeeper.allowRoleToUser("test@example.com", Role.DEVELOPER);
      AdminAPI api = new AdminAPI();
      api.setGateKeeper(mockGateKeeper);
     
      User user = UserServiceFactory.getUserService().getCurrentUser();
      String role = "dummy_" + UUID.randomUUID();
      APIResponse resp = api.addRole(role, user);
      assertTrue(resp.statusCode == Status.SUCCESS);
     
      userServiceHelper.setEnvIsLoggedIn(false);
      user = UserServiceFactory.getUserService().getCurrentUser();
      assertTrue(null == user);
     
      @SuppressWarnings("unchecked")
    List<RoleProp> all= (List<RoleProp>)api.getAllRoles().object;
           
      assertTrue(isRolePresent(all, role.toUpperCase()));
  }
View Full Code Here

Examples of gwtappcontainer.server.apis.admin.AdminAPI

    //3. delete a role and ensure it gives status code as insufficient permission
     
      //1. create a gatekeeper that allows developer
    MockGateKeeper mockGateKeeper = new MockGateKeeper();
    mockGateKeeper.allowRoleToUser("test@example.com", Role.PORTAL_ADMIN);
      AdminAPI api = new AdminAPI();
      api.setGateKeeper(mockGateKeeper);
     
      //2. add a role
      User user = UserServiceFactory.getUserService().getCurrentUser();
      String role = "testdummy";
      APIResponse resp = api.addRole(role, user);
      assertTrue("add should give insufficient permission error",
          resp.statusCode == Status.ERROR_INSUFFICIENT_PERMISSION);
     
      //3. rename a role
      resp = api.renameRole(role, role + "_new", user);
      assertTrue("rename should give insufficient permission error",
          resp.statusCode == Status.ERROR_INSUFFICIENT_PERMISSION);
     
      //4. delete a role
      resp = api.deleteRole(role, user);
      assertTrue("delete should give insufficient permission error",
          resp.statusCode == Status.ERROR_INSUFFICIENT_PERMISSION);         
    }
View Full Code Here

Examples of gwtappcontainer.server.apis.admin.AdminAPI

    }
   

  @Test
    public void roleSavedInUpperCase() {
      AdminAPI api = new AdminAPI();
      MockGateKeeper mockGateKeeper = new MockGateKeeper();
    mockGateKeeper.allowRoleToUser("test@example.com", Role.DEVELOPER);
      api.setGateKeeper(mockGateKeeper);
                 
      User user = UserServiceFactory.getUserService().getCurrentUser();
      api.addRole("testdummy", user);
     
      @SuppressWarnings("unchecked")
    List<RoleProp> roles = (List<RoleProp>) api.getAllRoles().object;
           
      assertTrue(isRolePresent(roles, "TESTDUMMY"));           
    }
View Full Code Here

Examples of gwtappcontainer.server.apis.admin.AdminAPI

  }
 
  @Test
  public void ensureValidUserReturnsTrueForValidUser() {
       
    AdminAPI adminApi = new AdminAPI();
    String email = "test_" + UUID.randomUUID() + "@example.com";
    APIResponse resp = adminApi.addUser(email, helper.loginAsPortalAdmin());
    assertTrue(resp.statusCode == Status.SUCCESS);
   
    User user = helper.loginAs(email);
    GateKeeper gateKeeper = new GateKeeper();
    assertTrue(gateKeeper.ensureValidUser(user));     
View Full Code Here

Examples of gwtappcontainer.server.apis.admin.AdminAPI

   
    MockGateKeeper mockGateKeeper = new MockGateKeeper();
    mockGateKeeper.allowRoleToUser("test@example.com", Role.DEVELOPER);
    mockGateKeeper.allowRoleToUser("test@example.com", Role.PORTAL_ADMIN);
   
    AdminAPI api = new AdminAPI();
    api.setGateKeeper(mockGateKeeper);
   
    User user = UserServiceFactory.getUserService().getCurrentUser();
   
    //add roles
    api.addRole(ROLE_DEVELOPER, user);
    api.addRole(ROLE_PORTAL_ADMIN, user);
    api.addRole(ROLE_PORTAL_USER.toString(), user);
    api.addRole(ROLE_PORTAL_READONLY.toString(), user);
   
    //add users
    api.addUser(EMAIL_DEVELOPER, user);
    api.addUser(EMAIL_PORTAL_ADMIN, user);
    api.addUser(EMAIL_PORTAL_READONLY, user);
    api.addUser(EMAIL_PORTAL_USER, user);
   
    //assign roles
    api.assignRoleToUser(EMAIL_DEVELOPER, ROLE_DEVELOPER, user);        
    api.assignRoleToUser(EMAIL_PORTAL_ADMIN, ROLE_PORTAL_ADMIN, user);        
    api.assignRoleToUser(EMAIL_PORTAL_READONLY, ROLE_PORTAL_READONLY, user);    
    api.assignRoleToUser(EMAIL_PORTAL_USER, ROLE_PORTAL_USER, user);        
  }
View Full Code Here

Examples of gwtappcontainer.server.apis.admin.AdminAPI

        //dsHelper.tearDown();       
    }
   
    @Test
    public void anyRoleModificationWithoutLoginGivesAuthenticationError() {
      AdminAPI api = new AdminAPI();
     
      APIResponse resp = api.addRole("dummy", null);
      assertTrue(resp.statusCode == Status.ERROR_LOGIN_REQUIRED);
     
      resp = api.deleteRole("dummy", null);
      assertTrue(resp.statusCode == Status.ERROR_LOGIN_REQUIRED);
     
      resp = api.renameRole("dummy", "dummy_new", null);
      assertTrue(resp.statusCode == Status.ERROR_LOGIN_REQUIRED);
    }
View Full Code Here

Examples of gwtappcontainer.server.apis.admin.AdminAPI

     
      //1. create a gatekeeper and assign test@example.com as developer
    MockGateKeeper mockGateKeeper = new MockGateKeeper();
    mockGateKeeper.allowRoleToUser("test@example.com", Role.DEVELOPER);
   
      AdminAPI api = new AdminAPI();     
      api.setGateKeeper(mockGateKeeper);
     
      //2. add a role and ensure it is present
      User user = UserServiceFactory.getUserService().getCurrentUser();
      String role = "testdummy_" + UUID.randomUUID();
      APIResponse resp = api.addRole(role, user);
      assertTrue(resp.statusCode == Status.SUCCESS);
     
    List<RoleProp> roles = (List<RoleProp>) api.getAllRoles().object;
   
    assertTrue("added role should be present",
          isRolePresent(roles, role.toUpperCase()));  
     
      //3. rename a role and ensure the entity in datastore is updated
      String newRole = role + "_new";
      resp = api.renameRole(role, newRole, user);
      assertTrue(resp.statusCode == Status.SUCCESS);     
     
      roles = (List<RoleProp>) api.getAllRoles().object;
           
      assertTrue("new role should be present",
          isRolePresent(roles, newRole.toUpperCase()));           
      assertTrue("old role should not be present",
          (false == isRolePresent(roles, role.toUpperCase())));
     
      //4. delete the role and ensure it is deleted from datastore
      resp = api.deleteRole(newRole, user);
      assertTrue("deletion should be success",
          resp.statusCode == Status.SUCCESS);
      roles = (List<RoleProp>) api.getAllRoles().object;
      assertTrue("role after deletion should not be present",
          (false == isRolePresent(roles, newRole.toUpperCase())));
    }
View Full Code Here

Examples of gwtappcontainer.server.apis.admin.AdminAPI

  }
 
  @Test
  public void canLoginAsDeveloper() {
           
    AdminAPI api = new AdminAPI();
    User user = helper.loginAsDeveloper();
   
    APIResponse resp = api.getRolesForLoggedInUser(user);
    assertTrue(resp.statusCode == Status.SUCCESS);
   
    UserProp prop = (UserProp) resp.object;
   
    assertTrue(null != prop);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.