Issue 830: Add control access tests to Org

This commit is contained in:
Andrew Donald Kennedy 2012-03-21 20:54:32 +00:00
parent 6918d1c448
commit 25fac3b36e
4 changed files with 34 additions and 10 deletions

View File

@ -43,8 +43,10 @@
<test.vcloud-director.image.login-user></test.vcloud-director.image.login-user>
<test.vcloud-director.image.authenticate-sudo></test.vcloud-director.image.authenticate-sudo>
<test.vcloud-director.catalog-name>Public</test.vcloud-director.catalog-name>
<test.vcloud-director.catalog-id></test.vcloud-director.catalog-id>
<test.vcloud-director.media-id></test.vcloud-director.media-id>
<test.vcloud-director.vapptemplate-id></test.vcloud-director.vapptemplate-id>
<test.vcloud-director.network-name></test.vcloud-director.network-name>
<test.vcloud-director.network-id></test.vcloud-director.network-id>
<test.vcloud-director.vdc-id></test.vcloud-director.vdc-id>
</properties>
@ -114,9 +116,11 @@
<test.vcloud-director.image-id>${test.vcloud-director.image-id}</test.vcloud-director.image-id>
<test.vcloud-director.image.login-user>${test.vcloud-director.image.login-user}</test.vcloud-director.image.login-user>
<test.vcloud-director.image.authenticate-sudo>${test.vcloud-director.image.authenticate-sudo}</test.vcloud-director.image.authenticate-sudo>
<test.vcloud-director.catalog-id>${test.vcloud-director.catalog-id}</test.vcloud-director.catalog-id>
<test.vcloud-director.catalog-name>${test.vcloud-director.catalog-name}</test.vcloud-director.catalog-name>
<test.vcloud-director.media-id>${test.vcloud-director.media-id}</test.vcloud-director.media-id>
<test.vcloud-director.vapptemplate-id>${test.vcloud-director.vapptemplate-id}</test.vcloud-director.vapptemplate-id>
<test.vcloud-director.network-name>${test.vcloud-director.network-name}</test.vcloud-director.network-name>
<test.vcloud-director.network-id>${test.vcloud-director.network-id}</test.vcloud-director.network-id>
<test.vcloud-director.vdc-id>${test.vcloud-director.vdc-id}</test.vcloud-director.vdc-id>
</systemPropertyVariables>

View File

@ -78,18 +78,20 @@ public interface OrgAsyncClient {
@Consumes(CONTROL_ACCESS)
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<ControlAccessParams> modifyControlAccess(@EndpointParam URI orgURI, @PathParam("catalogId") String catalogId,
ListenableFuture<ControlAccessParams> modifyControlAccess(@EndpointParam URI orgRef,
@PathParam("catalogId") String catalogId,
@BinderParam(BindToXMLPayload.class) ControlAccessParams params);
/**
* @see OrgClient#getControlAccess(URI, URI, ControlAccessParams)
*/
@POST
@GET
@Path("/catalog/{catalogId}/controlAccess")
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<ControlAccessParams> getControlAccess(@EndpointParam URI orgURI, @PathParam("catalogId") String catalogId);
ListenableFuture<ControlAccessParams> getControlAccess(@EndpointParam URI orgRef,
@PathParam("catalogId") String catalogId);
/**
* @return asynchronous access to {@link Metadata.Readable} features

View File

@ -145,18 +145,24 @@ public class OrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
assertEquals(value.getValue(), expected, String.format(CORRECT_VALUE_OBJECT_FMT, "Value", "MetadataValue", expected, value.getValue()));
}
@Test(testName = "GET /org/{id}/catalog/{catalogId}/controlAccess")
public void testGetontrolAccess() {
String catalogId = "";
@Test(testName = "GET /org/{id}/catalog/{catalogId}/controlAccess", dependsOnMethods = { "testGetOrg" })
public void testGetControlAccess() {
// Call the method being tested
ControlAccessParams params = orgClient.getControlAccess(orgURI, catalogId);
// Check params are well formed
checkControlAccessParams(params);
}
@Test(testName = "GET /org/{id}/catalog/{catalogId}/action/controlAccess", dependsOnMethods = { "testGetontrolAccess" })
@Test(testName = "GET /org/{id}/catalog/{catalogId}/action/controlAccess", dependsOnMethods = { "testGetControlAccess" })
public void testModifyControlAccess() {
String catalogId = "";
// Setup params
ControlAccessParams params = orgClient.getControlAccess(orgURI, catalogId);
// Call the method being tested
ControlAccessParams modified = orgClient.modifyControlAccess(orgURI, catalogId, params);
// Check params are well formed
checkControlAccessParams(modified);
}
}

View File

@ -77,6 +77,7 @@ import org.testng.annotations.Test;
import com.google.common.base.Optional;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
@ -112,6 +113,7 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ
protected Session session;
protected String catalogName;
protected String catalogId;
protected String networkName;
protected String userName;
@ -166,6 +168,7 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ
@SuppressWarnings("unchecked")
protected void initTestParametersFromPropertiesOrLazyDiscover() {
catalogName = Strings.emptyToNull(System.getProperty("test." + provider + ".catalog-name"));
catalogId = Strings.emptyToNull(System.getProperty("test." + provider + ".catalog-id"));
networkName = Strings.emptyToNull(System.getProperty("test." + provider + ".network-name"));
String vAppTemplateId = Strings.emptyToNull(System.getProperty("test." + provider + ".vapptemplate-id"));
@ -201,11 +204,20 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ
networkURI = Iterables.find(thisOrg.getLinks(),
ReferenceTypePredicates.<Link> typeEquals(VCloudDirectorMediaType.ORG_NETWORK)).getHref();
if (catalogName == null)
if (Strings.isNullOrEmpty(networkName))
networkName = Iterables.find(thisOrg.getLinks(),
ReferenceTypePredicates.<Link> typeEquals(VCloudDirectorMediaType.ORG_NETWORK)).getName();
if (Strings.isNullOrEmpty(catalogName))
catalogName = Iterables.find(thisOrg.getLinks(),
ReferenceTypePredicates.<Link> typeEquals(VCloudDirectorMediaType.CATALOG)).getName();
// TODO look for default networkName
// FIXME the URI should be opaque
if (Strings.isNullOrEmpty(catalogId)) {
String uri = Iterables.find(thisOrg.getLinks(),
ReferenceTypePredicates.<Link> typeEquals(VCloudDirectorMediaType.CATALOG)).getHref().toASCIIString();
catalogId = Iterables.getLast(Splitter.on('/').split(uri));
}
}
}