mirror of https://github.com/apache/jclouds.git
get/put orgSettings
This commit is contained in:
parent
4077e2d9a4
commit
5817f04463
|
@ -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_SETTINGS = "application/vnd.vmware.admin.orgSettings+xml";
|
||||
|
||||
/**
|
||||
*
|
||||
* All acceptable media types.
|
||||
|
@ -167,6 +169,6 @@ public class VCloudDirectorMediaType {
|
|||
CLONE_MEDIA_PARAMS, LEASE_SETTINGS_SECTION, RELOCATE_TEMPLATE, ENVELOPE,
|
||||
PUBLISH_CATALOG_PARAMS, GROUP, ORG_VAPP_TEMPLATE_LEASE_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
|
||||
);
|
||||
}
|
||||
|
|
|
@ -69,12 +69,12 @@ import com.google.common.base.Objects.ToStringHelper;
|
|||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlRootElement(name = "OrgSettings")
|
||||
@XmlType(propOrder = {
|
||||
"orgGeneralSettings",
|
||||
"generalSettings",
|
||||
"vAppLeaseSettings",
|
||||
"vAppTemplateLeaseSettings",
|
||||
"orgLdapSettings",
|
||||
"orgEmailSettings",
|
||||
"orgPasswordPolicySettings"
|
||||
"ldapSettings",
|
||||
"emailSettings",
|
||||
"passwordPolicy"
|
||||
})
|
||||
public class OrgSettings extends ResourceType<OrgSettings> {
|
||||
public static Builder builder() {
|
||||
|
@ -87,18 +87,18 @@ public class OrgSettings extends ResourceType<OrgSettings> {
|
|||
|
||||
public static class Builder extends ResourceType.Builder<OrgSettings> {
|
||||
|
||||
private OrgGeneralSettings orgGeneralSettings;
|
||||
private OrgGeneralSettings generalSettings;
|
||||
private OrgLeaseSettings vAppLeaseSettings;
|
||||
private OrgVAppTemplateLeaseSettings vAppTemplateLeaseSettings;
|
||||
private OrgLdapSettings orgLdapSettings;
|
||||
private OrgEmailSettings orgEmailSettings;
|
||||
private OrgPasswordPolicySettings orgPasswordPolicySettings;
|
||||
private OrgLdapSettings ldapSettings;
|
||||
private OrgEmailSettings emailSettings;
|
||||
private OrgPasswordPolicySettings passwordPolicy;
|
||||
|
||||
/**
|
||||
* @see OrgSettings#getOrgGeneralSettings()
|
||||
* @see OrgSettings#getGeneralSettings()
|
||||
*/
|
||||
public Builder orgGeneralSettings(OrgGeneralSettings orgGeneralSettings) {
|
||||
this.orgGeneralSettings = orgGeneralSettings;
|
||||
public Builder orgGeneralSettings(OrgGeneralSettings generalSettings) {
|
||||
this.generalSettings = generalSettings;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -119,32 +119,32 @@ public class OrgSettings extends ResourceType<OrgSettings> {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see OrgSettings#getOrgLdapSettings()
|
||||
* @see OrgSettings#getLdapSettings()
|
||||
*/
|
||||
public Builder orgLdapSettings(OrgLdapSettings orgLdapSettings) {
|
||||
this.orgLdapSettings = orgLdapSettings;
|
||||
public Builder orgLdapSettings(OrgLdapSettings ldapSettings) {
|
||||
this.ldapSettings = ldapSettings;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see OrgSettings#getOrgEmailSettings()
|
||||
* @see OrgSettings#getEmailSettings()
|
||||
*/
|
||||
public Builder orgEmailSettings(OrgEmailSettings orgEmailSettings) {
|
||||
this.orgEmailSettings = orgEmailSettings;
|
||||
public Builder orgEmailSettings(OrgEmailSettings emailSettings) {
|
||||
this.emailSettings = emailSettings;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see OrgSettings#getOrgPasswordPolicySettings()
|
||||
* @see OrgSettings#getPasswordPolicy()
|
||||
*/
|
||||
public Builder orgPasswordPolicySettings(OrgPasswordPolicySettings orgPasswordPolicySettings) {
|
||||
this.orgPasswordPolicySettings = orgPasswordPolicySettings;
|
||||
public Builder passwordPolicy(OrgPasswordPolicySettings passwordPolicy) {
|
||||
this.passwordPolicy = passwordPolicy;
|
||||
return this;
|
||||
}
|
||||
|
||||
public OrgSettings build() {
|
||||
return new OrgSettings(href, type, links, orgGeneralSettings, vAppLeaseSettings,
|
||||
vAppTemplateLeaseSettings, orgLdapSettings, orgEmailSettings, orgPasswordPolicySettings);
|
||||
return new OrgSettings(href, type, links, generalSettings, vAppLeaseSettings,
|
||||
vAppTemplateLeaseSettings, ldapSettings, emailSettings, passwordPolicy);
|
||||
}
|
||||
|
||||
|
||||
|
@ -191,12 +191,12 @@ public class OrgSettings extends ResourceType<OrgSettings> {
|
|||
}
|
||||
public Builder fromOrgSettings(OrgSettings in) {
|
||||
return fromResourceType(in)
|
||||
.orgGeneralSettings(in.getOrgGeneralSettings())
|
||||
.orgGeneralSettings(in.getGeneralSettings())
|
||||
.vAppLeaseSettings(in.getVAppLeaseSettings())
|
||||
.vAppTemplateLeaseSettings(in.getVAppTemplateLeaseSettings())
|
||||
.orgLdapSettings(in.getOrgLdapSettings())
|
||||
.orgEmailSettings(in.getOrgEmailSettings())
|
||||
.orgPasswordPolicySettings(in.getOrgPasswordPolicySettings());
|
||||
.orgLdapSettings(in.getLdapSettings())
|
||||
.orgEmailSettings(in.getEmailSettings())
|
||||
.passwordPolicy(in.getPasswordPolicy());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -205,32 +205,33 @@ public class OrgSettings extends ResourceType<OrgSettings> {
|
|||
// For JAXB
|
||||
}
|
||||
|
||||
public OrgSettings(URI href, String type, Set<Link> links,
|
||||
OrgGeneralSettings orgGeneralSettings,
|
||||
public OrgSettings(URI href, String type, Set<Link> links,
|
||||
OrgGeneralSettings generalSettings,
|
||||
OrgLeaseSettings vAppLeaseSettings,
|
||||
OrgVAppTemplateLeaseSettings vAppTemplateLeaseSettings,
|
||||
OrgLdapSettings orgLdapSettings, OrgEmailSettings orgEmailSettings,
|
||||
OrgPasswordPolicySettings orgPasswordPolicySettings) {
|
||||
OrgLdapSettings ldapSettings, OrgEmailSettings emailSettings,
|
||||
OrgPasswordPolicySettings passwordPolicy) {
|
||||
super(href, type, links);
|
||||
this.orgGeneralSettings = orgGeneralSettings;
|
||||
this.generalSettings = generalSettings;
|
||||
this.vAppLeaseSettings = vAppLeaseSettings;
|
||||
this.vAppTemplateLeaseSettings = vAppTemplateLeaseSettings;
|
||||
this.orgLdapSettings = orgLdapSettings;
|
||||
this.orgPasswordPolicySettings = orgPasswordPolicySettings;
|
||||
this.ldapSettings = ldapSettings;
|
||||
this.emailSettings = emailSettings;
|
||||
this.passwordPolicy = passwordPolicy;
|
||||
}
|
||||
|
||||
@XmlElement(name = "OrgGeneralSettings")
|
||||
protected OrgGeneralSettings orgGeneralSettings;
|
||||
protected OrgGeneralSettings generalSettings;
|
||||
@XmlElement(name = "VAppLeaseSettings")
|
||||
protected OrgLeaseSettings vAppLeaseSettings;
|
||||
@XmlElement(name = "VAppTemplateLeaseSettings")
|
||||
protected OrgVAppTemplateLeaseSettings vAppTemplateLeaseSettings;
|
||||
@XmlElement(name = "OrgLdapSettings")
|
||||
protected OrgLdapSettings orgLdapSettings;
|
||||
protected OrgLdapSettings ldapSettings;
|
||||
@XmlElement(name = "OrgEmailSettings")
|
||||
protected OrgEmailSettings orgEmailSettings;
|
||||
protected OrgEmailSettings emailSettings;
|
||||
@XmlElement(name = "OrgPasswordPolicySettings")
|
||||
protected OrgPasswordPolicySettings orgPasswordPolicySettings;
|
||||
protected OrgPasswordPolicySettings passwordPolicy;
|
||||
|
||||
/**
|
||||
* Gets the value of the orgGeneralSettings property.
|
||||
|
@ -240,8 +241,8 @@ public class OrgSettings extends ResourceType<OrgSettings> {
|
|||
* {@link OrgGeneralSettings }
|
||||
*
|
||||
*/
|
||||
public OrgGeneralSettings getOrgGeneralSettings() {
|
||||
return orgGeneralSettings;
|
||||
public OrgGeneralSettings getGeneralSettings() {
|
||||
return generalSettings;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -276,8 +277,8 @@ public class OrgSettings extends ResourceType<OrgSettings> {
|
|||
* {@link OrgLdapSettings }
|
||||
*
|
||||
*/
|
||||
public OrgLdapSettings getOrgLdapSettings() {
|
||||
return orgLdapSettings;
|
||||
public OrgLdapSettings getLdapSettings() {
|
||||
return ldapSettings;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -288,8 +289,8 @@ public class OrgSettings extends ResourceType<OrgSettings> {
|
|||
* {@link OrgEmailSettings }
|
||||
*
|
||||
*/
|
||||
public OrgEmailSettings getOrgEmailSettings() {
|
||||
return orgEmailSettings;
|
||||
public OrgEmailSettings getEmailSettings() {
|
||||
return emailSettings;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -300,8 +301,8 @@ public class OrgSettings extends ResourceType<OrgSettings> {
|
|||
* {@link OrgPasswordPolicySettings }
|
||||
*
|
||||
*/
|
||||
public OrgPasswordPolicySettings getOrgPasswordPolicySettings() {
|
||||
return orgPasswordPolicySettings;
|
||||
public OrgPasswordPolicySettings getPasswordPolicy() {
|
||||
return passwordPolicy;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -312,34 +313,34 @@ public class OrgSettings extends ResourceType<OrgSettings> {
|
|||
return false;
|
||||
OrgSettings that = OrgSettings.class.cast(o);
|
||||
return super.equals(that) &&
|
||||
equal(orgGeneralSettings, that.orgGeneralSettings) &&
|
||||
equal(generalSettings, that.generalSettings) &&
|
||||
equal(vAppLeaseSettings, that.vAppLeaseSettings) &&
|
||||
equal(vAppTemplateLeaseSettings, that.vAppTemplateLeaseSettings) &&
|
||||
equal(orgLdapSettings, that.orgLdapSettings) &&
|
||||
equal(orgEmailSettings, that.orgEmailSettings) &&
|
||||
equal(orgPasswordPolicySettings, that.orgPasswordPolicySettings);
|
||||
equal(ldapSettings, that.ldapSettings) &&
|
||||
equal(emailSettings, that.emailSettings) &&
|
||||
equal(passwordPolicy, that.passwordPolicy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(super.hashCode(),
|
||||
orgGeneralSettings,
|
||||
generalSettings,
|
||||
vAppLeaseSettings,
|
||||
vAppTemplateLeaseSettings,
|
||||
orgLdapSettings,
|
||||
orgEmailSettings,
|
||||
orgPasswordPolicySettings);
|
||||
ldapSettings,
|
||||
emailSettings,
|
||||
passwordPolicy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ToStringHelper string() {
|
||||
return super.string()
|
||||
.add("orgGeneralSettings", orgGeneralSettings)
|
||||
.add("generalSettings", generalSettings)
|
||||
.add("vAppLeaseSettings", vAppLeaseSettings)
|
||||
.add("vAppTemplateLeaseSettings", vAppTemplateLeaseSettings)
|
||||
.add("orgLdapSettings", orgLdapSettings)
|
||||
.add("orgEmailSettings", orgEmailSettings)
|
||||
.add("orgPasswordPolicySettings", orgPasswordPolicySettings);
|
||||
.add("ldapSettings", ldapSettings)
|
||||
.add("emailSettings", emailSettings)
|
||||
.add("passwordPolicy", passwordPolicy);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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.OrgLeaseSettings;
|
||||
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.filters.AddVCloudAuthorizationToRequest;
|
||||
import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx;
|
||||
|
@ -57,9 +58,29 @@ public interface AdminOrgAsyncClient extends OrgAsyncClient {
|
|||
|
||||
// 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)
|
||||
|
|
|
@ -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.OrgLeaseSettings;
|
||||
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;
|
||||
|
||||
/**
|
||||
|
@ -45,9 +46,29 @@ public interface AdminOrgClient extends OrgClient {
|
|||
|
||||
// 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.
|
||||
|
|
|
@ -528,10 +528,10 @@ public class Checks {
|
|||
}
|
||||
}
|
||||
|
||||
public static void checkOrgSetting(OrgSettings settings) {
|
||||
public static void checkOrgSettings(OrgSettings settings) {
|
||||
// Check optional fields
|
||||
if (settings.getOrgGeneralSettings() != null) {
|
||||
checkGeneralSettings(settings.getOrgGeneralSettings());
|
||||
if (settings.getGeneralSettings() != null) {
|
||||
checkGeneralSettings(settings.getGeneralSettings());
|
||||
}
|
||||
if (settings.getVAppLeaseSettings() != null) {
|
||||
checkVAppLeaseSettings(settings.getVAppLeaseSettings());
|
||||
|
@ -539,14 +539,14 @@ public class Checks {
|
|||
if (settings.getVAppTemplateLeaseSettings() != null) {
|
||||
checkVAppTemplateLeaseSettings(settings.getVAppTemplateLeaseSettings());
|
||||
}
|
||||
if (settings.getOrgLdapSettings() != null) {
|
||||
checkLdapSettings(settings.getOrgLdapSettings());
|
||||
if (settings.getLdapSettings() != null) {
|
||||
checkLdapSettings(settings.getLdapSettings());
|
||||
}
|
||||
if (settings.getOrgEmailSettings() != null) {
|
||||
checkEmailSettings(settings.getOrgEmailSettings());
|
||||
if (settings.getEmailSettings() != null) {
|
||||
checkEmailSettings(settings.getEmailSettings());
|
||||
}
|
||||
if (settings.getOrgPasswordPolicySettings() != null) {
|
||||
checkPasswordPolicySettings(settings.getOrgPasswordPolicySettings());
|
||||
if (settings.getPasswordPolicy() != null) {
|
||||
checkPasswordPolicySettings(settings.getPasswordPolicy());
|
||||
}
|
||||
|
||||
// parent type
|
||||
|
@ -561,7 +561,6 @@ public class Checks {
|
|||
checkEmailAddress(settings.getFromEmailAddress());
|
||||
assertNotNull(settings.getDefaultSubjectPrefix(), String.format(OBJ_FIELD_REQ, "OrgEmailSettings", "defaultSubjectPrefix"));
|
||||
assertNotNull(settings.isAlertEmailToAllAdmins(), String.format(OBJ_FIELD_REQ, "OrgEmailSettings", "isAlertEmailToAllAdmins"));
|
||||
assertNotNull(settings.getAlertEmailsTo(), String.format(OBJ_FIELD_REQ, "OrgEmailSettings", "alertEmailsTo"));
|
||||
|
||||
// optional
|
||||
// NOTE alertEmailsTo cannot be checked
|
||||
|
|
|
@ -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.OrgLeaseSettings;
|
||||
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.Reference;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.SmtpServerSettings;
|
||||
|
@ -54,9 +55,60 @@ public class AdminOrgClientExpectTest extends BaseVCloudDirectorRestClientExpect
|
|||
|
||||
// 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
|
||||
public void testGetEmailSettings() {
|
||||
|
@ -239,10 +291,10 @@ public class AdminOrgClientExpectTest extends BaseVCloudDirectorRestClientExpect
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateOrgPasswordPolicy() {
|
||||
public void testUpdatePasswordPolicy() {
|
||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||
new VcloudHttpRequestPrimer()
|
||||
.apiCommand("PUT", "/admin/org/???/settings/passwordPolicy")
|
||||
.apiCommand("PUT", "/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/passwordPolicy")
|
||||
.xmlFilePayload("/org/admin/updatePasswordPolicySource.xml",
|
||||
VCloudDirectorMediaType.ORG_PASSWORD_POLICY_SETTINGS)
|
||||
.acceptMedia(VCloudDirectorMediaType.ORG_PASSWORD_POLICY_SETTINGS)
|
||||
|
@ -269,7 +321,7 @@ public class AdminOrgClientExpectTest extends BaseVCloudDirectorRestClientExpect
|
|||
public void testGetVAppLeaseSettings() {
|
||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||
new VcloudHttpRequestPrimer()
|
||||
.apiCommand("GET", "/admin/org/???/settings/vAppLeaseSettings")
|
||||
.apiCommand("GET", "/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/vAppLeaseSettings")
|
||||
.acceptAnyMedia()
|
||||
.httpRequestBuilder().build(),
|
||||
new VcloudHttpResponsePrimer()
|
||||
|
@ -292,7 +344,7 @@ public class AdminOrgClientExpectTest extends BaseVCloudDirectorRestClientExpect
|
|||
public void testUpdateOrgVAppLeaseSettings() {
|
||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||
new VcloudHttpRequestPrimer()
|
||||
.apiCommand("PUT", "/admin/org/???/settings/vAppLeaseSettings")
|
||||
.apiCommand("PUT", "/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/vAppLeaseSettings")
|
||||
.xmlFilePayload("/org/admin/updateVAppLeaseSettingsSource.xml",
|
||||
VCloudDirectorMediaType.ORG_LEASE_SETTINGS)
|
||||
.acceptMedia(VCloudDirectorMediaType.ORG_LEASE_SETTINGS)
|
||||
|
@ -317,7 +369,7 @@ public class AdminOrgClientExpectTest extends BaseVCloudDirectorRestClientExpect
|
|||
public void testGetVAppTemplateLeaseSettings() {
|
||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||
new VcloudHttpRequestPrimer()
|
||||
.apiCommand("GET", "/admin/org/???/settings/vAppTemplateLeaseSettings")
|
||||
.apiCommand("GET", "/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/vAppTemplateLeaseSettings")
|
||||
.acceptAnyMedia()
|
||||
.httpRequestBuilder().build(),
|
||||
new VcloudHttpResponsePrimer()
|
||||
|
@ -340,7 +392,7 @@ public class AdminOrgClientExpectTest extends BaseVCloudDirectorRestClientExpect
|
|||
public void testUpdateOrgVAppTemplateLeaseSettings() {
|
||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||
new VcloudHttpRequestPrimer()
|
||||
.apiCommand("PUT", "/admin/org/???/settings/vAppTemplateLeaseSettings")
|
||||
.apiCommand("PUT", "/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/vAppTemplateLeaseSettings")
|
||||
.xmlFilePayload("/org/admin/updateVAppLeaseSettingsSource.xml",
|
||||
VCloudDirectorMediaType.ORG_VAPP_TEMPLATE_LEASE_SETTINGS)
|
||||
.acceptMedia(VCloudDirectorMediaType.ORG_VAPP_TEMPLATE_LEASE_SETTINGS)
|
||||
|
|
|
@ -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.OrgLeaseSettings;
|
||||
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.ReferenceType;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.SmtpServerSettings;
|
||||
|
@ -59,11 +60,13 @@ public class AdminOrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
*/
|
||||
private ReferenceType<?> orgRef;
|
||||
private AdminOrg org;
|
||||
OrgEmailSettings emailSettings;
|
||||
OrgGeneralSettings generalSettings;
|
||||
OrgPasswordPolicySettings passwordPolicy;
|
||||
OrgLeaseSettings vAppLeaseSettings;
|
||||
OrgVAppTemplateLeaseSettings vAppTemplateLeaseSettings;
|
||||
private OrgSettings settings, newSettings;
|
||||
private OrgEmailSettings emailSettings, newEmailSettings;
|
||||
private OrgGeneralSettings generalSettings, newGeneralSettings;
|
||||
private OrgLdapSettings ldapSettings, newLdapSettings;
|
||||
private OrgPasswordPolicySettings passwordPolicy, newPasswordPolicy;
|
||||
private OrgLeaseSettings vAppLeaseSettings, newVAppLeaseSettings;
|
||||
private OrgVAppTemplateLeaseSettings vAppTemplateLeaseSettings, newVAppTemplateLeaseSettings;
|
||||
|
||||
@Override
|
||||
@BeforeClass(inheritGroups = true)
|
||||
|
@ -79,9 +82,7 @@ public class AdminOrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
|
||||
// POST /admin/org/{id}/groups
|
||||
|
||||
// GET /admin/org/{id}/settings
|
||||
|
||||
// PUT /admin/org/{id}/settings
|
||||
|
||||
@Test(testName = "GET /admin/org/{id}/settings/emailSettings")
|
||||
public void testGetEmailSettings() {
|
||||
|
@ -109,7 +110,7 @@ public class AdminOrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
.build();
|
||||
|
||||
try {
|
||||
emailSettings = emailSettings.toBuilder()
|
||||
newEmailSettings = emailSettings.toBuilder()
|
||||
.isDefaultSmtpServer(!isDefaultSmtpServer)
|
||||
.isDefaultOrgEmail(!isDefaultOrgEmail)
|
||||
.fromEmailAddress(newFromEmailAddress)
|
||||
|
@ -119,7 +120,7 @@ public class AdminOrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
.build();
|
||||
|
||||
emailSettings = orgClient.updateEmailSettings(
|
||||
orgRef.getURI(), emailSettings);
|
||||
orgRef.getURI(), newEmailSettings);
|
||||
|
||||
assertTrue(equal(emailSettings.isDefaultSmtpServer(), !isDefaultSmtpServer),
|
||||
String.format(OBJ_FIELD_UPDATABLE,
|
||||
|
@ -175,7 +176,7 @@ public class AdminOrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
Integer delayAfterPowerOnSeconds = generalSettings.getDelayAfterPowerOnSeconds();
|
||||
|
||||
try {
|
||||
generalSettings = generalSettings.toBuilder()
|
||||
newGeneralSettings = generalSettings.toBuilder()
|
||||
// .canPublishCatalogs(!canPublishCatalogs)
|
||||
.deployedVMQuota(deployedVMQuota+1)
|
||||
.storedVmQuota(storedVmQuota+1)
|
||||
|
@ -184,7 +185,7 @@ public class AdminOrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
.build();
|
||||
|
||||
generalSettings = orgClient.updateGeneralSettings(
|
||||
orgRef.getURI(), generalSettings);
|
||||
orgRef.getURI(), newGeneralSettings);
|
||||
|
||||
// assertTrue(equal(generalSettings.canPublishCatalogs(), !canPublishCatalogs),
|
||||
// String.format(OBJ_FIELD_UPDATABLE,
|
||||
|
@ -220,8 +221,8 @@ public class AdminOrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
}
|
||||
|
||||
@Test(testName = "GET /admin/org/{id}/settings/ldap")
|
||||
public void getLdapSettings() {
|
||||
OrgLdapSettings ldapSettings = orgClient.getLdapSettings(orgRef.getURI());
|
||||
public void testGetLdapSettings() {
|
||||
ldapSettings = orgClient.getLdapSettings(orgRef.getURI());
|
||||
|
||||
Checks.checkLdapSettings(ldapSettings);
|
||||
}
|
||||
|
@ -241,14 +242,14 @@ public class AdminOrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
Integer accountLockoutIntervalMinutes = passwordPolicy.getAccountLockoutIntervalMinutes();
|
||||
|
||||
try {
|
||||
passwordPolicy = passwordPolicy.toBuilder()
|
||||
newPasswordPolicy = passwordPolicy.toBuilder()
|
||||
.accountLockoutEnabled(!accountLockoutEnabled)
|
||||
.invalidLoginsBeforeLockout(invalidLoginsBeforeLockout+1)
|
||||
.accountLockoutIntervalMinutes(accountLockoutIntervalMinutes+1)
|
||||
.build();
|
||||
|
||||
passwordPolicy = orgClient.updatePasswordPolicy(
|
||||
orgRef.getURI(), passwordPolicy);
|
||||
orgRef.getURI(), newPasswordPolicy);
|
||||
|
||||
assertTrue(equal(passwordPolicy.isAccountLockoutEnabled(), !accountLockoutEnabled),
|
||||
String.format(OBJ_FIELD_UPDATABLE,
|
||||
|
@ -290,14 +291,14 @@ public class AdminOrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
Integer deploymentLeaseSeconds = vAppLeaseSettings.getDeploymentLeaseSeconds();
|
||||
|
||||
try {
|
||||
vAppLeaseSettings = vAppLeaseSettings.toBuilder()
|
||||
newVAppLeaseSettings = vAppLeaseSettings.toBuilder()
|
||||
.deleteOnStorageLeaseExpiration(!deleteOnStorageLeaseExpiration)
|
||||
.storageLeaseSeconds(storageLeaseSeconds+1)
|
||||
.deploymentLeaseSeconds(deploymentLeaseSeconds+1)
|
||||
.build();
|
||||
|
||||
vAppLeaseSettings = orgClient.updateVAppLeaseSettings(
|
||||
orgRef.getURI(), vAppLeaseSettings);
|
||||
orgRef.getURI(), newVAppLeaseSettings);
|
||||
|
||||
assertTrue(equal(vAppLeaseSettings.deleteOnStorageLeaseExpiration(), !deleteOnStorageLeaseExpiration),
|
||||
String.format(OBJ_FIELD_UPDATABLE,
|
||||
|
@ -338,13 +339,13 @@ public class AdminOrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
Integer storageLeaseSeconds = vAppTemplateLeaseSettings.getStorageLeaseSeconds();
|
||||
|
||||
try {
|
||||
vAppTemplateLeaseSettings = vAppTemplateLeaseSettings.toBuilder()
|
||||
newVAppTemplateLeaseSettings = vAppTemplateLeaseSettings.toBuilder()
|
||||
.deleteOnStorageLeaseExpiration(!deleteOnStorageLeaseExpiration)
|
||||
.storageLeaseSeconds(storageLeaseSeconds+1)
|
||||
.build();
|
||||
|
||||
vAppTemplateLeaseSettings = orgClient.updateVAppTemplateLeaseSettings(
|
||||
orgRef.getURI(), vAppTemplateLeaseSettings);
|
||||
orgRef.getURI(), newVAppTemplateLeaseSettings);
|
||||
|
||||
assertTrue(equal(vAppTemplateLeaseSettings.deleteOnStorageLeaseExpiration(), !deleteOnStorageLeaseExpiration),
|
||||
String.format(OBJ_FIELD_UPDATABLE,
|
||||
|
@ -366,4 +367,75 @@ public class AdminOrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue