Search in sources :

Example 11 with ProjectElement

use of com.emc.storageos.model.project.ProjectElement in project coprhd-controller by CoprHD.

the class ApiTestTenants method testTenantEditToCreateProject.

@Test
public void testTenantEditToCreateProject() throws NoSuchAlgorithmException {
    final String testName = "testTenantEditToCreateProject - ";
    // Create an authnprovider before creating a tenant.
    AuthnCreateParam authnProviderCreateParam = getDefaultAuthnCreateParam(testName + getTestDefaultAuthnProviderDescription());
    ClientResponse clientAuthnProviderCreateResp = rSys.path(getTestAuthnProviderApi()).post(ClientResponse.class, authnProviderCreateParam);
    // Validate the authn provider creation success and add the
    // resource to the resource clean up list.
    validateAuthnProviderCreateSuccess(clientAuthnProviderCreateResp);
    TenantCreateParam createParam = this.getDefaultTenantCreateParam(testName + "Successful creation of tenant for project creation");
    TenantOrgRestRep createResp = rSys.path(getTestApi()).post(TenantOrgRestRep.class, createParam);
    validateTenantCreateSuccess(createParam, createResp);
    // Creating a roleAssignmentEntry with group.
    RoleAssignmentChanges roleAssignmentEntryParam = getDefaultRoleAssignmentChanges(true, true);
    String roleAssignmentsApi = getTestRoleAssignmentsApi(createResp.getId());
    RoleAssignments roleAssignmentCreateResp = rSys.path(roleAssignmentsApi).put(RoleAssignments.class, roleAssignmentEntryParam);
    validateRoleAssignmentCreateSuccess(roleAssignmentEntryParam, roleAssignmentCreateResp);
    String projectCreateApi = getProjectCreateApi(createResp.getId());
    ProjectParam projectCreateParam = getDefaultProjectParam("TestProject");
    ProjectElement projectCreateResp = rSys.path(projectCreateApi).post(ProjectElement.class, projectCreateParam);
    validateProjectCreateSuccess(projectCreateParam.getName(), projectCreateResp);
    // Create a user who is part of the tenant's group.
    BalancedWebResource ldapUser = getHttpsClient(getUserWithDomain(1), getUserPassword());
    // Get the tenant of the ldap user. This should return the above created tenant.
    TenantResponse tenantGetResp = ldapUser.path(getGetTenantApi()).get(TenantResponse.class);
    validateGetTenantSuccess(createResp, tenantGetResp);
    String getProjectApi = this.getProjectGetApi(createResp.getId());
    // Get the project of the ldap user. This should return the above created project.
    com.emc.storageos.model.project.ProjectList getProjectResp = ldapUser.path(getProjectApi).get(com.emc.storageos.model.project.ProjectList.class);
    validateGetProjectSuccess(projectCreateResp.getName().toString(), getProjectResp);
    // Create a user who is not part of the tenant's group.
    ldapUser = getHttpsClient(getUserWithDomain(2), getUserPassword());
    // Get the tenant of the ldap user. This should not return any tenant.
    ClientResponse clientTenantGetResp = ldapUser.path(getGetTenantApi()).get(ClientResponse.class);
    Assert.assertEquals(HttpStatus.SC_FORBIDDEN, clientTenantGetResp.getStatus());
    ClientResponse clientProjectIdsResp = ldapUser.path(getProjectApi).get(ClientResponse.class);
    Assert.assertEquals(HttpStatus.SC_FORBIDDEN, clientProjectIdsResp.getStatus());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) ProjectParam(com.emc.storageos.model.project.ProjectParam) ProjectElement(com.emc.storageos.model.project.ProjectElement) Test(org.junit.Test)

Example 12 with ProjectElement

use of com.emc.storageos.model.project.ProjectElement in project coprhd-controller by CoprHD.

the class OpenStackSynchronizationTask method createProject.

/**
 * Creates a CoprHD Project for given Tenant.
 * Sends internal POST API call to InternalTenantsService in order to create Project.
 *
 * @param tenantOrgId ID of the Project owner.
 * @param tenant OpenStack Tenant.
 *
 * @return URI of newly created Project.
 */
public URI createProject(URI tenantOrgId, KeystoneTenant tenant) {
    ProjectParam projectParam = new ProjectParam(tenant.getName() + CinderConstants.PROJECT_NAME_SUFFIX);
    ProjectElement projectResp = _internalTenantServiceClient.createProject(tenantOrgId, projectParam);
    return projectResp.getId();
}
Also used : ProjectParam(com.emc.storageos.model.project.ProjectParam) ProjectElement(com.emc.storageos.model.project.ProjectElement)

Aggregations

ProjectElement (com.emc.storageos.model.project.ProjectElement)12 ProjectParam (com.emc.storageos.model.project.ProjectParam)8 ClientResponse (com.sun.jersey.api.client.ClientResponse)3 URI (java.net.URI)3 Test (org.junit.Test)3 NamedURI (com.emc.storageos.db.client.model.NamedURI)2 Project (com.emc.storageos.db.client.model.Project)2 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)2 TenantOrgRestRep (com.emc.storageos.model.tenant.TenantOrgRestRep)2 ContainmentPrefixConstraint (com.emc.storageos.db.client.constraint.ContainmentPrefixConstraint)1 PrefixConstraint (com.emc.storageos.db.client.constraint.PrefixConstraint)1 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 FCTN_STRING_TO_URI (com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_STRING_TO_URI)1 FCTN_VPLEX_MIRROR_TO_URI (com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_VPLEX_MIRROR_TO_URI)1 BulkIdParam (com.emc.storageos.model.BulkIdParam)1 TaskResourceRep (com.emc.storageos.model.TaskResourceRep)1 ACLAssignmentChanges (com.emc.storageos.model.auth.ACLAssignmentChanges)1 ACLEntry (com.emc.storageos.model.auth.ACLEntry)1 FileShareBulkRep (com.emc.storageos.model.file.FileShareBulkRep)1 FileShareRestRep (com.emc.storageos.model.file.FileShareRestRep)1