Package org.jclouds.cloudstack.domain

Examples of org.jclouds.cloudstack.domain.User


   @Test
   public void testCreateContextUsingUserAndPasswordAuthentication() {
      skipIfNotGlobalAdmin();

      Account testAccount = null;
      User testUser = null;

      String prefix = this.prefix + "-session";
      try {
         testAccount = createTestAccount(globalAdminClient, prefix);
         testUser = createTestUser(globalAdminClient, testAccount, prefix);

         String expectedUsername = prefix + "-user";
         assertEquals(testUser.getName(), expectedUsername);

         checkLoginAsTheNewUser(expectedUsername);

         ApiKeyPair expected = globalAdminClient.getUserClient().registerUserKeys(testUser.getId());
         ApiKeyPair actual = ApiKeyPairs.loginToEndpointAsUsernameInDomainWithPasswordAndReturnApiKeyPair(
            URI.create(endpoint), prefix + "-user", "password", "");

         assertEquals(actual, expected);

      } finally {
         if (testUser != null)
            globalAdminClient.getUserClient().deleteUser(testUser.getId());
         if (testAccount != null)
            globalAdminClient.getAccountClient().deleteAccount(testAccount.getId());
      }
   }
View Full Code Here


   @Test
   public void testEnableDisableUser() {
      skipIfNotGlobalAdmin();

      Account testAccount = null;
      User testUser = null;
      try {
         testAccount = createTestAccount(globalAdminClient, prefix);
         testUser = createTestUser(globalAdminClient, testAccount, prefix);

         AsyncCreateResponse response = domainAdminClient.getUserClient().disableUser(testUser.getId());
         assertNotNull(response);
         assertTrue(adminJobComplete.apply(response.getJobId()));

         AsyncJob<User> job = domainAdminClient.getAsyncJobClient().getAsyncJob(response.getJobId());
         assertNotNull(job);
         assertEquals(job.getResult().getState(), User.State.DISABLED);

         User updated = domainAdminClient.getUserClient().enableUser(testUser.getId());
         assertNotNull(updated);
         assertEquals(updated.getState(), User.State.ENABLED);

      } finally {
         if (testUser != null) {
            globalAdminClient.getUserClient().deleteUser(testUser.getId());
         }
View Full Code Here

   @Test
   public void testCreateUser() {
      skipIfNotGlobalAdmin();

      Account testAccount = createTestAccount(globalAdminClient, prefix);
      User testUser = null;
      try {
         testUser = createTestUser(globalAdminClient, testAccount, prefix);

         assertNotNull(testUser);
         assertEquals(testUser.getName(), prefix + "-user");
         assertEquals(testUser.getAccount(), prefix + "-account");

         User updatedUser = globalAdminClient.getUserClient()
            .updateUser(testUser.getId(), userName(prefix + "-user-2"));

         assertNotNull(updatedUser);
         assertEquals(updatedUser.getName(), prefix + "-user-2");

         ApiKeyPair apiKeys = globalAdminClient.getUserClient()
            .registerUserKeys(updatedUser.getId());

         assertNotNull(apiKeys.getApiKey());
         assertNotNull(apiKeys.getSecretKey());

         checkAuthAsUser(apiKeys);
View Full Code Here

      this.currentUserSupplier = checkNotNull(currentUserSupplier, "currentUserSupplier");
   }

   @Override
   public Map<String, Network> get() {
      User currentUser = currentUserSupplier.get();
      NetworkClient networkClient = client.getNetworkClient();
      return Maps.uniqueIndex(
            networkClient.listNetworks(accountInDomain(currentUser.getAccount(), currentUser.getDomainId())),
            new Function<Network, String>() {

               @Override
               public String apply(Network arg0) {
                  return arg0.getId();
View Full Code Here

   @Override
   public User get() {
      Iterable<User> users = Iterables.concat(client.getAccountClient().listAccounts());
      Predicate<User> apiKeyMatches = UserPredicates.apiKeyEquals(creds.get().identity);
      User currentUser = null;
      try {
         currentUser = Iterables.find(users, apiKeyMatches);
      } catch (NoSuchElementException e) {
         throw new NoSuchElementException(String.format("none of the following users match %s: %s", apiKeyMatches,
               users));
View Full Code Here

   }
  
   private static User verifyCurrentUserIsOfType(String identity, AccountClient accountClient, Account.Type type) {
      Iterable<User> users = Iterables.concat(accountClient.listAccounts());
      Predicate<User> apiKeyMatches = UserPredicates.apiKeyEquals(identity);
      User currentUser;
      try {
         currentUser = Iterables.find(users, apiKeyMatches);
      } catch (NoSuchElementException e) {
         throw new NoSuchElementException(String.format("none of the following users match %s: %s", apiKeyMatches,
               users));
      }

      if (currentUser.getAccountType() != type) {
         Logger.getAnonymousLogger().warning(
               String.format("Expecting an user with type %s. Got: %s", type.toString(), currentUser.toString()));
      }
      return currentUser;
   }
View Full Code Here

   @Test
   public void testEnableDisableUser() {
      skipIfNotGlobalAdmin();

      Account testAccount = null;
      User testUser = null;
      try {
         testAccount = createTestAccount(globalAdminClient, prefix);
         testUser = createTestUser(globalAdminClient, testAccount, prefix);

         AsyncCreateResponse response = domainAdminClient.getUserClient().disableUser(testUser.getId());
         assertNotNull(response);
         assertTrue(jobComplete.apply(response.getJobId()));

         AsyncJob<User> job = domainAdminClient.getAsyncJobClient().getAsyncJob(response.getJobId());
         assertNotNull(job);
         assertEquals(job.getResult().getState(), User.State.DISABLED);

         User updated = domainAdminClient.getUserClient().enableUser(testUser.getId());
         assertNotNull(updated);
         assertEquals(updated.getState(), User.State.ENABLED);

      } finally {
         if (testUser != null) {
            globalAdminClient.getUserClient().deleteUser(testUser.getId());
         }
View Full Code Here

      this.currentUserSupplier = checkNotNull(currentUserSupplier, "currentUserSupplier");
   }

   @Override
   public Map<String, Project> get() {
      User currentUser = currentUserSupplier.get();
      ProjectApi projectApi = api.getProjectApi();
      return Maps.uniqueIndex(
            projectApi.listProjects(accountInDomain(currentUser.getAccount(), currentUser.getDomainId())),
            new Function<Project, String>() {

               @Override
               public String apply(Project arg0) {
                  return arg0.getId();
View Full Code Here

      this.currentUserSupplier = checkNotNull(currentUserSupplier, "currentUserSupplier");
   }

   @Override
   public Map<String, Network> get() {
      User currentUser = currentUserSupplier.get();
      NetworkApi networkClient = client.getNetworkApi();
      return Maps.uniqueIndex(
            networkClient.listNetworks(accountInDomain(currentUser.getAccount(), currentUser.getDomainId())),
            new Function<Network, String>() {

               @Override
               public String apply(Network arg0) {
                  return arg0.getId();
View Full Code Here

   @Override
   public User get() {
      Iterable<User> users = Iterables.concat(client.getAccountApi().listAccounts());
      Predicate<User> apiKeyMatches = UserPredicates.apiKeyEquals(creds.get().identity);
      User currentUser = null;
      try {
         currentUser = Iterables.find(users, apiKeyMatches);
      } catch (NoSuchElementException e) {
         throw new NoSuchElementException(String.format("none of the following users match %s: %s", apiKeyMatches,
               users));
View Full Code Here

TOP

Related Classes of org.jclouds.cloudstack.domain.User

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.