Package org.jclouds.openstack.keystone.v2_0.domain

Examples of org.jclouds.openstack.keystone.v2_0.domain.User$ConcreteBuilder


      }
   }
  
   @Test(description = "POST /admin/org/{id}/users")
   public void testAddUser() {
      User newUser = randomTestUser("testAddUser");
      user = userApi.addUserToOrg(newUser, org.getId());
      checkUser(newUser);
   }
View Full Code Here


      checkUser(user);
   }
   @Test(description = "PUT /admin/user/{id}", dependsOnMethods = { "testGetUser" })
   public void testEditUser() {
      User oldUser = user.toBuilder().build();
      User newUser = user.toBuilder()
         .fullName("new"+oldUser.getFullName())
         .emailAddress("new"+oldUser.getEmailAddress())
         .telephone("1-"+oldUser.getTelephone())
         .isEnabled(true)
         .im("new"+oldUser.getIM())
         .isAlertEnabled(true)
         .alertEmailPrefix("new"+oldUser.getAlertEmailPrefix())
         .alertEmail("new"+oldUser.getAlertEmail())
         .storedVmQuota(1)
         .deployedVmQuota(1)
         .password("newPassword")
         // TODO test setting other fields?
//         .name("new"+oldUser.getName())
         .role(getRoleReferenceFor(DefaultRoles.AUTHOR.value()))
         .build();
     
      userApi.edit(user.getHref(), newUser);
      user = userApi.get(user.getHref());
     
      checkUser(user);
      assertTrue(equal(user.getFullName(), newUser.getFullName()),
            String.format(OBJ_FIELD_UPDATABLE, USER, "fullName"));
      assertTrue(equal(user.getEmailAddress(), newUser.getEmailAddress()),
            String.format(OBJ_FIELD_UPDATABLE, USER, "emailAddress"));
      assertTrue(equal(user.getTelephone(), newUser.getTelephone()),
            String.format(OBJ_FIELD_UPDATABLE, USER, "telephone"));
      assertTrue(equal(user.isEnabled(), newUser.isEnabled()),
            String.format(OBJ_FIELD_UPDATABLE, USER, "isEnabled"));
      assertTrue(equal(user.getIM(), newUser.getIM()),
            String.format(OBJ_FIELD_UPDATABLE, USER, "im"));
      assertTrue(equal(user.isAlertEnabled(), newUser.isAlertEnabled()),
            String.format(OBJ_FIELD_UPDATABLE, USER, "isAlertEnabled"));
      assertTrue(equal(user.getAlertEmailPrefix(), newUser.getAlertEmailPrefix()),
            String.format(OBJ_FIELD_UPDATABLE, USER, "alertEmailPrefix"));
      assertTrue(equal(user.getAlertEmail(), newUser.getAlertEmail()),
            String.format(OBJ_FIELD_UPDATABLE, USER, "alertEmail"));
//         assertTrue(equal(user.getRole(), newUser.getRole()),
//               String.format(OBJ_FIELD_UPDATABLE, USER, "role"));
      assertTrue(equal(user.getStoredVmQuota(), newUser.getStoredVmQuota()),
            String.format(OBJ_FIELD_UPDATABLE, USER, "storedVmQuota"));
      assertTrue(equal(user.getDeployedVmQuota(), newUser.getDeployedVmQuota()),
            String.format(OBJ_FIELD_UPDATABLE, USER, "deployedVmQuota"));
          
      // session api isn't typically exposed to the user, as it is implicit
      SessionApi sessionApi = context.utils().injector().getInstance(SessionApi.class);
View Full Code Here

   }
   @Test(description = "DELETE /admin/user/{id}", dependsOnMethods = { "testAddUser" })
   public void testRemoveUser() {
      // Create a user to be removed (so we remove dependencies on test ordering)
      User newUser = randomTestUser("testRemoveUser"+getTestDateTimeStamp());
      User userToBeDeleted = userApi.addUserToOrg(newUser, org.getId());

      // Delete the user
      userApi.remove(userToBeDeleted.getHref());

      // Confirm cannot no longer be accessed
      User removed = userApi.get(userToBeDeleted.getHref());
      assertNull(removed);
   }
View Full Code Here

      Checks.checkOwner(owner);
   }

   @Test(description = "PUT /admin/catalog/{id}/owner", dependsOnMethods = { "testGetCatalog" })
   public void editCatalogOwner() {
      User newOwnerUser = randomTestUser("testEditCatalogOwner");
      newOwnerUser = adminContext.getApi().getUserApi().addUserToOrg(newOwnerUser, org.getId());
      assertNotNull(newOwnerUser, "failed to add temp user to test editCatalogOwner");

      Owner oldOwner = owner;
      Owner newOwner = Owner.builder().type("application/vnd.vmware.vcloud.owner+xml")
               .user(Reference.builder().fromEntity(newOwnerUser).build()).build();

      try {
         catalogApi.setOwner(catalog.getId(), newOwner);
         owner = catalogApi.getOwner(catalog.getId());
         Checks.checkOwner(owner);
         assertTrue(
                  equal(owner.toBuilder().links(ImmutableSet.<Link> of()).build(),
                           newOwner.toBuilder().user(newOwner.getUser()).build()),
                  String.format(OBJ_FIELD_UPDATABLE, CATALOG, "owner"));
      } finally {
         catalogApi.setOwner(catalog.getId(), oldOwner);
         owner = catalogApi.getOwner(catalog.getId());
         adminContext.getApi().getUserApi().remove(newOwnerUser.getHref());
      }
   }
View Full Code Here

      Checks.checkOwner(owner);
   }

   @Test(description = "PUT /admin/catalog/{id}/owner", dependsOnMethods = { "testGetCatalog" })
   public void editCatalogOwner() {
      User newOwnerUser = randomTestUser("testEditCatalogOwner");
      newOwnerUser = adminContext.getApi().getUserApi().addUserToOrg(newOwnerUser, org.getId());
      assertNotNull(newOwnerUser, "failed to add temp user to test editCatalogOwner");

      Owner oldOwner = owner;
      Owner newOwner = Owner.builder().type("application/vnd.vmware.vcloud.owner+xml")
               .user(Reference.builder().fromEntity(newOwnerUser).build()).build();

      try {
         catalogApi.setOwner(catalog.getId(), newOwner);
         owner = catalogApi.getOwner(catalog.getId());
         Checks.checkOwner(owner);
         assertTrue(
                  equal(owner.toBuilder().links(ImmutableSet.<Link> of()).build(),
                           newOwner.toBuilder().user(newOwner.getUser()).build()),
                  String.format(OBJ_FIELD_UPDATABLE, CATALOG, "owner"));
      } finally {
         catalogApi.setOwner(catalog.getId(), oldOwner);
         owner = catalogApi.getOwner(catalog.getId());
         adminContext.getApi().getUserApi().remove(newOwnerUser.getHref());
      }
   }
View Full Code Here

      }
   }
  
   @Test(description = "POST /admin/org/{id}/users")
   public void testAddUser() {
      User newUser = randomTestUser("testAddUser");
      user = userApi.addUserToOrg(newUser, org.getId());
      checkUser(newUser);
   }
View Full Code Here

      checkUser(user);
   }
   @Test(description = "PUT /admin/user/{id}", dependsOnMethods = { "testGetUser" })
   public void testEditUser() {
      User oldUser = user.toBuilder().build();
      User newUser = user.toBuilder()
         .fullName("new" + oldUser.getFullName())
         .emailAddress("new" + oldUser.getEmailAddress())
         .telephone("1-" + oldUser.getTelephone())
         .isEnabled(true)
         .im("new" + oldUser.getIM())
         .isAlertEnabled(true)
         .alertEmailPrefix("new" + oldUser.getAlertEmailPrefix())
         .alertEmail("new" + oldUser.getAlertEmail())
         .storedVmQuota(1)
         .deployedVmQuota(1)
         .password("newPassword")
         // TODO test setting other fields?
//         .name("new" + oldUser.getName())
         .role(getRoleReferenceFor(DefaultRoles.AUTHOR.value()))
         .build();
     
      userApi.edit(user.getHref(), newUser);
      user = userApi.get(user.getHref());
     
      checkUser(user);
      assertTrue(equal(user.getFullName(), newUser.getFullName()),
            String.format(OBJ_FIELD_UPDATABLE, USER, "fullName"));
      assertTrue(equal(user.getEmailAddress(), newUser.getEmailAddress()),
            String.format(OBJ_FIELD_UPDATABLE, USER, "emailAddress"));
      assertTrue(equal(user.getTelephone(), newUser.getTelephone()),
            String.format(OBJ_FIELD_UPDATABLE, USER, "telephone"));
      assertTrue(equal(user.isEnabled(), newUser.isEnabled()),
            String.format(OBJ_FIELD_UPDATABLE, USER, "isEnabled"));
      assertTrue(equal(user.getIM(), newUser.getIM()),
            String.format(OBJ_FIELD_UPDATABLE, USER, "im"));
      assertTrue(equal(user.isAlertEnabled(), newUser.isAlertEnabled()),
            String.format(OBJ_FIELD_UPDATABLE, USER, "isAlertEnabled"));
      assertTrue(equal(user.getAlertEmailPrefix(), newUser.getAlertEmailPrefix()),
            String.format(OBJ_FIELD_UPDATABLE, USER, "alertEmailPrefix"));
      assertTrue(equal(user.getAlertEmail(), newUser.getAlertEmail()),
            String.format(OBJ_FIELD_UPDATABLE, USER, "alertEmail"));
//         assertTrue(equal(user.getRole(), newUser.getRole()),
//               String.format(OBJ_FIELD_UPDATABLE, USER, "role"));
      assertTrue(equal(user.getStoredVmQuota(), newUser.getStoredVmQuota()),
            String.format(OBJ_FIELD_UPDATABLE, USER, "storedVmQuota"));
      assertTrue(equal(user.getDeployedVmQuota(), newUser.getDeployedVmQuota()),
            String.format(OBJ_FIELD_UPDATABLE, USER, "deployedVmQuota"));
          
      // session api isn't typically exposed to the user, as it is implicit
      SessionApi sessionApi = context.utils().injector().getInstance(SessionApi.class);
View Full Code Here

   }
   @Test(description = "DELETE /admin/user/{id}", dependsOnMethods = { "testAddUser" })
   public void testRemoveUser() {
      // Create a user to be removed (so we remove dependencies on test ordering)
      User newUser = randomTestUser("testRemoveUser" + getTestDateTimeStamp());
      User userToBeDeleted = userApi.addUserToOrg(newUser, org.getId());

      // Delete the user
      userApi.remove(userToBeDeleted.getHref());

      // Confirm cannot no longer be accessed
      User removed = userApi.get(userToBeDeleted.getHref());
      assertNull(removed);
   }
View Full Code Here

            }
            public Authentication authenticate(Authentication authentication)
                    throws AuthenticationException {
                Object principal = authentication.getPrincipal();
                String username = String.valueOf(principal);
                User user = myUserRepository.findByUsername(username);
                if(user == null) {
                    throw new UsernameNotFoundException("No user for principal "+principal);
                }
                if(!authentication.getCredentials().equals(user.getPassword())) {
                    throw new BadCredentialsException("Invalid password");
                }
                return new TestingAuthenticationToken(principal, null, "ROLE_USER");
            }
        };
View Full Code Here

            @Override
            public Authentication authenticate(Authentication authentication)
                    throws AuthenticationException {
                Object principal = authentication.getPrincipal();
                String username = String.valueOf(principal);
                User user = myUserRepository.findByUsername(username);
                if(user == null) {
                    throw new UsernameNotFoundException("No user for principal "+principal);
                }
                if(!authentication.getCredentials().equals(user.getPassword())) {
                    throw new BadCredentialsException("Invalid password");
                }
                return new TestingAuthenticationToken(principal, null, "ROLE_USER");
            }
        };
View Full Code Here

TOP

Related Classes of org.jclouds.openstack.keystone.v2_0.domain.User$ConcreteBuilder

Copyright © 2018 www.massapicom. 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.