Package org.jclouds.vcloud.director.v1_5.domain.section

Examples of org.jclouds.vcloud.director.v1_5.domain.section.LeaseSettingsSection$ConcreteBuilder


   }

   @Test(description = "GET /vApp/{id}/leaseSettingsSection", dependsOnMethods = { "testGetVApp" })
   public void testGetLeaseSettingsSection() {
      // The method under test
      LeaseSettingsSection section = vAppApi.getLeaseSettingsSection(vAppUrn);

      // Check the retrieved object is well formed
      checkLeaseSettingsSection(section);
   }
View Full Code Here


   }

   @Test(groups = { "live", "user" }, description = "PUT /vApp/{id}/leaseSettingsSection", dependsOnMethods = { "testGetLeaseSettingsSection" })
   public void testEditLeaseSettingsSection() {
      // Copy existing section
      LeaseSettingsSection oldSection = vAppApi.getLeaseSettingsSection(vAppUrn);
      Integer twoHours = (int) TimeUnit.SECONDS.convert(2L, TimeUnit.HOURS);
      LeaseSettingsSection newSection = oldSection.toBuilder().deploymentLeaseInSeconds(twoHours).build();

      // The method under test
      Task editLeaseSettingsSection = vAppApi.editLeaseSettingsSection(vAppUrn, newSection);
      assertTrue(retryTaskSuccess.apply(editLeaseSettingsSection),
               String.format(TASK_COMPLETE_TIMELY, "editLeaseSettingsSection"));

      // Retrieve the modified section
      LeaseSettingsSection modified = vAppApi.getLeaseSettingsSection(vAppUrn);

      // Check the retrieved object is well formed
      checkLeaseSettingsSection(modified);

      // Check the date fields
      if (modified.getDeploymentLeaseExpiration() != null && newSection.getDeploymentLeaseExpiration() != null) {
         assertTrue(modified.getDeploymentLeaseExpiration().after(newSection.getDeploymentLeaseExpiration()),
                  String.format("The new deploymentLeaseExpiration timestamp must be later than the original: %s > %s",
                           dateService.iso8601DateFormat(modified.getDeploymentLeaseExpiration()),
                           dateService.iso8601DateFormat(newSection.getDeploymentLeaseExpiration())));
      }
      if (modified.getStorageLeaseExpiration() != null && newSection.getStorageLeaseExpiration() != null) {
         assertTrue(modified.getStorageLeaseExpiration().after(newSection.getStorageLeaseExpiration()), String.format(
                  "The new storageLeaseExpiration timestamp must be later than the original: %s > %s",
                  dateService.iso8601DateFormat(modified.getStorageLeaseExpiration()),
                  dateService.iso8601DateFormat(newSection.getStorageLeaseExpiration())));
      }

      // Reset the date fields
      modified = modified.toBuilder().deploymentLeaseExpiration(null).storageLeaseExpiration(null).build();
      newSection = newSection.toBuilder().deploymentLeaseExpiration(null).storageLeaseExpiration(null).build();

      // Check the section was modified correctly
      assertEquals(
               modified.getDeploymentLeaseInSeconds(),
               twoHours,
               String.format(OBJ_FIELD_EQ, "LeaseSettingsSection", "DeploymentLeaseInSeconds",
                        Integer.toString(twoHours), modified.getDeploymentLeaseInSeconds().toString()));
      assertEquals(modified, newSection, String.format(ENTITY_EQUAL, "LeaseSettingsSection"));
   }
View Full Code Here

      return task;
   }

   public static LeaseSettingsSection getLeaseSettingsSection() {
      LeaseSettingsSection section = LeaseSettingsSection.builder()
            .build();

      return section;
   }
View Full Code Here

      return task;
   }

   public static LeaseSettingsSection getLeaseSettingsSection() {
      LeaseSettingsSection section = LeaseSettingsSection.builder()
            .build();

      return section;
   }
View Full Code Here

            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);

      // Check the user can really login with the changed password
      // NOTE: the password is NOT returned in the User object returned from the server
      SessionWithToken sessionWithToken = sessionApi.loginUserInOrgWithPassword(URI.create(endpoint + "/sessions"), user.getName(), org.getName(), "newPassword");
      assertNotNull(sessionWithToken.getToken());
      sessionApi.logoutSessionWithToken(sessionWithToken.getSession().getHref(), sessionWithToken.getToken());
   }
View Full Code Here

      // Need to know how many times to fail login to lock account
      AdminOrgApi adminOrgApi = adminContext.getApi().getOrgApi();
      OrgPasswordPolicySettings settingsToRevertTo = null;

      // session api isn't typically exposed to the user, as it is implicit
      SessionApi sessionApi = context.utils().injector().getInstance(SessionApi.class);
     
      OrgPasswordPolicySettings settings = adminOrgApi.getSettings(org.getId()).getPasswordPolicy();
      assertNotNull(settings);

      // Adjust account settings so we can lock the account - be careful to not set invalidLoginsBeforeLockout too low!
      if (!settings.isAccountLockoutEnabled()) {
         settingsToRevertTo = settings;
         settings = settings.toBuilder().accountLockoutEnabled(true).invalidLoginsBeforeLockout(5).build();
         settings = adminOrgApi.editPasswordPolicy(org.getId(), settings);
      }

      assertTrue(settings.isAccountLockoutEnabled());
     
      for (int i = 0; i < settings.getInvalidLoginsBeforeLockout() + 1; i++) {
         try {
            sessionApi.loginUserInOrgWithPassword(URI.create(endpoint + "/sessions"), user.getName(), org.getName(), "wrongpassword!");
            fail("Managed to login using the wrong password!");
         } catch (AuthorizationException e) {
         } catch (Exception e) {
            fail("Expected AuthorizationException", e);
         }
      }
     
      user = userApi.get(user.getHref());
      assertTrue(user.isLocked());

      try {
         sessionApi.loginUserInOrgWithPassword(URI.create(endpoint + "/sessions"), user.getName(), org.getName(), "newPassword");
         fail("Managed to login to locked account!");
      } catch (AuthorizationException e) {
      } catch (Exception e) {
         fail("Expected AuthorizationException", e);
      }
     
      userApi.unlock(user.getHref());

      user = userApi.get(user.getHref());
      assertFalse(user.isLocked());

      // Double-check the user can now login again
      SessionWithToken sessionWithToken = sessionApi.loginUserInOrgWithPassword(URI.create(endpoint + "/sessions"), user.getName(), org.getName(), "newPassword");
      assertNotNull(sessionWithToken.getToken());
      sessionApi.logoutSessionWithToken(sessionWithToken.getSession().getHref(), sessionWithToken.getToken());
     
      // Return account settings to the previous values, if necessary
      if (settingsToRevertTo != null) {
         adminOrgApi.editPasswordPolicy(org.getId(), settingsToRevertTo);
      }
View Full Code Here

      HttpResponse listResponse = HttpResponse.builder()
               .statusCode(200)
               .payload(payloadFromResourceWithContentType("/org/orglist.xml", ORG_LIST + ";version=1.5"))
               .build();
     
      VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse, list, listResponse);


      OrgList expected = OrgList.builder()
            .org(Reference.builder()
               .type("application/vnd.vmware.vcloud.org+xml")
               .name("JClouds")
               .href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
               .build())
            .build();

      assertEquals(api.getOrgApi().list(), expected);
   }
View Full Code Here

            .payload(payloadFromResourceWithContentType("/org/org.xml", ORG + ";version=1.5"))
            .build();
   
   @Test
   public void testGetOrgHref() {
      VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse, get, getResponse);
      assertEquals(api.getOrgApi().get(orgHref), org());
   }
View Full Code Here

           .payload(payloadFromStringWithContentType(orgEntity, ENTITY + ";version=1.5"))
           .build();
  
   @Test
   public void testGetOrgUrn() {
      VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse, resolveOrg, resolveOrgResponse, get, getResponse);
      assertEquals(api.getOrgApi().get(orgUrn), org());
   }
View Full Code Here

            .payload(payloadFromResourceWithContentType("/org/orgMetadata.xml", METADATA))
            .build();

   @Test
   public void testGetOrgMetadataHref() {
      VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse, getMetadata, getMetadataResponse);
      assertEquals(api.getMetadataApi(orgHref).get(), metadata());
   }
View Full Code Here

TOP

Related Classes of org.jclouds.vcloud.director.v1_5.domain.section.LeaseSettingsSection$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.