You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ad...@apache.org on 2014/11/17 17:21:13 UTC
[06/32] jclouds-labs git commit: JCLOUDS-780 Remove vcloud-director.
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/775b89fd/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkApiLiveTest.java
----------------------------------------------------------------------
diff --git a/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkApiLiveTest.java b/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkApiLiveTest.java
deleted file mode 100644
index fa81ec6..0000000
--- a/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkApiLiveTest.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.vcloud.director.v1_5.features.admin;
-
-import static com.google.common.base.Objects.equal;
-import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_UPDATABLE;
-import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.REQUIRED_VALUE_OBJECT_FMT;
-import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.TASK_COMPLETE_TIMELY;
-import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.URN_REQ_LIVE;
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
-
-import org.jclouds.vcloud.director.v1_5.domain.Checks;
-import org.jclouds.vcloud.director.v1_5.domain.Task;
-import org.jclouds.vcloud.director.v1_5.domain.network.ExternalNetwork;
-import org.jclouds.vcloud.director.v1_5.domain.network.IpScope;
-import org.jclouds.vcloud.director.v1_5.domain.network.Network;
-import org.jclouds.vcloud.director.v1_5.domain.network.NetworkConfiguration;
-import org.jclouds.vcloud.director.v1_5.domain.network.NetworkFeatures;
-import org.jclouds.vcloud.director.v1_5.domain.network.RouterInfo;
-import org.jclouds.vcloud.director.v1_5.domain.network.SyslogServerSettings;
-import org.jclouds.vcloud.director.v1_5.domain.org.OrgNetwork;
-import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorApiLiveTest;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableSet;
-
-@Test(groups = { "live", "admin" }, singleThreaded = true, testName = "AdminNetworkLiveTest")
-public class AdminNetworkApiLiveTest extends BaseVCloudDirectorApiLiveTest {
-
- public static final String NETWORK = "AdminNetwork";
-
- /*
- * Convenience references to API apis.
- */
- private AdminNetworkApi networkApi;
-
- private Network network;
-
- @Override
- @BeforeClass(alwaysRun = true)
- protected void setupRequiredApis() {
- networkApi = adminContext.getApi().getNetworkApi();
- }
-
- @Test(description = "GET /admin/network/{id}")
- public void testGetNetwork() {
- //TODO: test both org and external networks
- network = lazyGetNetwork();
-
-
- if (network instanceof ExternalNetwork) {
- Checks.checkExternalNetwork(Network.<ExternalNetwork>toSubType(network));
- } else if (network instanceof OrgNetwork) {
- Checks.checkOrgNetwork(Network.<OrgNetwork>toSubType(network));
- } else {
- fail(String.format(REQUIRED_VALUE_OBJECT_FMT, ".class", NETWORK,
- network.getClass(), "ExternalNetwork,. OrgNetwork"));
- }
- }
-
- // TODO: this test is far from exhaustive
- @Test(description = "PUT /admin/network/{id}" )
- public void testEditNetwork() {
- //TODO: ensure network instanceof OrgNetwork, may require queries
- assertTrue(network instanceof OrgNetwork, String.format(URN_REQ_LIVE, "OrgNetwork"));
-
- OrgNetwork oldNetwork = Network.<OrgNetwork>toSubType(network)
- .toBuilder()
- .tasks(ImmutableSet.<Task>of())
- .build();
-
- OrgNetwork editNetwork = getMutatedOrgNetwork(oldNetwork);
-
- try {
- Task editNetworkTask = networkApi.edit(network.getHref(), editNetwork);
- Checks.checkTask(editNetworkTask);
- assertTrue(retryTaskSuccess.apply(editNetworkTask), String.format(TASK_COMPLETE_TIMELY, "editNetworkTask"));
- network = networkApi.get(network.getHref());
-
- Checks.checkOrgNetwork(Network.<OrgNetwork>toSubType(network));
-
- assertTrue(equal(network.getConfiguration().getIpScope(),
- editNetwork.getConfiguration().getIpScope()),
- String.format(OBJ_FIELD_UPDATABLE, NETWORK + ".configuration", "ipScope"));
- assertTrue(equal(network.getConfiguration().getParentNetwork(),
- editNetwork.getConfiguration().getParentNetwork()),
- String.format(OBJ_FIELD_UPDATABLE, NETWORK + ".configuration", "parentNetwork"));
- assertTrue(equal(network.getConfiguration().getFenceMode(),
- editNetwork.getConfiguration().getFenceMode()),
- String.format(OBJ_FIELD_UPDATABLE, NETWORK + ".configuration", "fenceMode"));
- assertTrue(equal(network.getConfiguration().retainNetInfoAcrossDeployments(),
- editNetwork.getConfiguration().retainNetInfoAcrossDeployments()),
- String.format(OBJ_FIELD_UPDATABLE, NETWORK + ".configuration", "retainNetInfoAcrossDeployments"));
- assertTrue(equal(network.getConfiguration().getNetworkFeatures(),
- editNetwork.getConfiguration().getNetworkFeatures()),
- String.format(OBJ_FIELD_UPDATABLE, NETWORK + ".configuration", "networkFeatures"));
- assertTrue(equal(network.getConfiguration().getSyslogServerSettings(),
- editNetwork.getConfiguration().getSyslogServerSettings()),
- String.format(OBJ_FIELD_UPDATABLE, NETWORK + ".configuration", "syslogServerSettings"));
- assertTrue(equal(network.getConfiguration().getRouterInfo(),
- editNetwork.getConfiguration().getRouterInfo()),
- String.format(OBJ_FIELD_UPDATABLE, NETWORK + ".configuration", "routerInfo"));
- // FIXME: fails
-// assertTrue(equal(Network.<OrgNetwork>toSubType(network).getNetworkPool(),
-// editNetwork.getNetworkPool()),
-// String.format(OBJ_FIELD_UPDATABLE, NETWORK, "networkPool"));
-
-// assertTrue(equal(Network.<OrgNetwork>toSubType(network).getAllowedExternalIpAddresses(),
-// editNetwork.getAllowedExternalIpAddresses()),
-// String.format(OBJ_FIELD_UPDATABLE, NETWORK, "allowedExternalIpAddresses"));
- } finally {
- Task editNetworkTask = networkApi.edit(network.getHref(), oldNetwork);
- Checks.checkTask(editNetworkTask);
- assertTrue(retryTaskSuccess.apply(editNetworkTask), String.format(TASK_COMPLETE_TIMELY, "editNetworkTask"));
- network = networkApi.get(network.getHref());
- }
- }
-
- @Test(description = "POST /admin/network/{id}/action/reset")
- public void testResetNetwork() {
- // TODO assert that network is deployed somehow
- Task resetNetworkTask = networkApi.reset(network.getHref());
- Checks.checkTask(resetNetworkTask);
- assertTrue(retryTaskSuccess.apply(resetNetworkTask), String.format(TASK_COMPLETE_TIMELY, "resetNetworkTask"));
- network = networkApi.get(network.getHref());
-
- Checks.checkOrgNetwork(Network.<OrgNetwork>toSubType(network));
- // TODO: other assertions about the reset? that network is deployed when task is complete, for example
- }
-
- private static OrgNetwork getMutatedOrgNetwork(OrgNetwork network) {
- OrgNetwork.Builder<?> networkBuilder = OrgNetwork.builder().fromNetwork(network)
- .tasks(ImmutableSet.<Task>of())
-// .name("new " + network.getName())
- .description("new " + network.getDescription())
- .configuration(getMutatedNetworkConfiguration(network.getConfiguration()));
-
- // FIXME: fails
-// if (network.getNetworkPool() != null) {
-// networkBuilder.networkPool(null);
-// } // TODO: else?
-
-// if (network.getAllowedExternalIpAddresses() != null) {
-// networkBuilder.allowedExternalIpAddresses(null);
-// } // TODO: else?
-
- return networkBuilder.build();
- }
-
- private static NetworkConfiguration getMutatedNetworkConfiguration(NetworkConfiguration config) {
- NetworkConfiguration.Builder configBuilder = config.toBuilder();
-
- if (config.getIpScope() != null) {
- configBuilder.ipScope(IpScope.builder().fromIpScope(config.getIpScope())
- // TODO: mutate to test more
- .build());
- }
-
- if (config.getParentNetwork() != null) {
-// configBuilder.parentNetwork(null);
- } // TODO: else?
-
-// configBuilder.fenceMode(config.getFenceMode() == Network.FenceMode.BRIDGED ?
-// Network.FenceMode.BRIDGED : Network.FenceMode.ISOLATED);
-
- if (config.getSyslogServerSettings() != null) {
- configBuilder.syslogServerSettings(SyslogServerSettings.builder()
- .fromSyslogServerSettings(config.getSyslogServerSettings())
- // TODO: mutate to test more
- .build());
- }
-
- if (config.retainNetInfoAcrossDeployments() != null) {
-// configBuilder.retainNetInfoAcrossDeployments(!config.retainNetInfoAcrossDeployments());
- } else {
-// configBuilder.retainNetInfoAcrossDeployments(false);
- }
-
- if (config.getNetworkFeatures() != null) {
- configBuilder.features(NetworkFeatures.builder().fromNetworkFeatures(config.getNetworkFeatures())
- // TODO: mutate to test more
- .build());
- }
-
- if (config.getRouterInfo() != null) {
- configBuilder.routerInfo(RouterInfo.builder().fromRouterInfo(config.getRouterInfo())
- // TODO: mutate to test more
- .build());
- }
-
- return configBuilder.build();
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/775b89fd/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgApiExpectTest.java
----------------------------------------------------------------------
diff --git a/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgApiExpectTest.java b/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgApiExpectTest.java
deleted file mode 100644
index e7df633..0000000
--- a/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgApiExpectTest.java
+++ /dev/null
@@ -1,610 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.vcloud.director.v1_5.features.admin;
-
-import static org.testng.Assert.assertEquals;
-
-import java.net.URI;
-
-import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
-import org.jclouds.vcloud.director.v1_5.admin.VCloudDirectorAdminApi;
-import org.jclouds.vcloud.director.v1_5.domain.Link;
-import org.jclouds.vcloud.director.v1_5.domain.Reference;
-import org.jclouds.vcloud.director.v1_5.domain.network.SmtpServerSettings;
-import org.jclouds.vcloud.director.v1_5.domain.org.AdminOrg;
-import org.jclouds.vcloud.director.v1_5.domain.org.OrgEmailSettings;
-import org.jclouds.vcloud.director.v1_5.domain.org.OrgGeneralSettings;
-import org.jclouds.vcloud.director.v1_5.domain.org.OrgLdapSettings;
-import org.jclouds.vcloud.director.v1_5.domain.org.OrgLeaseSettings;
-import org.jclouds.vcloud.director.v1_5.domain.org.OrgPasswordPolicySettings;
-import org.jclouds.vcloud.director.v1_5.domain.org.OrgSettings;
-import org.jclouds.vcloud.director.v1_5.domain.org.OrgVAppTemplateLeaseSettings;
-import org.jclouds.vcloud.director.v1_5.internal.VCloudDirectorAdminApiExpectTest;
-import org.testng.annotations.Test;
-
-@Test(groups = { "unit", "user" }, singleThreaded = true, testName = "AdminOrgApiExpectTest")
-public class AdminOrgApiExpectTest extends VCloudDirectorAdminApiExpectTest {
-
- private Reference orgRef = Reference.builder()
- .href(URI.create(endpoint + "/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0")).build();
-
- @Test
- public void testGetOrg() {
- VCloudDirectorAdminApi api = requestsSendResponses(loginRequest, sessionResponse, new VcloudHttpRequestPrimer()
- .apiCommand("GET", "/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0").acceptAnyMedia()
- .httpRequestBuilder().build(),
- new VcloudHttpResponsePrimer().xmlFilePayload("/org/admin/org.xml", VCloudDirectorMediaType.ADMIN_ORG)
- .httpResponseBuilder().build());
-
- AdminOrg expected = adminOrg();
-
- assertEquals(api.getOrgApi().get(orgRef.getHref()), expected);
- }
-
- public static final AdminOrg adminOrg() {
- return AdminOrg
- .builder()
- .name("JClouds")
- .id("urn:vcloud:org:6f312e42-cd2b-488d-a2bb-97519cd57ed0")
- .type("application/vnd.vmware.admin.organization+xml")
- .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
- .link(Link
- .builder()
- .rel("down")
- .type("application/vnd.vmware.vcloud.tasksList+xml")
- .href(URI.create("https://vcloudbeta.bluelock.com/api/tasksList/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
- .build())
- .link(Link
- .builder()
- .rel("down")
- .type("application/vnd.vmware.vcloud.metadata+xml")
- .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/metadata"))
- .build())
- .link(Link
- .builder()
- .rel("add")
- .type("application/vnd.vmware.admin.catalog+xml")
- .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/catalogs"))
- .build())
- .link(Link
- .builder()
- .rel("add")
- .type("application/vnd.vmware.admin.user+xml")
- .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/users"))
- .build())
- .link(Link
- .builder()
- .rel("add")
- .type("application/vnd.vmware.admin.group+xml")
- .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/groups"))
- .build())
- .link(Link
- .builder()
- .rel("add")
- .type("application/vnd.vmware.admin.orgNetwork+xml")
- .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/networks"))
- .build())
- .link(Link
- .builder()
- .rel("edit")
- .type("application/vnd.vmware.admin.organization+xml")
- .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
- .build())
- .link(Link
- .builder()
- .rel("remove")
- .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
- .build())
- .link(Link
- .builder()
- .rel("alternate")
- .type("application/vnd.vmware.vcloud.org+xml")
- .href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
- .build())
- .description("")
- .fullName("JClouds")
- .isEnabled(true)
- .settings(settings())
- .user(Reference
- .builder()
- .type("application/vnd.vmware.admin.user+xml")
- .name("adam.lowe@cloudsoftcorp.com")
- .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/user/672ebb67-d8ff-4201-9c1b-c1be869e526c"))
- .build())
- .user(Reference
- .builder()
- .type("application/vnd.vmware.admin.user+xml")
- .name("adrian@jclouds.org")
- .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/user/8c360b93-ed25-4c9a-8e24-d48cd9966d93"))
- .build())
- .user(Reference
- .builder()
- .type("application/vnd.vmware.admin.user+xml")
- .name("qunying.huang@enstratus.com")
- .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/user/967d317c-4273-4a95-b8a4-bf63b78e9c69"))
- .build())
- .user(Reference
- .builder()
- .type("application/vnd.vmware.admin.user+xml")
- .name("dan@cloudsoftcorp.com")
- .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/user/ae75edd2-12de-414c-8e85-e6ea10442c08"))
- .build())
- .user(Reference
- .builder()
- .type("application/vnd.vmware.admin.user+xml")
- .name("adk@cloudsoftcorp.com")
- .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/user/e9eb1b29-0404-4c5e-8ef7-e584acc51da9"))
- .build())
- .catalog(Reference
- .builder()
- .type("application/vnd.vmware.admin.catalog+xml")
- .name("QunyingTestCatalog")
- .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4"))
- .build())
- .catalog(Reference
- .builder()
- .type("application/vnd.vmware.admin.catalog+xml")
- .name("Public")
- .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/catalog/9e08c2f6-077a-42ce-bece-d5332e2ebb5c"))
- .build())
- .catalog(Reference
- .builder()
- .type("application/vnd.vmware.admin.catalog+xml")
- .name("dantest")
- .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/catalog/b542aff4-9f97-4f51-a126-4330fbf62f02"))
- .build())
- .catalog(Reference
- .builder()
- .type("application/vnd.vmware.admin.catalog+xml")
- .name("test")
- .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/catalog/b7289d54-4ca4-497f-9a93-2d4afc97e3da"))
- .build())
- .vdc(Reference
- .builder()
- .type("application/vnd.vmware.vcloud.vdc+xml")
- .name("Cluster01-JClouds")
- .href(URI.create("https://vcloudbeta.bluelock.com/api/vdc/d16d333b-e3c0-4176-845d-a5ee6392df07"))
- .build())
- .network(Reference
- .builder()
- .type("application/vnd.vmware.admin.network+xml")
- .name("ilsolation01-Jclouds")
- .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/network/f3ba8256-6f48-4512-aad6-600e85b4dc38"))
- .build())
- .network(Reference
- .builder()
- .type("application/vnd.vmware.admin.network+xml")
- .name("internet01-Jclouds")
- .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/network/55a677cf-ab3f-48ae-b880-fab90421980c"))
- .build()).build();
- }
-
- @Test(enabled = false)
- public void testGetSettings() {
- VCloudDirectorAdminApi api = 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());
-
- OrgSettings expected = settings();
-
- assertEquals(api.getOrgApi().getSettings(orgRef.getHref()), expected);
- }
-
- @Test(enabled = false)
- public void testEditSettings() {
- VCloudDirectorAdminApi api = requestsSendResponses(
- loginRequest,
- sessionResponse,
- new VcloudHttpRequestPrimer()
- .apiCommand("PUT", "/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/")
- .xmlFilePayload("/org/admin/editSettingsSource.xml", VCloudDirectorMediaType.ORG_SETTINGS)
- .acceptMedia(VCloudDirectorMediaType.ORG_SETTINGS).httpRequestBuilder().build(),
- new VcloudHttpResponsePrimer()
- .xmlFilePayload("/org/admin/editSettings.xml", VCloudDirectorMediaType.ORG_SETTINGS)
- .httpResponseBuilder().build());
-
- OrgSettings expected = editSettings();
-
- assertEquals(api.getOrgApi().editSettings(orgRef.getHref(), expected), expected);
- }
-
- @Test
- public void testGetEmailSettings() {
- VCloudDirectorAdminApi api = requestsSendResponses(
- loginRequest,
- sessionResponse,
- new VcloudHttpRequestPrimer()
- .apiCommand("GET", "/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/email")
- .acceptAnyMedia().httpRequestBuilder().build(),
- new VcloudHttpResponsePrimer()
- .xmlFilePayload("/org/admin/emailSettings.xml", VCloudDirectorMediaType.ORG_GENERAL_SETTINGS)
- .httpResponseBuilder().build());
-
- OrgEmailSettings expected = emailSettings();
-
- assertEquals(api.getOrgApi().getEmailSettings(orgRef.getHref()), expected);
- }
-
- @Test
- public void testEditEmailSettings() {
- VCloudDirectorAdminApi api = requestsSendResponses(
- loginRequest,
- sessionResponse,
- new VcloudHttpRequestPrimer()
- .apiCommand("PUT", "/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/email")
- .xmlFilePayload("/org/admin/editEmailSettingsSource.xml",
- VCloudDirectorMediaType.ORG_EMAIL_SETTINGS)
- .acceptMedia(VCloudDirectorMediaType.ORG_EMAIL_SETTINGS).httpRequestBuilder().build(),
- new VcloudHttpResponsePrimer()
- .xmlFilePayload("/org/admin/editEmailSettings.xml",
- VCloudDirectorMediaType.ORG_EMAIL_SETTINGS).httpResponseBuilder().build());
-
- OrgEmailSettings expected = editEmailSettings();
-
- assertEquals(api.getOrgApi().editEmailSettings(orgRef.getHref(), expected), expected);
- }
-
- @Test(enabled = false)
- public void testGetGeneralSettings() {
- VCloudDirectorAdminApi api = requestsSendResponses(
- loginRequest,
- sessionResponse,
- new VcloudHttpRequestPrimer()
- .apiCommand("GET", "/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/general")
- .acceptAnyMedia().httpRequestBuilder().build(),
- new VcloudHttpResponsePrimer()
- .xmlFilePayload("/org/admin/generalSettings.xml", VCloudDirectorMediaType.ORG_GENERAL_SETTINGS)
- .httpResponseBuilder().build());
-
- OrgGeneralSettings expected = generalSettings();
-
- assertEquals(api.getOrgApi().getGeneralSettings(orgRef.getHref()), expected);
- }
-
- public static final OrgGeneralSettings generalSettings() {
- return OrgGeneralSettings
- .builder()
- .type("application/vnd.vmware.admin.organizationGeneralSettings+xml")
- .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/general"))
- .link(Link
- .builder()
- .rel("edit")
- .type("application/vnd.vmware.admin.organizationGeneralSettings+xml")
- .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/general"))
- .build()).canPublishCatalogs(false).deployedVMQuota(0).storedVmQuota(0)
- .useServerBootSequence(false).delayAfterPowerOnSeconds(0).build();
- }
-
- @Test(enabled = false)
- public void testEditGeneralSettings() {
- VCloudDirectorAdminApi api = requestsSendResponses(
- loginRequest,
- sessionResponse,
- new VcloudHttpRequestPrimer()
- .apiCommand("PUT", "/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/general")
- .xmlFilePayload("/org/admin/editGeneralSettingsSource.xml",
- VCloudDirectorMediaType.ORG_GENERAL_SETTINGS)
- .acceptMedia(VCloudDirectorMediaType.ORG_GENERAL_SETTINGS).httpRequestBuilder().build(),
- new VcloudHttpResponsePrimer()
- .xmlFilePayload("/org/admin/editGeneralSettings.xml",
- VCloudDirectorMediaType.ORG_GENERAL_SETTINGS).httpResponseBuilder().build());
-
- OrgGeneralSettings expected = editGeneralSettings();
-
- assertEquals(api.getOrgApi().editGeneralSettings(orgRef.getHref(), expected), expected);
- }
-
- public static final OrgGeneralSettings editGeneralSettings() {
- return generalSettings().toBuilder()
-
- .build();
- }
-
- @Test
- public void testGetLdapSettings() {
- VCloudDirectorAdminApi api = requestsSendResponses(
- loginRequest,
- sessionResponse,
- new VcloudHttpRequestPrimer()
- .apiCommand("GET", "/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/ldap")
- .acceptAnyMedia().httpRequestBuilder().build(),
- new VcloudHttpResponsePrimer()
- .xmlFilePayload("/org/admin/ldapSettings.xml", VCloudDirectorMediaType.ORG_LDAP_SETTINGS)
- .httpResponseBuilder().build());
-
- OrgLdapSettings expected = ldapSettings();
-
- assertEquals(api.getOrgApi().getLdapSettings(orgRef.getHref()), expected);
- }
-
- public static final OrgLdapSettings ldapSettings() {
- return OrgLdapSettings
- .builder()
- .type("application/vnd.vmware.admin.organizationLdapSettings+xml")
- .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/ldap"))
- .ldapMode("NONE").build();
- }
-
- @Test
- public void testGetPasswordPolicy() {
- VCloudDirectorAdminApi api = requestsSendResponses(
- loginRequest,
- sessionResponse,
- new VcloudHttpRequestPrimer()
- .apiCommand("GET", "/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/passwordPolicy")
- .acceptAnyMedia().httpRequestBuilder().build(),
- new VcloudHttpResponsePrimer()
- .xmlFilePayload("/org/admin/passwordPolicy.xml",
- VCloudDirectorMediaType.ORG_PASSWORD_POLICY_SETTINGS).httpResponseBuilder().build());
-
- OrgPasswordPolicySettings expected = passwordPolicy();
-
- assertEquals(api.getOrgApi().getPasswordPolicy(orgRef.getHref()), expected);
- }
-
- public static final OrgPasswordPolicySettings passwordPolicy() {
- return OrgPasswordPolicySettings
- .builder()
- .type("application/vnd.vmware.admin.organizationPasswordPolicySettings+xml")
- .link(Link
- .builder()
- .rel("edit")
- .type("application/vnd.vmware.admin.organizationPasswordPolicySettings+xml")
- .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/passwordPolicy"))
- .build())
- .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/passwordPolicy"))
- .accountLockoutEnabled(false).invalidLoginsBeforeLockout(5).accountLockoutIntervalMinutes(10).build();
- }
-
- @Test
- public void testEditPasswordPolicy() {
- VCloudDirectorAdminApi api = requestsSendResponses(
- loginRequest,
- sessionResponse,
- new VcloudHttpRequestPrimer()
- .apiCommand("PUT", "/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/passwordPolicy")
- .xmlFilePayload("/org/admin/editPasswordPolicySource.xml",
- VCloudDirectorMediaType.ORG_PASSWORD_POLICY_SETTINGS)
- .acceptMedia(VCloudDirectorMediaType.ORG_PASSWORD_POLICY_SETTINGS).httpRequestBuilder().build(),
- new VcloudHttpResponsePrimer()
- .xmlFilePayload("/org/admin/editPasswordPolicy.xml",
- VCloudDirectorMediaType.ORG_PASSWORD_POLICY_SETTINGS).httpResponseBuilder().build());
-
- OrgPasswordPolicySettings expected = editOrgPasswordPolicy();
-
- assertEquals(api.getOrgApi().editPasswordPolicy(orgRef.getHref(), expected), expected);
- }
-
- public static final OrgPasswordPolicySettings editOrgPasswordPolicy() {
- return passwordPolicy().toBuilder().accountLockoutEnabled(true).invalidLoginsBeforeLockout(6)
- .accountLockoutIntervalMinutes(11).build();
- }
-
- @Test(enabled = false)
- public void testGetVAppLeaseSettings() {
- VCloudDirectorAdminApi api = requestsSendResponses(
- loginRequest,
- sessionResponse,
- new VcloudHttpRequestPrimer()
- .apiCommand("GET", "/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/vAppLeaseSettings")
- .acceptAnyMedia().httpRequestBuilder().build(),
- new VcloudHttpResponsePrimer()
- .xmlFilePayload("/org/admin/vAppLeaseSettings.xml", VCloudDirectorMediaType.ORG_LEASE_SETTINGS)
- .httpResponseBuilder().build());
-
- OrgLeaseSettings expected = vAppLeaseSettings();
-
- assertEquals(api.getOrgApi().getVAppLeaseSettings(orgRef.getHref()), expected);
- }
-
- public static final OrgLeaseSettings vAppLeaseSettings() {
- return OrgLeaseSettings
- .builder()
- .type("application/vnd.vmware.admin.vAppLeaseSettings+xml")
- .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/vAppLeaseSettings"))
- .link(Link
- .builder()
- .rel("edit")
- .type("application/vnd.vmware.admin.vAppLeaseSettings+xml")
- .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/vAppLeaseSettings"))
- .build()).deleteOnStorageLeaseExpiration(false).deploymentLeaseSeconds(0)
- .storageLeaseSeconds(0).build();
- }
-
- @Test(enabled = false)
- public void testEditOrgVAppLeaseSettings() {
- VCloudDirectorAdminApi api = requestsSendResponses(
- loginRequest,
- sessionResponse,
- new VcloudHttpRequestPrimer()
- .apiCommand("PUT", "/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/vAppLeaseSettings")
- .xmlFilePayload("/org/admin/editVAppLeaseSettingsSource.xml",
- VCloudDirectorMediaType.ORG_LEASE_SETTINGS)
- .acceptMedia(VCloudDirectorMediaType.ORG_LEASE_SETTINGS).httpRequestBuilder().build(),
- new VcloudHttpResponsePrimer()
- .xmlFilePayload("/org/admin/editVAppLeaseSettings.xml",
- VCloudDirectorMediaType.ORG_LEASE_SETTINGS).httpResponseBuilder().build());
-
- OrgLeaseSettings expected = editVAppLeaseSettings();
-
- assertEquals(api.getOrgApi().editVAppLeaseSettings(orgRef.getHref(), expected), expected);
- }
-
- public static final OrgLeaseSettings editVAppLeaseSettings() {
- return vAppLeaseSettings().toBuilder()
-
- .build();
- }
-
- @Test(enabled = false)
- public void testGetVAppTemplateLeaseSettings() {
- VCloudDirectorAdminApi api = requestsSendResponses(
- loginRequest,
- sessionResponse,
- new VcloudHttpRequestPrimer()
- .apiCommand("GET",
- "/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/vAppTemplateLeaseSettings")
- .acceptAnyMedia().httpRequestBuilder().build(),
- new VcloudHttpResponsePrimer()
- .xmlFilePayload("/org/admin/vAppTemplateLeaseSettings.xml",
- VCloudDirectorMediaType.ORG_VAPP_TEMPLATE_LEASE_SETTINGS).httpResponseBuilder()
- .build());
-
- OrgVAppTemplateLeaseSettings expected = vAppTemplateLeaseSettings();
-
- assertEquals(api.getOrgApi().getVAppTemplateLeaseSettings(orgRef.getHref()), expected);
- }
-
- public static final OrgVAppTemplateLeaseSettings vAppTemplateLeaseSettings() {
- return OrgVAppTemplateLeaseSettings
- .builder()
- .type("application/vnd.vmware.admin.vAppTemplateLeaseSettings+xml")
- .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/vAppTemplateLeaseSettings"))
- .link(Link
- .builder()
- .rel("edit")
- .type("application/vnd.vmware.admin.vAppTemplateLeaseSettings+xml")
- .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/vAppTemplateLeaseSettings"))
- .build()).deleteOnStorageLeaseExpiration(false).storageLeaseSeconds(0).build();
- }
-
- @Test(enabled = false)
- public void testEditOrgVAppTemplateLeaseSettings() {
- VCloudDirectorAdminApi api = requestsSendResponses(
- loginRequest,
- sessionResponse,
- new VcloudHttpRequestPrimer()
- .apiCommand("PUT",
- "/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/vAppTemplateLeaseSettings")
- .xmlFilePayload("/org/admin/editVAppLeaseSettingsSource.xml",
- VCloudDirectorMediaType.ORG_VAPP_TEMPLATE_LEASE_SETTINGS)
- .acceptMedia(VCloudDirectorMediaType.ORG_VAPP_TEMPLATE_LEASE_SETTINGS).httpRequestBuilder()
- .build(),
- new VcloudHttpResponsePrimer()
- .xmlFilePayload("/org/admin/editVAppLeaseSettings.xml",
- VCloudDirectorMediaType.ORG_VAPP_TEMPLATE_LEASE_SETTINGS).httpResponseBuilder()
- .build());
-
- OrgVAppTemplateLeaseSettings expected = editVAppTemplateLeaseSettings();
-
- assertEquals(api.getOrgApi().editVAppTemplateLeaseSettings(orgRef.getHref(), expected), expected);
- }
-
- public static final OrgVAppTemplateLeaseSettings editVAppTemplateLeaseSettings() {
- return vAppTemplateLeaseSettings().toBuilder()
-
- .build();
- }
-
- public static final OrgSettings settings() {
- return OrgSettings
- .builder()
- .type("application/vnd.vmware.admin.orgSettings+xml")
- .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings"))
- .link(Link
- .builder()
- .rel("down")
- .type("application/vnd.vmware.admin.vAppTemplateLeaseSettings+xml")
- .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/vAppTemplateLeaseSettings"))
- .build())
- .link(Link
- .builder()
- .rel("down")
- .type("application/vnd.vmware.admin.organizationEmailSettings+xml")
- .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/email"))
- .build())
- .link(Link
- .builder()
- .rel("down")
- .type("application/vnd.vmware.admin.vAppLeaseSettings+xml")
- .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/vAppLeaseSettings"))
- .build())
- .link(Link
- .builder()
- .rel("down")
- .type("application/vnd.vmware.admin.organizationPasswordPolicySettings+xml")
- .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/passwordPolicy"))
- .build())
- .link(Link
- .builder()
- .rel("down")
- .type("application/vnd.vmware.admin.organizationGeneralSettings+xml")
- .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/general"))
- .build())
- .link(Link
- .builder()
- .rel("down")
- .type("application/vnd.vmware.admin.organizationLdapSettings+xml")
- .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/ldap"))
- .build())
- .link(Link
- .builder()
- .rel("edit")
- .type("application/vnd.vmware.admin.orgSettings+xml")
- .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings"))
- .build()).generalSettings(generalSettings()).vAppLeaseSettings(vAppLeaseSettings())
- .vAppTemplateLeaseSettings(vAppTemplateLeaseSettings()).ldapSettings(ldapSettings())
- .emailSettings(emailSettings()).passwordPolicy(passwordPolicy()).build();
- }
-
- @Test
- public static final OrgSettings editSettings() {
- return settings().toBuilder().build();
- }
-
- public static final OrgEmailSettings emailSettings() {
- return OrgEmailSettings
- .builder()
- .type("application/vnd.vmware.admin.organizationEmailSettings+xml")
- .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/email"))
- .link(Link
- .builder()
- .rel("edit")
- .type("application/vnd.vmware.admin.organizationEmailSettings+xml")
- .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/email"))
- .build())
- .isDefaultSmtpServer(true)
- .isDefaultOrgEmail(true)
- .fromEmailAddress("")
- .defaultSubjectPrefix("")
- .isAlertEmailToAllAdmins(true)
- .smtpServerSettings(
- SmtpServerSettings.builder().useAuthentication(false).host("").username("").password("")
- .build()).build();
- }
-
- @Test
- public static final OrgEmailSettings editEmailSettings() {
- return emailSettings()
- .toBuilder()
- .isDefaultSmtpServer(false)
- .isDefaultOrgEmail(false)
- .fromEmailAddress("test@test.com")
- .defaultSubjectPrefix("new")
- .isAlertEmailToAllAdmins(false)
- .smtpServerSettings(
- emailSettings().getSmtpServerSettings().toBuilder().useAuthentication(true).host("new")
- .username("new").build()).build();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/775b89fd/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgApiLiveTest.java
----------------------------------------------------------------------
diff --git a/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgApiLiveTest.java b/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgApiLiveTest.java
deleted file mode 100644
index feb6ba2..0000000
--- a/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgApiLiveTest.java
+++ /dev/null
@@ -1,345 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.vcloud.director.v1_5.features.admin;
-
-import static com.google.common.base.Objects.equal;
-import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_UPDATABLE;
-import static org.testng.Assert.assertTrue;
-
-import org.jclouds.vcloud.director.v1_5.domain.Checks;
-import org.jclouds.vcloud.director.v1_5.domain.network.SmtpServerSettings;
-import org.jclouds.vcloud.director.v1_5.domain.org.AdminOrg;
-import org.jclouds.vcloud.director.v1_5.domain.org.OrgEmailSettings;
-import org.jclouds.vcloud.director.v1_5.domain.org.OrgGeneralSettings;
-import org.jclouds.vcloud.director.v1_5.domain.org.OrgLdapSettings;
-import org.jclouds.vcloud.director.v1_5.domain.org.OrgLeaseSettings;
-import org.jclouds.vcloud.director.v1_5.domain.org.OrgPasswordPolicySettings;
-import org.jclouds.vcloud.director.v1_5.domain.org.OrgSettings;
-import org.jclouds.vcloud.director.v1_5.domain.org.OrgVAppTemplateLeaseSettings;
-import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorApiLiveTest;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-@Test(groups = { "live", "admin" }, singleThreaded = true, testName = "AdminOrgApiLiveTest")
-public class AdminOrgApiLiveTest extends BaseVCloudDirectorApiLiveTest {
-
- public static final String ORG = "admin org";
-
- /*
- * Convenience references to API apis.
- */
-
- private AdminOrgApi orgApi;
-
- /*
- * Shared state between dependant tests.
- */
- private OrgSettings settings;
- private OrgEmailSettings emailSettings;
- private OrgGeneralSettings generalSettings;
- private OrgLdapSettings ldapSettings;
- private OrgPasswordPolicySettings passwordPolicy;
- private OrgLeaseSettings vAppLeaseSettings;
- private OrgVAppTemplateLeaseSettings vAppTemplateLeaseSettings;
-
- @Override
- @BeforeClass(alwaysRun = true)
- public void setupRequiredApis() {
- orgApi = adminContext.getApi().getOrgApi();
- }
-
- @Test(description = "GET /admin/org/{id}")
- public void testGetAdminOrg() {
- AdminOrg adminOrg = orgApi.get(org.getHref());
-
- Checks.checkAdminOrg(adminOrg);
- }
-
- @Test(description = "GET /admin/org/{id}/settings/email")
- public void testGetEmailSettings() {
- emailSettings = orgApi.getEmailSettings(org.getHref());
-
- Checks.checkEmailSettings(emailSettings);
- }
-
- @Test(description = "PUT /admin/org/{id}/settings/email", dependsOnMethods = { "testGetEmailSettings" })
- public void testEditEmailSettings() {
- boolean isDefaultSmtpServer = emailSettings.isDefaultSmtpServer();
- boolean isDefaultOrgEmail = emailSettings.isDefaultOrgEmail();
- String oldFromEmailAddress = emailSettings.getFromEmailAddress();
- String newFromEmailAddress = "test@test.com";
- String oldDefaultSubjectPrefix = emailSettings.getDefaultSubjectPrefix();
- String newDefaultSubjectPrefix = "new" + oldDefaultSubjectPrefix;
- boolean isAlertEmailToAllAdmins = emailSettings.isAlertEmailToAllAdmins();
- SmtpServerSettings oldSmtpServerSettings = emailSettings.getSmtpServerSettings();
- SmtpServerSettings newSmtpServerSettings = oldSmtpServerSettings.toBuilder()
- .useAuthentication(!oldSmtpServerSettings.useAuthentication())
- .host("new" + oldSmtpServerSettings.getHost()).username("new" + oldSmtpServerSettings.getUsername())
- .password("new" + oldSmtpServerSettings.getPassword()).build();
-
- try {
- OrgEmailSettings newEmailSettings = emailSettings.toBuilder().isDefaultSmtpServer(!isDefaultSmtpServer)
- .isDefaultOrgEmail(!isDefaultOrgEmail).fromEmailAddress(newFromEmailAddress)
- .defaultSubjectPrefix(newDefaultSubjectPrefix).isAlertEmailToAllAdmins(!isAlertEmailToAllAdmins)
- .smtpServerSettings(newSmtpServerSettings).build();
-
- emailSettings = orgApi.editEmailSettings(org.getHref(), newEmailSettings);
-
- assertTrue(equal(emailSettings.isDefaultSmtpServer(), !isDefaultSmtpServer),
- String.format(OBJ_FIELD_UPDATABLE, "emailSettings", "isDefaultSmtpServer"));
- assertTrue(equal(emailSettings.isDefaultOrgEmail(), !isDefaultOrgEmail),
- String.format(OBJ_FIELD_UPDATABLE, "emailSettings", "isDefaultOrgEmail"));
- assertTrue(equal(emailSettings.getFromEmailAddress(), newFromEmailAddress),
- String.format(OBJ_FIELD_UPDATABLE, "emailSettings", "fromEmailAddress"));
- assertTrue(equal(emailSettings.getDefaultSubjectPrefix(), newDefaultSubjectPrefix),
- String.format(OBJ_FIELD_UPDATABLE, "emailSettings", "defaultSubjectPrefix"));
- assertTrue(equal(emailSettings.isAlertEmailToAllAdmins(), !isAlertEmailToAllAdmins),
- String.format(OBJ_FIELD_UPDATABLE, "emailSettings", "isAlertEmailToAllAdmins"));
- assertTrue(equal(emailSettings.getSmtpServerSettings(), newSmtpServerSettings),
- String.format(OBJ_FIELD_UPDATABLE, "emailSettings", "smtpServerSettings"));
-
- // TODO negative tests?
-
- Checks.checkEmailSettings(emailSettings);
- } finally {
- emailSettings = emailSettings.toBuilder().isDefaultSmtpServer(isDefaultSmtpServer)
- .isDefaultOrgEmail(isDefaultOrgEmail).fromEmailAddress(oldFromEmailAddress)
- .defaultSubjectPrefix(oldDefaultSubjectPrefix).isAlertEmailToAllAdmins(isAlertEmailToAllAdmins)
- .smtpServerSettings(oldSmtpServerSettings).build();
-
- emailSettings = orgApi.editEmailSettings(org.getHref(), emailSettings);
- }
- }
-
- @Test(description = "GET /admin/org/{id}/settings/general")
- public void testGetGeneralSettings() {
- generalSettings = orgApi.getGeneralSettings(org.getHref());
-
- Checks.checkGeneralSettings(generalSettings);
- }
-
- @Test(description = "PUT /admin/org/{id}/settings/general", dependsOnMethods = { "testGetGeneralSettings" })
- public void testEditGeneralSettings() {
- // FIXME: canPublishCatalogs does not edit
- // boolean canPublishCatalogs = generalSettings.canPublishCatalogs();
- Integer deployedVMQuota = generalSettings.getDeployedVMQuota();
- Integer storedVmQuota = generalSettings.getStoredVmQuota();
- boolean useServerBootSequence = generalSettings.useServerBootSequence();
- Integer delayAfterPowerOnSeconds = generalSettings.getDelayAfterPowerOnSeconds();
-
- try {
- OrgGeneralSettings newGeneralSettings = generalSettings
- .toBuilder()
- // .canPublishCatalogs(!canPublishCatalogs)
- .deployedVMQuota(deployedVMQuota + 1).storedVmQuota(storedVmQuota + 1)
- .useServerBootSequence(!useServerBootSequence).delayAfterPowerOnSeconds(delayAfterPowerOnSeconds + 1)
- .build();
-
- generalSettings = orgApi.editGeneralSettings(org.getHref(), newGeneralSettings);
-
- // assertTrue(equal(generalSettings.canPublishCatalogs(), !canPublishCatalogs),
- // String.format(OBJ_FIELD_UPDATABLE,
- // "generalSettings", "canPublishCatalogs"));
- assertTrue(equal(generalSettings.getDeployedVMQuota(), deployedVMQuota + 1),
- String.format(OBJ_FIELD_UPDATABLE, "generalSettings", "deployedVMQuota"));
- assertTrue(equal(generalSettings.getStoredVmQuota(), storedVmQuota + 1),
- String.format(OBJ_FIELD_UPDATABLE, "generalSettings", "storedVmQuota"));
- assertTrue(equal(generalSettings.useServerBootSequence(), !useServerBootSequence),
- String.format(OBJ_FIELD_UPDATABLE, "generalSettings", "useServerBootSequence"));
- assertTrue(equal(generalSettings.getDelayAfterPowerOnSeconds(), delayAfterPowerOnSeconds + 1),
- String.format(OBJ_FIELD_UPDATABLE, "generalSettings", "delayAfterPowerOnSeconds"));
-
- // TODO negative tests?
-
- Checks.checkGeneralSettings(generalSettings);
- } finally {
- generalSettings = generalSettings
- .toBuilder()
- // .canPublishCatalogs(canPublishCatalogs)
- .deployedVMQuota(deployedVMQuota).storedVmQuota(storedVmQuota)
- .useServerBootSequence(useServerBootSequence).delayAfterPowerOnSeconds(delayAfterPowerOnSeconds)
- .build();
-
- generalSettings = orgApi.editGeneralSettings(org.getHref(), generalSettings);
- }
- }
-
- @Test(description = "GET /admin/org/{id}/settings/ldap")
- public void testGetLdapSettings() {
- ldapSettings = orgApi.getLdapSettings(org.getHref());
-
- Checks.checkLdapSettings(ldapSettings);
- }
-
- @Test(description = "GET /admin/org/{id}/settings/passwordPolicy")
- public void testGetPasswordPolicy() {
- passwordPolicy = orgApi.getPasswordPolicy(org.getHref());
-
- Checks.checkPasswordPolicySettings(passwordPolicy);
- }
-
- @Test(description = "PUT /admin/org/{id}/settings/passwordPolicy", dependsOnMethods = { "testGetPasswordPolicy" })
- public void testEditPasswordPolicy() {
- boolean accountLockoutEnabled = passwordPolicy.isAccountLockoutEnabled();
- Integer invalidLoginsBeforeLockout = passwordPolicy.getInvalidLoginsBeforeLockout();
- Integer accountLockoutIntervalMinutes = passwordPolicy.getAccountLockoutIntervalMinutes();
-
- try {
- OrgPasswordPolicySettings newPasswordPolicy = passwordPolicy.toBuilder()
- .accountLockoutEnabled(!accountLockoutEnabled)
- .invalidLoginsBeforeLockout(invalidLoginsBeforeLockout + 1)
- .accountLockoutIntervalMinutes(accountLockoutIntervalMinutes + 1).build();
-
- passwordPolicy = orgApi.editPasswordPolicy(org.getHref(), newPasswordPolicy);
-
- assertTrue(equal(passwordPolicy.isAccountLockoutEnabled(), !accountLockoutEnabled),
- String.format(OBJ_FIELD_UPDATABLE, "PasswordPolicySettings", "deleteOnStorageLeaseExpiration"));
- assertTrue(equal(passwordPolicy.getInvalidLoginsBeforeLockout(), invalidLoginsBeforeLockout + 1),
- String.format(OBJ_FIELD_UPDATABLE, "PasswordPolicySettings", "storageLeaseSeconds"));
- assertTrue(equal(passwordPolicy.getAccountLockoutIntervalMinutes(), accountLockoutIntervalMinutes + 1),
- String.format(OBJ_FIELD_UPDATABLE, "PasswordPolicySettings", "deploymentLeaseSeconds"));
-
- // TODO negative tests?
-
- Checks.checkPasswordPolicySettings(passwordPolicy);
- } finally {
- passwordPolicy = passwordPolicy.toBuilder().accountLockoutEnabled(accountLockoutEnabled)
- .invalidLoginsBeforeLockout(invalidLoginsBeforeLockout)
- .accountLockoutIntervalMinutes(accountLockoutIntervalMinutes).build();
-
- passwordPolicy = orgApi.editPasswordPolicy(org.getHref(), passwordPolicy);
- }
- }
-
- @Test(description = "GET /admin/org/{id}/settings/vAppLeaseSettings")
- public void testGetVAppLeaseSettings() {
- vAppLeaseSettings = orgApi.getVAppLeaseSettings(org.getHref());
-
- Checks.checkVAppLeaseSettings(vAppLeaseSettings);
- }
-
- @Test(description = "PUT /admin/org/{id}/settings/vAppLeaseSettings", dependsOnMethods = { "testGetVAppLeaseSettings" })
- // FIXME: fails with 403 forbidden
- public void testEditVAppLeaseSettings() {
- boolean deleteOnStorageLeaseExpiration = vAppLeaseSettings.deleteOnStorageLeaseExpiration();
- Integer storageLeaseSeconds = vAppLeaseSettings.getStorageLeaseSeconds();
- Integer deploymentLeaseSeconds = vAppLeaseSettings.getDeploymentLeaseSeconds();
-
- try {
- OrgLeaseSettings newVAppLeaseSettings = vAppLeaseSettings.toBuilder()
- .deleteOnStorageLeaseExpiration(!deleteOnStorageLeaseExpiration)
- .storageLeaseSeconds(storageLeaseSeconds + 1).deploymentLeaseSeconds(deploymentLeaseSeconds + 1)
- .build();
-
- vAppLeaseSettings = orgApi.editVAppLeaseSettings(org.getHref(), newVAppLeaseSettings);
-
- assertTrue(equal(vAppLeaseSettings.deleteOnStorageLeaseExpiration(), !deleteOnStorageLeaseExpiration),
- String.format(OBJ_FIELD_UPDATABLE, "vAppLeaseSettings", "deleteOnStorageLeaseExpiration"));
- assertTrue(equal(vAppLeaseSettings.getStorageLeaseSeconds(), storageLeaseSeconds + 1),
- String.format(OBJ_FIELD_UPDATABLE, "vAppLeaseSettings", "storageLeaseSeconds"));
- assertTrue(equal(vAppLeaseSettings.getDeploymentLeaseSeconds(), deploymentLeaseSeconds + 1),
- String.format(OBJ_FIELD_UPDATABLE, "vAppLeaseSettings", "deploymentLeaseSeconds"));
-
- // TODO negative tests?
-
- Checks.checkVAppLeaseSettings(vAppLeaseSettings);
- } finally {
- vAppLeaseSettings = vAppLeaseSettings.toBuilder()
- .deleteOnStorageLeaseExpiration(deleteOnStorageLeaseExpiration)
- .storageLeaseSeconds(storageLeaseSeconds).deploymentLeaseSeconds(deploymentLeaseSeconds).build();
-
- vAppLeaseSettings = orgApi.editVAppLeaseSettings(org.getHref(), vAppLeaseSettings);
- }
- }
-
- @Test(description = "GET /admin/org/{id}/settings/vAppTemplateLeaseSettings")
- public void testGetVAppTemplateLeaseSettings() {
- vAppTemplateLeaseSettings = orgApi.getVAppTemplateLeaseSettings(org.getHref());
-
- Checks.checkVAppTemplateLeaseSettings(vAppTemplateLeaseSettings);
- }
-
- @Test(description = "PUT /admin/org/{id}/settings/vAppTemplateLeaseSettings", dependsOnMethods = { "testGetVAppTemplateLeaseSettings" })
- // FIXME: fails with 403 forbidden
- public void testEditVAppTemplateLeaseSettings() {
- boolean deleteOnStorageLeaseExpiration = vAppTemplateLeaseSettings.deleteOnStorageLeaseExpiration();
- Integer storageLeaseSeconds = vAppTemplateLeaseSettings.getStorageLeaseSeconds();
-
- try {
- OrgVAppTemplateLeaseSettings newVAppTemplateLeaseSettings = vAppTemplateLeaseSettings.toBuilder()
- .deleteOnStorageLeaseExpiration(!deleteOnStorageLeaseExpiration)
- .storageLeaseSeconds(storageLeaseSeconds + 1).build();
-
- vAppTemplateLeaseSettings = orgApi.editVAppTemplateLeaseSettings(org.getHref(), newVAppTemplateLeaseSettings);
-
- assertTrue(equal(vAppTemplateLeaseSettings.deleteOnStorageLeaseExpiration(), !deleteOnStorageLeaseExpiration),
- String.format(OBJ_FIELD_UPDATABLE, "vAppTemplateLeaseSettings", "deleteOnStorageLeaseExpiration"));
- assertTrue(equal(vAppTemplateLeaseSettings.getStorageLeaseSeconds(), storageLeaseSeconds + 1),
- String.format(OBJ_FIELD_UPDATABLE, "vAppTemplateLeaseSettings", "storageLeaseSeconds"));
-
- // TODO negative tests?
-
- Checks.checkVAppTemplateLeaseSettings(vAppTemplateLeaseSettings);
- } finally {
- vAppTemplateLeaseSettings = vAppTemplateLeaseSettings.toBuilder()
- .deleteOnStorageLeaseExpiration(deleteOnStorageLeaseExpiration)
- .storageLeaseSeconds(storageLeaseSeconds).build();
-
- vAppTemplateLeaseSettings = orgApi.editVAppTemplateLeaseSettings(org.getHref(), vAppTemplateLeaseSettings);
- }
- }
-
- @Test(description = "GET /admin/org/{id}/settings")
- public void testGetSettings() {
- settings = orgApi.getSettings(org.getHref());
-
- Checks.checkOrgSettings(settings);
- }
-
- @Test(description = "PUT /admin/org/{id}/settings", dependsOnMethods = { "testGetEmailSettings" })
- public void testEditSettings() throws Exception {
- String newFromEmailAddress = "test" + random.nextInt(Integer.MAX_VALUE) + "@test.com";
- Exception exception = null;
-
- try {
- OrgSettings newSettings = OrgSettings.builder()
- .emailSettings(emailSettings.toBuilder().fromEmailAddress(newFromEmailAddress).build()).build();
-
- OrgSettings modified = orgApi.editSettings(org.getHref(), newSettings);
-
- Checks.checkOrgSettings(settings);
- assertTrue(equal(modified.getEmailSettings().getFromEmailAddress(), newFromEmailAddress),
- String.format(OBJ_FIELD_UPDATABLE, "orgSettings", "emailSettings"));
-
- } catch (Exception e) {
- exception = e;
- } finally {
- try {
- OrgSettings restorableSettings = OrgSettings.builder().emailSettings(emailSettings).build();
-
- settings = orgApi.editSettings(org.getHref(), restorableSettings);
- } catch (Exception e) {
- if (exception != null) {
- logger.warn(e, "Error resetting settings; rethrowing original test exception...");
- throw exception;
- } else {
- throw e;
- }
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/775b89fd/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminQueryApiExpectTest.java
----------------------------------------------------------------------
diff --git a/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminQueryApiExpectTest.java b/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminQueryApiExpectTest.java
deleted file mode 100644
index 9f90096..0000000
--- a/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminQueryApiExpectTest.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.vcloud.director.v1_5.features.admin;
-
-import static org.testng.Assert.assertEquals;
-
-import java.net.URI;
-
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
-import org.jclouds.vcloud.director.v1_5.admin.VCloudDirectorAdminApi;
-import org.jclouds.vcloud.director.v1_5.domain.Link;
-import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecords;
-import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRoleRecord;
-import org.jclouds.vcloud.director.v1_5.internal.VCloudDirectorAdminApiExpectTest;
-import org.testng.annotations.Test;
-
-import com.google.common.net.HttpHeaders;
-
-@Test(groups = { "unit", "admin" }, singleThreaded = true, testName = "AdminQueryApiExpectTest")
-public class AdminQueryApiExpectTest extends VCloudDirectorAdminApiExpectTest {
-
- // TODO Write expect tests for all other admin-query operations
-
- @Test
- public void testQueryAllGroups() {
-
- // TODO Need an example /admin/groups/query that actually contains records!
-
- HttpRequest queryRequest = HttpRequest.builder()
- .method("GET")
- .endpoint(endpoint + "/admin/groups/query")
- .addHeader("Accept", "*/*")
- .addHeader("x-vcloud-authorization", token)
- .addHeader(HttpHeaders.COOKIE, "vcloud-token=" + token)
- .build();
-
- HttpResponse queryResponse = HttpResponse.builder()
- .statusCode(200)
- .payload(payloadFromResourceWithContentType("/query/admin/allGroups.xml", VCloudDirectorMediaType.QUERY_RESULT_RECORDS + ";version=1.5"))
- .build();
-
- VCloudDirectorAdminApi api = requestsSendResponses(loginRequest, sessionResponse, queryRequest, queryResponse);
-
- QueryResultRecords expected = QueryResultRecords.builder()
- .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/groups/query?page=1&pageSize=25&format=records"))
- .type("application/vnd.vmware.vcloud.query.records+xml")
- .name("group")
- .page(1)
- .pageSize(25)
- .total(0L)
- .link(Link.builder()
- .rel("alternate")
- .type("application/vnd.vmware.vcloud.query.references+xml")
- .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/groups/query?page=1&pageSize=25&format=references"))
- .build())
- .link(Link.builder()
- .rel("alternate")
- .type("application/vnd.vmware.vcloud.query.idrecords+xml")
- .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/groups/query?page=1&pageSize=25&format=idrecords"))
- .build())
- .build();
-
- assertEquals(api.getQueryApi().groupsQueryAll(), expected);
- }
-
-// <?xml version="1.0" encoding="UTF-8"?>
-// <QueryResultRecords xmlns="http://www.vmware.com/vcloud/v1.5" total="4" pageSize="25" page="1" name="role" type="application/vnd.vmware.vcloud.query.records+xml" href="https://vcloudbeta.bluelock.com/api/admin/roles/query?page=1&pageSize=25&format=records" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://vcloudbeta.bluelock.com/api/v1.5/schema/master.xsd">
-// <Link rel="alternate" type="application/vnd.vmware.vcloud.query.references+xml" href="https://vcloudbeta.bluelock.com/api/admin/roles/query?page=1&pageSize=25&format=references"/>
-// <Link rel="alternate" type="application/vnd.vmware.vcloud.query.idrecords+xml" href="https://vcloudbeta.bluelock.com/api/admin/roles/query?page=1&pageSize=25&format=idrecords"/>
-// <RoleRecord name="vApp Author" isReadOnly="false" href="https://vcloudbeta.bluelock.com/api/admin/role/1bf4457f-a253-3cf1-b163-f319f1a31802"/>
-// </QueryResultRecords>
-
- @Test
- public void testQueryAllRoles() {
-
- HttpRequest queryRequest = HttpRequest.builder()
- .method("GET")
- .endpoint(endpoint + "/admin/roles/query")
- .addHeader("Accept", "*/*")
- .addHeader("x-vcloud-authorization", token)
- .addHeader(HttpHeaders.COOKIE, "vcloud-token=" + token).build();
-
- HttpResponse queryResponse = HttpResponse.builder()
- .statusCode(200)
- .payload(payloadFromResourceWithContentType("/query/admin/allRoles.xml", VCloudDirectorMediaType.QUERY_RESULT_RECORDS + ";version=1.5"))
- .build();
-
- VCloudDirectorAdminApi api = requestsSendResponses(loginRequest, sessionResponse, queryRequest, queryResponse);
-
- QueryResultRecords expected = QueryResultRecords.builder()
- .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/roles/query?page=1&pageSize=25&format=records"))
- .type("application/vnd.vmware.vcloud.query.records+xml")
- .name("role")
- .page(1)
- .pageSize(25)
- .total(1L)
- .link(Link.builder()
- .rel("alternate")
- .type("application/vnd.vmware.vcloud.query.references+xml")
- .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/roles/query?page=1&pageSize=25&format=references"))
- .build())
- .link(Link.builder()
- .rel("alternate")
- .type("application/vnd.vmware.vcloud.query.idrecords+xml")
- .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/roles/query?page=1&pageSize=25&format=idrecords"))
- .build())
- .record(QueryResultRoleRecord.builder()
- .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/role/1bf4457f-a253-3cf1-b163-f319f1a31802"))
- .name("vApp Author")
- .isReadOnly(false)
- .build())
- .build();
-
- assertEquals(api.getQueryApi().rolesQueryAll(), expected);
- }
-}
-
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/775b89fd/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminQueryApiLiveTest.java
----------------------------------------------------------------------
diff --git a/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminQueryApiLiveTest.java b/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminQueryApiLiveTest.java
deleted file mode 100644
index d74c1de..0000000
--- a/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminQueryApiLiveTest.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.vcloud.director.v1_5.features.admin;
-
-import static org.testng.Assert.assertEquals;
-
-import org.jclouds.vcloud.director.v1_5.domain.Checks;
-import org.jclouds.vcloud.director.v1_5.domain.Reference;
-import org.jclouds.vcloud.director.v1_5.domain.RoleReferences;
-import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultAdminUserRecord;
-import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultAdminVdcRecord;
-import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecord;
-import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecords;
-import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRightRecord;
-import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRoleRecord;
-import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultStrandedUserRecord;
-import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorApiLiveTest;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-@Test(groups = { "live", "admin" }, singleThreaded = true, testName = "AdminQueryApiLiveTest")
-public class AdminQueryApiLiveTest extends BaseVCloudDirectorApiLiveTest {
-
- /*
- * Convenience references to API apis.
- */
-
- private AdminQueryApi queryApi;
-
- @Override
- @BeforeClass(alwaysRun = true)
- public void setupRequiredApis() {
- queryApi = adminContext.getApi().getQueryApi();
- }
-
- @Test(description = "GET /admin/groups/query")
- public void testQueryAllGroups() {
- // TODO Ensure there will be at least one record, for asserting result
- QueryResultRecords resultRecords = queryApi.groupsQueryAll();
-
- for (QueryResultRecord record : resultRecords.getRecords()) {
- Checks.checkQueryResultRecord(record);
- }
- }
-
- @Test(description = "GET /admin/orgs/query")
- public void testQueryAllOrgs() {
- // TODO Ensure there will be at least one record, for asserting result
- QueryResultRecords resultRecords = queryApi.orgsQueryAll();
-
- for (QueryResultRecord record : resultRecords.getRecords()) {
- Checks.checkQueryResultRecord(record);
- }
- }
-
- @Test(description = "GET /admin/rights/query")
- public void testQueryAllRights() {
- // TODO Ensure there will be at least one record, for asserting result
- QueryResultRecords resultRecords = queryApi.rightsQueryAll();
-
- for (QueryResultRecord record : resultRecords.getRecords()) {
- Checks.checkQueryResultRecord(record);
- assertEquals(record.getClass(), QueryResultRightRecord.class, "incorrect record type admin query");
- }
- }
-
- @Test(description = "GET /admin/roles/query")
- public void testQueryAllRoles() {
- // TODO Ensure there will be at least one record, for asserting result
- QueryResultRecords resultRecords = queryApi.rolesQueryAll();
-
- for (QueryResultRecord record : resultRecords.getRecords()) {
- Checks.checkQueryResultRecord(record);
- assertEquals(record.getClass(), QueryResultRoleRecord.class, "incorrect record type admin query");
- }
-
- RoleReferences roleRefs = queryApi.roleReferencesQueryAll();
-
- for (Reference ref : roleRefs.getReferences()) {
- Checks.checkReferenceType(ref);
- }
- }
-
- @Test(description = "GET /admin/strandedUsers/query")
- public void testQueryAllStrandedUsers() {
- // TODO Ensure there will be at least one record, for asserting result
- QueryResultRecords resultRecords = queryApi.strandedUsersQueryAll();
-
- for (QueryResultRecord record : resultRecords.getRecords()) {
- Checks.checkQueryResultRecord(record);
- assertEquals(record.getClass(), QueryResultStrandedUserRecord.class, "incorrect record type admin query");
- }
- }
-
- @Test(description = "GET /admin/users/query")
- public void testQueryAllUsers() {
- // TODO Ensure there will be at least one record, for asserting result
- QueryResultRecords resultRecords = queryApi.usersQueryAll();
-
- for (QueryResultRecord record : resultRecords.getRecords()) {
- Checks.checkQueryResultRecord(record);
- assertEquals(record.getClass(), QueryResultAdminUserRecord.class, "incorrect record type admin query");
- }
- }
-
- @Test(description = "GET /admin/vdcs/query")
- public void testQueryAllVdc() {
- // TODO Ensure there will be at least one record, for asserting result
- QueryResultRecords resultRecords = queryApi.vdcsQueryAll();
-
- for (QueryResultRecord record : resultRecords.getRecords()) {
- Checks.checkQueryResultRecord(record);
- assertEquals(record.getClass(), QueryResultAdminVdcRecord.class, "incorrect record type admin query");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/775b89fd/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcApiExpectTest.java
----------------------------------------------------------------------
diff --git a/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcApiExpectTest.java b/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcApiExpectTest.java
deleted file mode 100644
index ad28867..0000000
--- a/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcApiExpectTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.vcloud.director.v1_5.features.admin;
-
-import static org.testng.Assert.assertEquals;
-
-import java.net.URI;
-
-import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
-import org.jclouds.vcloud.director.v1_5.admin.VCloudDirectorAdminApi;
-import org.jclouds.vcloud.director.v1_5.domain.AdminVdc;
-import org.jclouds.vcloud.director.v1_5.domain.Reference;
-import org.jclouds.vcloud.director.v1_5.features.VdcApiExpectTest;
-import org.jclouds.vcloud.director.v1_5.internal.VCloudDirectorAdminApiExpectTest;
-import org.testng.annotations.Test;
-
-@Test(groups = { "unit", "admin" }, singleThreaded = true, testName = "AdminVdcApiExpectTest")
-public class AdminVdcApiExpectTest extends VCloudDirectorAdminApiExpectTest {
-
- private Reference vdcRef = Reference.builder()
- .href(URI.create(endpoint + "???"))
- .build();
-
- @Test( enabled = false )
- public void testGetVdc() {
- VCloudDirectorAdminApi api = requestsSendResponses(loginRequest, sessionResponse,
- new VcloudHttpRequestPrimer()
- .apiCommand("GET", "/admin/vdc/???")
- .acceptAnyMedia()
- .httpRequestBuilder().build(),
- new VcloudHttpResponsePrimer()
- .xmlFilePayload("/vdc/admin/vdc.xml",
- VCloudDirectorMediaType.ADMIN_VDC)
- .httpResponseBuilder().build());
-
- AdminVdc expected = adminVdc();
-
- assertEquals(api.getVdcApi().get(vdcRef.getHref()), expected);
- }
-
- public static final AdminVdc adminVdc() {
- return AdminVdc.builder().fromVdc(VdcApiExpectTest.getVdc())
-
- .build();
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/775b89fd/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcApiLiveTest.java
----------------------------------------------------------------------
diff --git a/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcApiLiveTest.java b/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcApiLiveTest.java
deleted file mode 100644
index 99e792a..0000000
--- a/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcApiLiveTest.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.vcloud.director.v1_5.features.admin;
-
-import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_REQ_LIVE;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertNull;
-
-import org.jclouds.vcloud.director.v1_5.VCloudDirectorException;
-import org.jclouds.vcloud.director.v1_5.domain.AdminVdc;
-import org.jclouds.vcloud.director.v1_5.domain.Checks;
-import org.jclouds.vcloud.director.v1_5.domain.Metadata;
-import org.jclouds.vcloud.director.v1_5.domain.Task;
-import org.jclouds.vcloud.director.v1_5.features.MetadataApi;
-import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorApiLiveTest;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableMap;
-
-@Test(groups = { "live", "admin" }, singleThreaded = true, testName = "AdminVdcApiLiveTest")
-public class AdminVdcApiLiveTest extends BaseVCloudDirectorApiLiveTest {
-
- public static final String VDC = "admin vdc";
-
- /*
- * Convenience reference to API api.
- */
- protected AdminVdcApi vdcApi;
- protected MetadataApi metadataApi;
-
- private String metadataKey;
- private String metadataValue;
-
- @Override
- @BeforeClass(alwaysRun = true)
- public void setupRequiredApis() {
- vdcApi = adminContext.getApi().getVdcApi();
- metadataApi = context.getApi().getMetadataApi(context.resolveIdToHref(vdcId));
- }
-
- @AfterClass(alwaysRun = true)
- public void cleanUp() throws Exception {
- if (metadataKey != null) {
- try {
- Task task = metadataApi.remove(metadataKey);
- taskDoneEventually(task);
- } catch (VCloudDirectorException e) {
- logger.warn(e, "Error deleting metadata-value (perhaps it doesn't exist?); continuing...");
- }
- }
- }
-
- @Test(description = "GET /admin/vdc/{id}")
- public void testGetVdc() {
- AdminVdc vdc = vdcApi.get(context.resolveIdToAdminHref(vdcId));
- assertNotNull(vdc, String.format(OBJ_REQ_LIVE, VDC));
-
- // parent type
- Checks.checkAdminVdc(vdc);
- }
-
- // TODO insufficient permissions to test
- @Test(description = "PUT /admin/vdc/{id}", enabled = false)
- public void testEditVdc() throws Exception {
- String origName = lazyGetVdc().getName();
- String newName = name("a");
- Exception exception = null;
-
- AdminVdc vdc = AdminVdc.builder().name(newName).build();
-
- try {
- Task task = vdcApi.edit(vdc.getHref(), vdc);
- assertTaskSucceeds(task);
-
- AdminVdc modified = vdcApi.get(vdc.getHref());
- assertEquals(modified.getName(), newName);
-
- // parent type
- Checks.checkAdminVdc(vdc);
- } catch (Exception e) {
- exception = e;
- } finally {
- try {
- AdminVdc restorableVdc = AdminVdc.builder().name(origName).build();
- Task task = vdcApi.edit(vdc.getHref(), restorableVdc);
- assertTaskSucceeds(task);
- } catch (Exception e) {
- if (exception != null) {
- logger.warn(e, "Error resetting adminVdc.name; rethrowing original test exception...");
- throw exception;
- } else {
- throw e;
- }
- }
- }
- }
-
- // TODO insufficient permissions to test
- @Test(description = "DELETE /admin/vdc/{id}", enabled = false)
- public void testRemoveVdc() throws Exception {
- // TODO Need to have a VDC that we're happy to remove!
- Task task = vdcApi.remove(context.resolveIdToAdminHref(vdcId));
- assertTaskSucceeds(task);
-
- try {
- vdcApi.get(context.resolveIdToAdminHref(vdcId));
- } catch (VCloudDirectorException e) {
- // success; unreachable because it has been removed
- // TODO: ^^ wrong. this should return null
- }
- }
-
- // TODO insufficient permissions to test
- @Test(description = "DISABLE/ENABLE /admin/vdc/{id}", enabled = false)
- public void testDisableAndEnableVdc() throws Exception {
- // TODO Need to have a VDC that we're happy to remove!
- Exception exception = null;
-
- try {
- vdcApi.disable(context.resolveIdToAdminHref(vdcId));
- } catch (Exception e) {
- exception = e;
- } finally {
- try {
- vdcApi.enable(context.resolveIdToAdminHref(vdcId));
- } catch (Exception e) {
- if (exception != null) {
- logger.warn(e, "Error resetting adminVdc.name; rethrowing original test exception...");
- throw exception;
- } else {
- throw e;
- }
- }
- }
- }
-
- @Test(description = "GET /admin/vdc/{id}/metadata")
- public void testGetMetadata() throws Exception {
- Metadata metadata = metadataApi.get();
-
- Checks.checkMetadata(metadata);
- }
-
- // TODO insufficient permissions to test
- @Test(description = "PUT /admin/vdc/{id}/metadata", enabled = false)
- public void testSetMetadata() throws Exception {
- metadataKey = name("key-");
- metadataValue = name("value-");
-
- Task task = metadataApi.putAll(ImmutableMap.of(metadataKey, metadataValue));
-
- assertTaskSucceeds(task);
-
- String modified = metadataApi.get(metadataKey);
- assertEquals(modified, metadataValue);
- }
-
- // TODO insufficient permissions to test
- @Test(description = "GET /admin/vdc/{id}/metadata/{key}", dependsOnMethods = { "testSetMetadata" }, enabled = false)
- public void testGetMetadataValue() throws Exception {
- String retrievedMetadataValue = metadataApi.get(metadataKey);
-
- assertEquals(retrievedMetadataValue, metadataValue);
- }
-
- // TODO insufficient permissions to test
- @Test(description = "PUT /admin/vdc/{id}/metadata/{key}", dependsOnMethods = { "testGetMetadataValue" }, enabled = false)
- public void testSetMetadataValue() throws Exception {
- metadataValue = name("value-");
-
- Task task = metadataApi.put(metadataKey, metadataValue);
- assertTaskSucceeds(task);
-
- String retrievedMetadataValue = metadataApi.get(metadataKey);
- assertEquals(retrievedMetadataValue, metadataValue);
- }
-
- // TODO insufficient permissions to test
- @Test(description = "DELETE /admin/vdc/{id}/metadata/{key}", dependsOnMethods = { "testSetMetadataValue" }, enabled = false)
- public void testRemoveMetadataValue() throws Exception {
- // TODO Remove dependency on other tests; make cleanUp remove a list of metadata entries?
-
- Task task = metadataApi.remove(metadataKey);
- assertTaskSucceeds(task);
-
- assertNull(metadataApi.get(metadataKey));
- }
-}