Package org.jclouds.cloudstack.domain

Examples of org.jclouds.cloudstack.domain.Account


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

      Account account = null;
      try {
         account = createTestAccount(globalAdminClient, prefix);

         assertNotNull(account);
         assertEquals(account.getName(), prefix + "-account");
         assertEquals(account.getType(), Account.Type.USER);

         Account updated = globalAdminClient.getAccountClient().updateAccount(
            account.getName(), account.getDomainId(), prefix + "-account-2");

         assertNotNull(updated);
         assertEquals(updated.getName(), prefix + "-account-2");

      } finally {
         if (account != null) {
            globalAdminClient.getAccountClient().deleteAccount(account.getId());
         }
View Full Code Here


   @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());
         }
         if (testAccount != null) {
            globalAdminClient.getAccountClient().deleteAccount(testAccount.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);

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

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

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

         AsyncCreateResponse response = domainAdminClient.getAccountClient()
            .disableAccount(testAccount.getName(), testAccount.getDomainId(), false);
         assertNotNull(response);
         assertTrue(adminJobComplete.apply(response.getJobId()));

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

         Account updated = domainAdminClient.getAccountClient()
            .enableAccount(testAccount.getName(), testAccount.getDomainId());
         assertNotNull(updated);
         assertEquals(updated.getState(), Account.State.ENABLED);

      } finally {
         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(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());
         }
         if (testAccount != null) {
            globalAdminClient.getAccountClient().deleteAccount(testAccount.getId());
         }
      }
   }
View Full Code Here

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

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

         AsyncCreateResponse response = domainAdminClient.getAccountClient()
            .disableAccount(testAccount.getName(), testAccount.getDomainId(), false);
         assertNotNull(response);
         assertTrue(jobComplete.apply(response.getJobId()));

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

         Account updated = domainAdminClient.getAccountClient()
            .enableAccount(testAccount.getName(), testAccount.getDomainId());
         assertNotNull(updated);
         assertEquals(updated.getState(), Account.State.ENABLED);

      } finally {
         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.getAsyncJobApi().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());
         }
         if (testAccount != null) {
            globalAdminClient.getAccountApi().deleteAccount(testAccount.getId());
         }
      }
   }
View Full Code Here

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

      Account account = null;
      try {
         account = createTestAccount(globalAdminClient, prefix);

         assertNotNull(account);
         assertEquals(account.getName(), prefix + "-account");
         assertEquals(account.getType(), Account.Type.USER);

         Account updated = globalAdminClient.getAccountApi().updateAccount(
            account.getName(), account.getDomainId(), prefix + "-account-2");

         assertNotNull(updated);
         assertEquals(updated.getName(), prefix + "-account-2");

      } finally {
         if (account != null) {
            globalAdminClient.getAccountApi().deleteAccount(account.getId());
         }
View Full Code Here

   @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.getAccountApi().deleteAccount(testAccount.getId());
      }
   }
View Full Code Here

TOP

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

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.