get/put orgSettings

This commit is contained in:
danikov 2012-03-11 19:40:04 +00:00
parent 4077e2d9a4
commit 5817f04463
7 changed files with 270 additions and 102 deletions

View File

@ -147,6 +147,8 @@ public class VCloudDirectorMediaType {
public static final String ORG_EMAIL_SETTINGS = "application/vnd.vmware.admin.organizationEmailSettings+xml"; public static final String ORG_EMAIL_SETTINGS = "application/vnd.vmware.admin.organizationEmailSettings+xml";
public static final String ORG_SETTINGS = "application/vnd.vmware.admin.orgSettings+xml";
/** /**
* *
* All acceptable media types. * All acceptable media types.
@ -167,6 +169,6 @@ public class VCloudDirectorMediaType {
CLONE_MEDIA_PARAMS, LEASE_SETTINGS_SECTION, RELOCATE_TEMPLATE, ENVELOPE, CLONE_MEDIA_PARAMS, LEASE_SETTINGS_SECTION, RELOCATE_TEMPLATE, ENVELOPE,
PUBLISH_CATALOG_PARAMS, GROUP, ORG_VAPP_TEMPLATE_LEASE_SETTINGS, PUBLISH_CATALOG_PARAMS, GROUP, ORG_VAPP_TEMPLATE_LEASE_SETTINGS,
ORG_LEASE_SETTINGS, ORG_PASSWORD_POLICY_SETTINGS, ORG_LDAP_SETTINGS, ORG_LEASE_SETTINGS, ORG_PASSWORD_POLICY_SETTINGS, ORG_LDAP_SETTINGS,
ORG_GENERAL_SETTINGS, ORG_EMAIL_SETTINGS ORG_GENERAL_SETTINGS, ORG_EMAIL_SETTINGS, ORG_SETTINGS
); );
} }

View File

@ -69,12 +69,12 @@ import com.google.common.base.Objects.ToStringHelper;
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "OrgSettings") @XmlRootElement(name = "OrgSettings")
@XmlType(propOrder = { @XmlType(propOrder = {
"orgGeneralSettings", "generalSettings",
"vAppLeaseSettings", "vAppLeaseSettings",
"vAppTemplateLeaseSettings", "vAppTemplateLeaseSettings",
"orgLdapSettings", "ldapSettings",
"orgEmailSettings", "emailSettings",
"orgPasswordPolicySettings" "passwordPolicy"
}) })
public class OrgSettings extends ResourceType<OrgSettings> { public class OrgSettings extends ResourceType<OrgSettings> {
public static Builder builder() { public static Builder builder() {
@ -87,18 +87,18 @@ public class OrgSettings extends ResourceType<OrgSettings> {
public static class Builder extends ResourceType.Builder<OrgSettings> { public static class Builder extends ResourceType.Builder<OrgSettings> {
private OrgGeneralSettings orgGeneralSettings; private OrgGeneralSettings generalSettings;
private OrgLeaseSettings vAppLeaseSettings; private OrgLeaseSettings vAppLeaseSettings;
private OrgVAppTemplateLeaseSettings vAppTemplateLeaseSettings; private OrgVAppTemplateLeaseSettings vAppTemplateLeaseSettings;
private OrgLdapSettings orgLdapSettings; private OrgLdapSettings ldapSettings;
private OrgEmailSettings orgEmailSettings; private OrgEmailSettings emailSettings;
private OrgPasswordPolicySettings orgPasswordPolicySettings; private OrgPasswordPolicySettings passwordPolicy;
/** /**
* @see OrgSettings#getOrgGeneralSettings() * @see OrgSettings#getGeneralSettings()
*/ */
public Builder orgGeneralSettings(OrgGeneralSettings orgGeneralSettings) { public Builder orgGeneralSettings(OrgGeneralSettings generalSettings) {
this.orgGeneralSettings = orgGeneralSettings; this.generalSettings = generalSettings;
return this; return this;
} }
@ -119,32 +119,32 @@ public class OrgSettings extends ResourceType<OrgSettings> {
} }
/** /**
* @see OrgSettings#getOrgLdapSettings() * @see OrgSettings#getLdapSettings()
*/ */
public Builder orgLdapSettings(OrgLdapSettings orgLdapSettings) { public Builder orgLdapSettings(OrgLdapSettings ldapSettings) {
this.orgLdapSettings = orgLdapSettings; this.ldapSettings = ldapSettings;
return this; return this;
} }
/** /**
* @see OrgSettings#getOrgEmailSettings() * @see OrgSettings#getEmailSettings()
*/ */
public Builder orgEmailSettings(OrgEmailSettings orgEmailSettings) { public Builder orgEmailSettings(OrgEmailSettings emailSettings) {
this.orgEmailSettings = orgEmailSettings; this.emailSettings = emailSettings;
return this; return this;
} }
/** /**
* @see OrgSettings#getOrgPasswordPolicySettings() * @see OrgSettings#getPasswordPolicy()
*/ */
public Builder orgPasswordPolicySettings(OrgPasswordPolicySettings orgPasswordPolicySettings) { public Builder passwordPolicy(OrgPasswordPolicySettings passwordPolicy) {
this.orgPasswordPolicySettings = orgPasswordPolicySettings; this.passwordPolicy = passwordPolicy;
return this; return this;
} }
public OrgSettings build() { public OrgSettings build() {
return new OrgSettings(href, type, links, orgGeneralSettings, vAppLeaseSettings, return new OrgSettings(href, type, links, generalSettings, vAppLeaseSettings,
vAppTemplateLeaseSettings, orgLdapSettings, orgEmailSettings, orgPasswordPolicySettings); vAppTemplateLeaseSettings, ldapSettings, emailSettings, passwordPolicy);
} }
@ -191,12 +191,12 @@ public class OrgSettings extends ResourceType<OrgSettings> {
} }
public Builder fromOrgSettings(OrgSettings in) { public Builder fromOrgSettings(OrgSettings in) {
return fromResourceType(in) return fromResourceType(in)
.orgGeneralSettings(in.getOrgGeneralSettings()) .orgGeneralSettings(in.getGeneralSettings())
.vAppLeaseSettings(in.getVAppLeaseSettings()) .vAppLeaseSettings(in.getVAppLeaseSettings())
.vAppTemplateLeaseSettings(in.getVAppTemplateLeaseSettings()) .vAppTemplateLeaseSettings(in.getVAppTemplateLeaseSettings())
.orgLdapSettings(in.getOrgLdapSettings()) .orgLdapSettings(in.getLdapSettings())
.orgEmailSettings(in.getOrgEmailSettings()) .orgEmailSettings(in.getEmailSettings())
.orgPasswordPolicySettings(in.getOrgPasswordPolicySettings()); .passwordPolicy(in.getPasswordPolicy());
} }
} }
@ -206,31 +206,32 @@ public class OrgSettings extends ResourceType<OrgSettings> {
} }
public OrgSettings(URI href, String type, Set<Link> links, public OrgSettings(URI href, String type, Set<Link> links,
OrgGeneralSettings orgGeneralSettings, OrgGeneralSettings generalSettings,
OrgLeaseSettings vAppLeaseSettings, OrgLeaseSettings vAppLeaseSettings,
OrgVAppTemplateLeaseSettings vAppTemplateLeaseSettings, OrgVAppTemplateLeaseSettings vAppTemplateLeaseSettings,
OrgLdapSettings orgLdapSettings, OrgEmailSettings orgEmailSettings, OrgLdapSettings ldapSettings, OrgEmailSettings emailSettings,
OrgPasswordPolicySettings orgPasswordPolicySettings) { OrgPasswordPolicySettings passwordPolicy) {
super(href, type, links); super(href, type, links);
this.orgGeneralSettings = orgGeneralSettings; this.generalSettings = generalSettings;
this.vAppLeaseSettings = vAppLeaseSettings; this.vAppLeaseSettings = vAppLeaseSettings;
this.vAppTemplateLeaseSettings = vAppTemplateLeaseSettings; this.vAppTemplateLeaseSettings = vAppTemplateLeaseSettings;
this.orgLdapSettings = orgLdapSettings; this.ldapSettings = ldapSettings;
this.orgPasswordPolicySettings = orgPasswordPolicySettings; this.emailSettings = emailSettings;
this.passwordPolicy = passwordPolicy;
} }
@XmlElement(name = "OrgGeneralSettings") @XmlElement(name = "OrgGeneralSettings")
protected OrgGeneralSettings orgGeneralSettings; protected OrgGeneralSettings generalSettings;
@XmlElement(name = "VAppLeaseSettings") @XmlElement(name = "VAppLeaseSettings")
protected OrgLeaseSettings vAppLeaseSettings; protected OrgLeaseSettings vAppLeaseSettings;
@XmlElement(name = "VAppTemplateLeaseSettings") @XmlElement(name = "VAppTemplateLeaseSettings")
protected OrgVAppTemplateLeaseSettings vAppTemplateLeaseSettings; protected OrgVAppTemplateLeaseSettings vAppTemplateLeaseSettings;
@XmlElement(name = "OrgLdapSettings") @XmlElement(name = "OrgLdapSettings")
protected OrgLdapSettings orgLdapSettings; protected OrgLdapSettings ldapSettings;
@XmlElement(name = "OrgEmailSettings") @XmlElement(name = "OrgEmailSettings")
protected OrgEmailSettings orgEmailSettings; protected OrgEmailSettings emailSettings;
@XmlElement(name = "OrgPasswordPolicySettings") @XmlElement(name = "OrgPasswordPolicySettings")
protected OrgPasswordPolicySettings orgPasswordPolicySettings; protected OrgPasswordPolicySettings passwordPolicy;
/** /**
* Gets the value of the orgGeneralSettings property. * Gets the value of the orgGeneralSettings property.
@ -240,8 +241,8 @@ public class OrgSettings extends ResourceType<OrgSettings> {
* {@link OrgGeneralSettings } * {@link OrgGeneralSettings }
* *
*/ */
public OrgGeneralSettings getOrgGeneralSettings() { public OrgGeneralSettings getGeneralSettings() {
return orgGeneralSettings; return generalSettings;
} }
/** /**
@ -276,8 +277,8 @@ public class OrgSettings extends ResourceType<OrgSettings> {
* {@link OrgLdapSettings } * {@link OrgLdapSettings }
* *
*/ */
public OrgLdapSettings getOrgLdapSettings() { public OrgLdapSettings getLdapSettings() {
return orgLdapSettings; return ldapSettings;
} }
/** /**
@ -288,8 +289,8 @@ public class OrgSettings extends ResourceType<OrgSettings> {
* {@link OrgEmailSettings } * {@link OrgEmailSettings }
* *
*/ */
public OrgEmailSettings getOrgEmailSettings() { public OrgEmailSettings getEmailSettings() {
return orgEmailSettings; return emailSettings;
} }
/** /**
@ -300,8 +301,8 @@ public class OrgSettings extends ResourceType<OrgSettings> {
* {@link OrgPasswordPolicySettings } * {@link OrgPasswordPolicySettings }
* *
*/ */
public OrgPasswordPolicySettings getOrgPasswordPolicySettings() { public OrgPasswordPolicySettings getPasswordPolicy() {
return orgPasswordPolicySettings; return passwordPolicy;
} }
@Override @Override
@ -312,34 +313,34 @@ public class OrgSettings extends ResourceType<OrgSettings> {
return false; return false;
OrgSettings that = OrgSettings.class.cast(o); OrgSettings that = OrgSettings.class.cast(o);
return super.equals(that) && return super.equals(that) &&
equal(orgGeneralSettings, that.orgGeneralSettings) && equal(generalSettings, that.generalSettings) &&
equal(vAppLeaseSettings, that.vAppLeaseSettings) && equal(vAppLeaseSettings, that.vAppLeaseSettings) &&
equal(vAppTemplateLeaseSettings, that.vAppTemplateLeaseSettings) && equal(vAppTemplateLeaseSettings, that.vAppTemplateLeaseSettings) &&
equal(orgLdapSettings, that.orgLdapSettings) && equal(ldapSettings, that.ldapSettings) &&
equal(orgEmailSettings, that.orgEmailSettings) && equal(emailSettings, that.emailSettings) &&
equal(orgPasswordPolicySettings, that.orgPasswordPolicySettings); equal(passwordPolicy, that.passwordPolicy);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hashCode(super.hashCode(), return Objects.hashCode(super.hashCode(),
orgGeneralSettings, generalSettings,
vAppLeaseSettings, vAppLeaseSettings,
vAppTemplateLeaseSettings, vAppTemplateLeaseSettings,
orgLdapSettings, ldapSettings,
orgEmailSettings, emailSettings,
orgPasswordPolicySettings); passwordPolicy);
} }
@Override @Override
public ToStringHelper string() { public ToStringHelper string() {
return super.string() return super.string()
.add("orgGeneralSettings", orgGeneralSettings) .add("generalSettings", generalSettings)
.add("vAppLeaseSettings", vAppLeaseSettings) .add("vAppLeaseSettings", vAppLeaseSettings)
.add("vAppTemplateLeaseSettings", vAppTemplateLeaseSettings) .add("vAppTemplateLeaseSettings", vAppTemplateLeaseSettings)
.add("orgLdapSettings", orgLdapSettings) .add("ldapSettings", ldapSettings)
.add("orgEmailSettings", orgEmailSettings) .add("emailSettings", emailSettings)
.add("orgPasswordPolicySettings", orgPasswordPolicySettings); .add("passwordPolicy", passwordPolicy);
} }
} }

View File

@ -38,6 +38,7 @@ import org.jclouds.vcloud.director.v1_5.domain.OrgGeneralSettings;
import org.jclouds.vcloud.director.v1_5.domain.OrgLdapSettings; import org.jclouds.vcloud.director.v1_5.domain.OrgLdapSettings;
import org.jclouds.vcloud.director.v1_5.domain.OrgLeaseSettings; import org.jclouds.vcloud.director.v1_5.domain.OrgLeaseSettings;
import org.jclouds.vcloud.director.v1_5.domain.OrgPasswordPolicySettings; import org.jclouds.vcloud.director.v1_5.domain.OrgPasswordPolicySettings;
import org.jclouds.vcloud.director.v1_5.domain.OrgSettings;
import org.jclouds.vcloud.director.v1_5.domain.OrgVAppTemplateLeaseSettings; import org.jclouds.vcloud.director.v1_5.domain.OrgVAppTemplateLeaseSettings;
import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest;
import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx; import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx;
@ -57,9 +58,29 @@ public interface AdminOrgAsyncClient extends OrgAsyncClient {
// POST /admin/org/{id}/groups // POST /admin/org/{id}/groups
// GET /admin/org/{id}/settings /**
* @see AdminOrgClient#getSettings(URI)
*/
@GET
@Path("/settings")
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<OrgSettings> getSettings(
@EndpointParam URI orgRef);
// PUT /admin/org/{id}/settings /**
* @see AdminOrgClient#updateSettings(URI, OrgSettings)
*/
@PUT
@Path("/settings")
@Consumes(VCloudDirectorMediaType.ORG_SETTINGS)
@Produces(VCloudDirectorMediaType.ORG_SETTINGS)
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<OrgSettings> updateSettings(
@EndpointParam URI orgRef,
@BinderParam(BindToXMLPayload.class) OrgSettings settings);
/** /**
* @see AdminOrgClient#getEmailSettings(URI) * @see AdminOrgClient#getEmailSettings(URI)

View File

@ -28,6 +28,7 @@ import org.jclouds.vcloud.director.v1_5.domain.OrgGeneralSettings;
import org.jclouds.vcloud.director.v1_5.domain.OrgLdapSettings; import org.jclouds.vcloud.director.v1_5.domain.OrgLdapSettings;
import org.jclouds.vcloud.director.v1_5.domain.OrgLeaseSettings; import org.jclouds.vcloud.director.v1_5.domain.OrgLeaseSettings;
import org.jclouds.vcloud.director.v1_5.domain.OrgPasswordPolicySettings; import org.jclouds.vcloud.director.v1_5.domain.OrgPasswordPolicySettings;
import org.jclouds.vcloud.director.v1_5.domain.OrgSettings;
import org.jclouds.vcloud.director.v1_5.domain.OrgVAppTemplateLeaseSettings; import org.jclouds.vcloud.director.v1_5.domain.OrgVAppTemplateLeaseSettings;
/** /**
@ -45,9 +46,29 @@ public interface AdminOrgClient extends OrgClient {
// POST /admin/org/{id}/groups // POST /admin/org/{id}/groups
// GET /admin/org/{id}/settings /**
* Gets organizational settings for this organization.
*
* <pre>
* GET /admin/org/{id}/settings
* </pre>
*
* @param orgRef the reference for the admin org
* @return the settings
*/
OrgSettings getSettings(URI orgRef);
// PUT /admin/org/{id}/settings /**
* Updates organizational settings for this organization.
*
* <pre>
* PUT /admin/org/{id}/settings
* </pre>
* @param orgRef the reference for the admin org
* @param newSettings the requested updated settings
* @return the resultant settings
*/
OrgSettings updateSettings(URI orgRef, OrgSettings newSettings);
/** /**
* Retrieves email settings for an organization. * Retrieves email settings for an organization.

View File

@ -528,10 +528,10 @@ public class Checks {
} }
} }
public static void checkOrgSetting(OrgSettings settings) { public static void checkOrgSettings(OrgSettings settings) {
// Check optional fields // Check optional fields
if (settings.getOrgGeneralSettings() != null) { if (settings.getGeneralSettings() != null) {
checkGeneralSettings(settings.getOrgGeneralSettings()); checkGeneralSettings(settings.getGeneralSettings());
} }
if (settings.getVAppLeaseSettings() != null) { if (settings.getVAppLeaseSettings() != null) {
checkVAppLeaseSettings(settings.getVAppLeaseSettings()); checkVAppLeaseSettings(settings.getVAppLeaseSettings());
@ -539,14 +539,14 @@ public class Checks {
if (settings.getVAppTemplateLeaseSettings() != null) { if (settings.getVAppTemplateLeaseSettings() != null) {
checkVAppTemplateLeaseSettings(settings.getVAppTemplateLeaseSettings()); checkVAppTemplateLeaseSettings(settings.getVAppTemplateLeaseSettings());
} }
if (settings.getOrgLdapSettings() != null) { if (settings.getLdapSettings() != null) {
checkLdapSettings(settings.getOrgLdapSettings()); checkLdapSettings(settings.getLdapSettings());
} }
if (settings.getOrgEmailSettings() != null) { if (settings.getEmailSettings() != null) {
checkEmailSettings(settings.getOrgEmailSettings()); checkEmailSettings(settings.getEmailSettings());
} }
if (settings.getOrgPasswordPolicySettings() != null) { if (settings.getPasswordPolicy() != null) {
checkPasswordPolicySettings(settings.getOrgPasswordPolicySettings()); checkPasswordPolicySettings(settings.getPasswordPolicy());
} }
// parent type // parent type
@ -561,7 +561,6 @@ public class Checks {
checkEmailAddress(settings.getFromEmailAddress()); checkEmailAddress(settings.getFromEmailAddress());
assertNotNull(settings.getDefaultSubjectPrefix(), String.format(OBJ_FIELD_REQ, "OrgEmailSettings", "defaultSubjectPrefix")); assertNotNull(settings.getDefaultSubjectPrefix(), String.format(OBJ_FIELD_REQ, "OrgEmailSettings", "defaultSubjectPrefix"));
assertNotNull(settings.isAlertEmailToAllAdmins(), String.format(OBJ_FIELD_REQ, "OrgEmailSettings", "isAlertEmailToAllAdmins")); assertNotNull(settings.isAlertEmailToAllAdmins(), String.format(OBJ_FIELD_REQ, "OrgEmailSettings", "isAlertEmailToAllAdmins"));
assertNotNull(settings.getAlertEmailsTo(), String.format(OBJ_FIELD_REQ, "OrgEmailSettings", "alertEmailsTo"));
// optional // optional
// NOTE alertEmailsTo cannot be checked // NOTE alertEmailsTo cannot be checked

View File

@ -30,6 +30,7 @@ import org.jclouds.vcloud.director.v1_5.domain.OrgGeneralSettings;
import org.jclouds.vcloud.director.v1_5.domain.OrgLdapSettings; import org.jclouds.vcloud.director.v1_5.domain.OrgLdapSettings;
import org.jclouds.vcloud.director.v1_5.domain.OrgLeaseSettings; import org.jclouds.vcloud.director.v1_5.domain.OrgLeaseSettings;
import org.jclouds.vcloud.director.v1_5.domain.OrgPasswordPolicySettings; import org.jclouds.vcloud.director.v1_5.domain.OrgPasswordPolicySettings;
import org.jclouds.vcloud.director.v1_5.domain.OrgSettings;
import org.jclouds.vcloud.director.v1_5.domain.OrgVAppTemplateLeaseSettings; import org.jclouds.vcloud.director.v1_5.domain.OrgVAppTemplateLeaseSettings;
import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.Reference;
import org.jclouds.vcloud.director.v1_5.domain.SmtpServerSettings; import org.jclouds.vcloud.director.v1_5.domain.SmtpServerSettings;
@ -54,9 +55,60 @@ public class AdminOrgClientExpectTest extends BaseVCloudDirectorRestClientExpect
// POST /admin/org/{id}/groups // POST /admin/org/{id}/groups
// GET /admin/org/{id}/settings @Test
public void testGetSettings() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("GET", "/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/")
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/org/admin/settings.xml",
VCloudDirectorMediaType.ORG_SETTINGS)
.httpResponseBuilder().build());
// PUT /admin/org/{id}/settings OrgSettings expected = settings();
assertEquals(client.getAdminOrgClient().getSettings(orgRef.getURI()), expected);
}
public static final OrgSettings settings() {
return OrgSettings.builder()
.type("application/vnd.vmware.admin.organizationSettings+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/"))
.link(Link.builder()
.rel("edit")
.type("application/vnd.vmware.admin.organizationSettings+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/"))
.build())
.build();
}
@Test
public void testUpdateSettings() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("PUT", "/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/")
.xmlFilePayload("/org/admin/updateSettingsSource.xml",
VCloudDirectorMediaType.ORG_SETTINGS)
.acceptMedia(VCloudDirectorMediaType.ORG_SETTINGS)
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/org/admin/updateSettings.xml",
VCloudDirectorMediaType.ORG_SETTINGS)
.httpResponseBuilder().build());
OrgSettings expected = updateSettings();
assertEquals(client.getAdminOrgClient().updateSettings(orgRef.getURI(), expected), expected);
}
@Test
public static final OrgSettings updateSettings() {
return settings().toBuilder()
.build();
}
@Test @Test
public void testGetEmailSettings() { public void testGetEmailSettings() {
@ -239,10 +291,10 @@ public class AdminOrgClientExpectTest extends BaseVCloudDirectorRestClientExpect
} }
@Test @Test
public void testUpdateOrgPasswordPolicy() { public void testUpdatePasswordPolicy() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer() new VcloudHttpRequestPrimer()
.apiCommand("PUT", "/admin/org/???/settings/passwordPolicy") .apiCommand("PUT", "/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/passwordPolicy")
.xmlFilePayload("/org/admin/updatePasswordPolicySource.xml", .xmlFilePayload("/org/admin/updatePasswordPolicySource.xml",
VCloudDirectorMediaType.ORG_PASSWORD_POLICY_SETTINGS) VCloudDirectorMediaType.ORG_PASSWORD_POLICY_SETTINGS)
.acceptMedia(VCloudDirectorMediaType.ORG_PASSWORD_POLICY_SETTINGS) .acceptMedia(VCloudDirectorMediaType.ORG_PASSWORD_POLICY_SETTINGS)
@ -269,7 +321,7 @@ public class AdminOrgClientExpectTest extends BaseVCloudDirectorRestClientExpect
public void testGetVAppLeaseSettings() { public void testGetVAppLeaseSettings() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer() new VcloudHttpRequestPrimer()
.apiCommand("GET", "/admin/org/???/settings/vAppLeaseSettings") .apiCommand("GET", "/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/vAppLeaseSettings")
.acceptAnyMedia() .acceptAnyMedia()
.httpRequestBuilder().build(), .httpRequestBuilder().build(),
new VcloudHttpResponsePrimer() new VcloudHttpResponsePrimer()
@ -292,7 +344,7 @@ public class AdminOrgClientExpectTest extends BaseVCloudDirectorRestClientExpect
public void testUpdateOrgVAppLeaseSettings() { public void testUpdateOrgVAppLeaseSettings() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer() new VcloudHttpRequestPrimer()
.apiCommand("PUT", "/admin/org/???/settings/vAppLeaseSettings") .apiCommand("PUT", "/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/vAppLeaseSettings")
.xmlFilePayload("/org/admin/updateVAppLeaseSettingsSource.xml", .xmlFilePayload("/org/admin/updateVAppLeaseSettingsSource.xml",
VCloudDirectorMediaType.ORG_LEASE_SETTINGS) VCloudDirectorMediaType.ORG_LEASE_SETTINGS)
.acceptMedia(VCloudDirectorMediaType.ORG_LEASE_SETTINGS) .acceptMedia(VCloudDirectorMediaType.ORG_LEASE_SETTINGS)
@ -317,7 +369,7 @@ public class AdminOrgClientExpectTest extends BaseVCloudDirectorRestClientExpect
public void testGetVAppTemplateLeaseSettings() { public void testGetVAppTemplateLeaseSettings() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer() new VcloudHttpRequestPrimer()
.apiCommand("GET", "/admin/org/???/settings/vAppTemplateLeaseSettings") .apiCommand("GET", "/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/vAppTemplateLeaseSettings")
.acceptAnyMedia() .acceptAnyMedia()
.httpRequestBuilder().build(), .httpRequestBuilder().build(),
new VcloudHttpResponsePrimer() new VcloudHttpResponsePrimer()
@ -340,7 +392,7 @@ public class AdminOrgClientExpectTest extends BaseVCloudDirectorRestClientExpect
public void testUpdateOrgVAppTemplateLeaseSettings() { public void testUpdateOrgVAppTemplateLeaseSettings() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer() new VcloudHttpRequestPrimer()
.apiCommand("PUT", "/admin/org/???/settings/vAppTemplateLeaseSettings") .apiCommand("PUT", "/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/vAppTemplateLeaseSettings")
.xmlFilePayload("/org/admin/updateVAppLeaseSettingsSource.xml", .xmlFilePayload("/org/admin/updateVAppLeaseSettingsSource.xml",
VCloudDirectorMediaType.ORG_VAPP_TEMPLATE_LEASE_SETTINGS) VCloudDirectorMediaType.ORG_VAPP_TEMPLATE_LEASE_SETTINGS)
.acceptMedia(VCloudDirectorMediaType.ORG_VAPP_TEMPLATE_LEASE_SETTINGS) .acceptMedia(VCloudDirectorMediaType.ORG_VAPP_TEMPLATE_LEASE_SETTINGS)

View File

@ -29,6 +29,7 @@ import org.jclouds.vcloud.director.v1_5.domain.OrgGeneralSettings;
import org.jclouds.vcloud.director.v1_5.domain.OrgLdapSettings; import org.jclouds.vcloud.director.v1_5.domain.OrgLdapSettings;
import org.jclouds.vcloud.director.v1_5.domain.OrgLeaseSettings; import org.jclouds.vcloud.director.v1_5.domain.OrgLeaseSettings;
import org.jclouds.vcloud.director.v1_5.domain.OrgPasswordPolicySettings; import org.jclouds.vcloud.director.v1_5.domain.OrgPasswordPolicySettings;
import org.jclouds.vcloud.director.v1_5.domain.OrgSettings;
import org.jclouds.vcloud.director.v1_5.domain.OrgVAppTemplateLeaseSettings; import org.jclouds.vcloud.director.v1_5.domain.OrgVAppTemplateLeaseSettings;
import org.jclouds.vcloud.director.v1_5.domain.ReferenceType; import org.jclouds.vcloud.director.v1_5.domain.ReferenceType;
import org.jclouds.vcloud.director.v1_5.domain.SmtpServerSettings; import org.jclouds.vcloud.director.v1_5.domain.SmtpServerSettings;
@ -59,11 +60,13 @@ public class AdminOrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
*/ */
private ReferenceType<?> orgRef; private ReferenceType<?> orgRef;
private AdminOrg org; private AdminOrg org;
OrgEmailSettings emailSettings; private OrgSettings settings, newSettings;
OrgGeneralSettings generalSettings; private OrgEmailSettings emailSettings, newEmailSettings;
OrgPasswordPolicySettings passwordPolicy; private OrgGeneralSettings generalSettings, newGeneralSettings;
OrgLeaseSettings vAppLeaseSettings; private OrgLdapSettings ldapSettings, newLdapSettings;
OrgVAppTemplateLeaseSettings vAppTemplateLeaseSettings; private OrgPasswordPolicySettings passwordPolicy, newPasswordPolicy;
private OrgLeaseSettings vAppLeaseSettings, newVAppLeaseSettings;
private OrgVAppTemplateLeaseSettings vAppTemplateLeaseSettings, newVAppTemplateLeaseSettings;
@Override @Override
@BeforeClass(inheritGroups = true) @BeforeClass(inheritGroups = true)
@ -79,9 +82,7 @@ public class AdminOrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
// POST /admin/org/{id}/groups // POST /admin/org/{id}/groups
// GET /admin/org/{id}/settings
// PUT /admin/org/{id}/settings
@Test(testName = "GET /admin/org/{id}/settings/emailSettings") @Test(testName = "GET /admin/org/{id}/settings/emailSettings")
public void testGetEmailSettings() { public void testGetEmailSettings() {
@ -109,7 +110,7 @@ public class AdminOrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
.build(); .build();
try { try {
emailSettings = emailSettings.toBuilder() newEmailSettings = emailSettings.toBuilder()
.isDefaultSmtpServer(!isDefaultSmtpServer) .isDefaultSmtpServer(!isDefaultSmtpServer)
.isDefaultOrgEmail(!isDefaultOrgEmail) .isDefaultOrgEmail(!isDefaultOrgEmail)
.fromEmailAddress(newFromEmailAddress) .fromEmailAddress(newFromEmailAddress)
@ -119,7 +120,7 @@ public class AdminOrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
.build(); .build();
emailSettings = orgClient.updateEmailSettings( emailSettings = orgClient.updateEmailSettings(
orgRef.getURI(), emailSettings); orgRef.getURI(), newEmailSettings);
assertTrue(equal(emailSettings.isDefaultSmtpServer(), !isDefaultSmtpServer), assertTrue(equal(emailSettings.isDefaultSmtpServer(), !isDefaultSmtpServer),
String.format(OBJ_FIELD_UPDATABLE, String.format(OBJ_FIELD_UPDATABLE,
@ -175,7 +176,7 @@ public class AdminOrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
Integer delayAfterPowerOnSeconds = generalSettings.getDelayAfterPowerOnSeconds(); Integer delayAfterPowerOnSeconds = generalSettings.getDelayAfterPowerOnSeconds();
try { try {
generalSettings = generalSettings.toBuilder() newGeneralSettings = generalSettings.toBuilder()
// .canPublishCatalogs(!canPublishCatalogs) // .canPublishCatalogs(!canPublishCatalogs)
.deployedVMQuota(deployedVMQuota+1) .deployedVMQuota(deployedVMQuota+1)
.storedVmQuota(storedVmQuota+1) .storedVmQuota(storedVmQuota+1)
@ -184,7 +185,7 @@ public class AdminOrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
.build(); .build();
generalSettings = orgClient.updateGeneralSettings( generalSettings = orgClient.updateGeneralSettings(
orgRef.getURI(), generalSettings); orgRef.getURI(), newGeneralSettings);
// assertTrue(equal(generalSettings.canPublishCatalogs(), !canPublishCatalogs), // assertTrue(equal(generalSettings.canPublishCatalogs(), !canPublishCatalogs),
// String.format(OBJ_FIELD_UPDATABLE, // String.format(OBJ_FIELD_UPDATABLE,
@ -220,8 +221,8 @@ public class AdminOrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
} }
@Test(testName = "GET /admin/org/{id}/settings/ldap") @Test(testName = "GET /admin/org/{id}/settings/ldap")
public void getLdapSettings() { public void testGetLdapSettings() {
OrgLdapSettings ldapSettings = orgClient.getLdapSettings(orgRef.getURI()); ldapSettings = orgClient.getLdapSettings(orgRef.getURI());
Checks.checkLdapSettings(ldapSettings); Checks.checkLdapSettings(ldapSettings);
} }
@ -241,14 +242,14 @@ public class AdminOrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
Integer accountLockoutIntervalMinutes = passwordPolicy.getAccountLockoutIntervalMinutes(); Integer accountLockoutIntervalMinutes = passwordPolicy.getAccountLockoutIntervalMinutes();
try { try {
passwordPolicy = passwordPolicy.toBuilder() newPasswordPolicy = passwordPolicy.toBuilder()
.accountLockoutEnabled(!accountLockoutEnabled) .accountLockoutEnabled(!accountLockoutEnabled)
.invalidLoginsBeforeLockout(invalidLoginsBeforeLockout+1) .invalidLoginsBeforeLockout(invalidLoginsBeforeLockout+1)
.accountLockoutIntervalMinutes(accountLockoutIntervalMinutes+1) .accountLockoutIntervalMinutes(accountLockoutIntervalMinutes+1)
.build(); .build();
passwordPolicy = orgClient.updatePasswordPolicy( passwordPolicy = orgClient.updatePasswordPolicy(
orgRef.getURI(), passwordPolicy); orgRef.getURI(), newPasswordPolicy);
assertTrue(equal(passwordPolicy.isAccountLockoutEnabled(), !accountLockoutEnabled), assertTrue(equal(passwordPolicy.isAccountLockoutEnabled(), !accountLockoutEnabled),
String.format(OBJ_FIELD_UPDATABLE, String.format(OBJ_FIELD_UPDATABLE,
@ -290,14 +291,14 @@ public class AdminOrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
Integer deploymentLeaseSeconds = vAppLeaseSettings.getDeploymentLeaseSeconds(); Integer deploymentLeaseSeconds = vAppLeaseSettings.getDeploymentLeaseSeconds();
try { try {
vAppLeaseSettings = vAppLeaseSettings.toBuilder() newVAppLeaseSettings = vAppLeaseSettings.toBuilder()
.deleteOnStorageLeaseExpiration(!deleteOnStorageLeaseExpiration) .deleteOnStorageLeaseExpiration(!deleteOnStorageLeaseExpiration)
.storageLeaseSeconds(storageLeaseSeconds+1) .storageLeaseSeconds(storageLeaseSeconds+1)
.deploymentLeaseSeconds(deploymentLeaseSeconds+1) .deploymentLeaseSeconds(deploymentLeaseSeconds+1)
.build(); .build();
vAppLeaseSettings = orgClient.updateVAppLeaseSettings( vAppLeaseSettings = orgClient.updateVAppLeaseSettings(
orgRef.getURI(), vAppLeaseSettings); orgRef.getURI(), newVAppLeaseSettings);
assertTrue(equal(vAppLeaseSettings.deleteOnStorageLeaseExpiration(), !deleteOnStorageLeaseExpiration), assertTrue(equal(vAppLeaseSettings.deleteOnStorageLeaseExpiration(), !deleteOnStorageLeaseExpiration),
String.format(OBJ_FIELD_UPDATABLE, String.format(OBJ_FIELD_UPDATABLE,
@ -338,13 +339,13 @@ public class AdminOrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
Integer storageLeaseSeconds = vAppTemplateLeaseSettings.getStorageLeaseSeconds(); Integer storageLeaseSeconds = vAppTemplateLeaseSettings.getStorageLeaseSeconds();
try { try {
vAppTemplateLeaseSettings = vAppTemplateLeaseSettings.toBuilder() newVAppTemplateLeaseSettings = vAppTemplateLeaseSettings.toBuilder()
.deleteOnStorageLeaseExpiration(!deleteOnStorageLeaseExpiration) .deleteOnStorageLeaseExpiration(!deleteOnStorageLeaseExpiration)
.storageLeaseSeconds(storageLeaseSeconds+1) .storageLeaseSeconds(storageLeaseSeconds+1)
.build(); .build();
vAppTemplateLeaseSettings = orgClient.updateVAppTemplateLeaseSettings( vAppTemplateLeaseSettings = orgClient.updateVAppTemplateLeaseSettings(
orgRef.getURI(), vAppTemplateLeaseSettings); orgRef.getURI(), newVAppTemplateLeaseSettings);
assertTrue(equal(vAppTemplateLeaseSettings.deleteOnStorageLeaseExpiration(), !deleteOnStorageLeaseExpiration), assertTrue(equal(vAppTemplateLeaseSettings.deleteOnStorageLeaseExpiration(), !deleteOnStorageLeaseExpiration),
String.format(OBJ_FIELD_UPDATABLE, String.format(OBJ_FIELD_UPDATABLE,
@ -366,4 +367,75 @@ public class AdminOrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
orgRef.getURI(), vAppTemplateLeaseSettings); orgRef.getURI(), vAppTemplateLeaseSettings);
} }
} }
@Test(testName = "GET /admin/org/{id}/settings/settings",
dependsOnMethods = { "testGetGeneralSettings",
"testGetVAppLeaseSettings",
"testGetVAppTemplateLeaseSettings",
"testGetLdapSettings",
"testGetEmailSettings",
"testGetPasswordPolicy"})
public void testGetSettings() {
settings = orgClient.getSettings(orgRef.getURI());
Checks.checkOrgSettings(settings);
}
@Test(testName = "PUT /admin/org/{id}/settings/settings",
dependsOnMethods = { "testUpdateGeneralSettings",
"testUpdateVAppLeaseSettings",
"testUpdateVAppTemplateLeaseSettings",
"testUpdateEmailSettings",
"testUpdatePasswordPolicy"},
enabled = false )
public void testUpdateSettings() {
try {
newSettings = settings.toBuilder()
.orgGeneralSettings(newGeneralSettings)
.vAppLeaseSettings(newVAppLeaseSettings)
.vAppTemplateLeaseSettings(newVAppTemplateLeaseSettings)
.orgLdapSettings(newLdapSettings)
.orgEmailSettings(newEmailSettings)
.passwordPolicy(newPasswordPolicy)
.build();
settings = orgClient.updateSettings(
orgRef.getURI(), newSettings);
assertTrue(equal(settings.getGeneralSettings(), newGeneralSettings),
String.format(OBJ_FIELD_UPDATABLE,
"orgSettings", "generalSettings"));
assertTrue(equal(settings.getVAppLeaseSettings(), newVAppLeaseSettings),
String.format(OBJ_FIELD_UPDATABLE,
"orgSettings", "vAppLeaseSettings"));
assertTrue(equal(settings.getVAppTemplateLeaseSettings(), newVAppTemplateLeaseSettings),
String.format(OBJ_FIELD_UPDATABLE,
"orgSettings", "vAppTemplateLeaseSettings"));
assertTrue(equal(settings.getLdapSettings(), newLdapSettings),
String.format(OBJ_FIELD_UPDATABLE,
"orgSettings", "ldapSettings"));
assertTrue(equal(settings.getEmailSettings(), newEmailSettings),
String.format(OBJ_FIELD_UPDATABLE,
"orgSettings", "emailSettings"));
assertTrue(equal(settings.getPasswordPolicy(), newPasswordPolicy),
String.format(OBJ_FIELD_UPDATABLE,
"orgSettings", "passwordPolicy"));
//TODO negative tests?
Checks.checkOrgSettings(settings);
} finally {
settings = settings.toBuilder()
.orgGeneralSettings(generalSettings)
.vAppLeaseSettings(vAppLeaseSettings)
.vAppTemplateLeaseSettings(vAppTemplateLeaseSettings)
.orgLdapSettings(ldapSettings)
.orgEmailSettings(emailSettings)
.passwordPolicy(passwordPolicy)
.build();
settings = orgClient.updateSettings(
orgRef.getURI(), settings);
}
}
} }