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());
}
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();
}
Aggregations