use of com.emc.storageos.model.tenant.UserMappingParam in project coprhd-controller by CoprHD.
the class ApiTest method createTenant.
private TenantOrgRestRep createTenant(String label, String domain, String attrKey, String attrValue) throws Exception {
BalancedWebResource rootUser = createHttpsClient(SYSADMIN, SYSADMIN_PASS_WORD, baseUrls);
UserInfo info = rootUser.path("/user/whoami").get(UserInfo.class);
String rootTenantId = info.getTenant();
String rootToken = (String) _savedTokens.get(SYSADMIN);
TenantCreateParam tenantParam = new TenantCreateParam();
tenantParam.setLabel(label);
tenantParam.setDescription("description for " + label);
tenantParam.setUserMappings(new ArrayList<UserMappingParam>());
UserMappingParam tenant2UserMapping = new UserMappingParam();
tenant2UserMapping.setDomain(domain);
UserMappingAttributeParam tenant2Attr = new UserMappingAttributeParam();
tenant2Attr.setKey(attrKey);
tenant2Attr.setValues(Collections.singletonList(attrValue));
tenant2UserMapping.setAttributes(Collections.singletonList(tenant2Attr));
tenantParam.getUserMappings().add(tenant2UserMapping);
String subtenant_url = "/tenants/" + rootTenantId + "/subtenants";
TenantOrgRestRep tenantOrg = rootUser.path(subtenant_url).header(AUTH_TOKEN_HEADER, rootToken).post(TenantOrgRestRep.class, tenantParam);
return tenantOrg;
}
use of com.emc.storageos.model.tenant.UserMappingParam in project coprhd-controller by CoprHD.
the class ApiTestBase method updateRootTenantAttrs.
/**
* Update tenant attributes for the root tenant
*/
protected void updateRootTenantAttrs() {
TenantResponse tenantResp = rSys.path("/tenant").get(TenantResponse.class);
rootTenantId = tenantResp.getTenant();
/*
* PUT the ou=sanity attribute mapping into the root tenant attributes
*/
TenantUpdateParam tenantUpdate = new TenantUpdateParam();
tenantUpdate.setUserMappingChanges(new UserMappingChanges());
tenantUpdate.getUserMappingChanges().setAdd(new ArrayList<UserMappingParam>());
UserMappingParam rootMapping = new UserMappingParam();
rootMapping.setDomain("SANITY.local");
UserMappingAttributeParam rootAttr = new UserMappingAttributeParam();
rootAttr.setKey("ou");
rootAttr.setValues(Collections.singletonList(ROOTTENANT_ATTR));
rootMapping.setAttributes(Collections.singletonList(rootAttr));
tenantUpdate.getUserMappingChanges().getAdd().add(rootMapping);
// TODO: FIX: not sure why name is required for update
tenantUpdate.setLabel(ROOTTENANT_NAME);
ClientResponse resp = rSys.path("/tenants/" + rootTenantId.toString()).put(ClientResponse.class, tenantUpdate);
Assert.assertEquals(200, resp.getStatus());
}
use of com.emc.storageos.model.tenant.UserMappingParam in project coprhd-controller by CoprHD.
the class ApiTest method authnProviderAddDomainTest.
// quick test to see if the added domain of AP server is converted to all lowercase
public void authnProviderAddDomainTest() throws Exception {
AuthnCreateParam param = new AuthnCreateParam();
param.setLabel("domain test AP server");
param.setDescription("AP server configuration created by ApiTest.java");
param.setDisable(false);
param.getDomains().add("asd.locl");
param.setManagerDn("CN=Manager,DC=root,DC=com");
param.setManagerPassword("secret");
param.setSearchBase("OU=People,DC=root,DC=com");
param.setSearchFilter("mail=%u");
param.setServerUrls(new HashSet<String>());
param.getServerUrls().add("ldaps:\\" + LDAP_SERVER1_IP);
param.setMode("ldap");
AuthnProviderRestRep resp = rSys.path("/vdc/admin/authnproviders").post(AuthnProviderRestRep.class, param);
Assert.assertNotNull(resp);
// update the AP server by adding a domain name with mixed case
AuthnUpdateParam updateParam = new AuthnUpdateParam();
Set<String> toAddSet = new HashSet<String>();
toAddSet.add("sAnItY2.local");
updateParam.getDomainChanges().setAdd(toAddSet);
ClientResponse response = rSys.path("/vdc/admin/authnproviders/" + resp.getId()).put(ClientResponse.class, updateParam);
Assert.assertEquals(200, response.getStatus());
// verify the added domain name is converted to lower case
response = rSys.path("/vdc/admin/authnproviders/" + resp.getId()).get(ClientResponse.class);
AuthnProviderRestRep responseRestRep = response.getEntity(AuthnProviderRestRep.class);
Assert.assertFalse(responseRestRep.getDomains().contains("sAnItY2.local"));
Assert.assertTrue(responseRestRep.getDomains().contains("sanity2.local"));
// use the added domain to create a subtenant, verify it's successful
TenantCreateParam tenantParam = new TenantCreateParam();
tenantParam.setLabel("sub2");
tenantParam.setDescription("My sub tenant 2");
UserMappingParam tenantMapping1 = new UserMappingParam();
tenantMapping1.setDomain("sAnItY2.local");
UserMappingAttributeParam attriParam = new UserMappingAttributeParam("department", Collections.singletonList("ASD"));
tenantMapping1.getAttributes().add(attriParam);
tenantParam.getUserMappings().add(tenantMapping1);
response = rSys.path("/tenants/" + rootTenantId + "/subtenants").post(ClientResponse.class, tenantParam);
Assert.assertEquals(200, response.getStatus());
}
use of com.emc.storageos.model.tenant.UserMappingParam in project coprhd-controller by CoprHD.
the class UserMappingForm method createUserMappingParam.
public UserMappingParam createUserMappingParam() {
UserMappingParam userMappingParam = new UserMappingParam();
userMappingParam.setDomain(domain);
for (String group : groups.split(LINE_BREAK)) {
if (!StringUtils.isBlank(group)) {
userMappingParam.getGroups().add(group.trim());
}
}
List<UserMappingAttributeParam> attributeParams = Lists.newArrayList();
if (!attributes.isEmpty()) {
for (AttributeMapping mapping : attributes) {
if (mapping != null) {
attributeParams.add(mapping.createAttributeParam());
}
}
}
userMappingParam.setAttributes(attributeParams);
return userMappingParam;
}
use of com.emc.storageos.model.tenant.UserMappingParam in project coprhd-controller by CoprHD.
the class TenantModificationTest method tenantAdminModifyUserMapping.
@Test
public void tenantAdminModifyUserMapping() throws Exception {
TenantUpdateParam tenantUpdateParam = new TenantUpdateParam();
UserMappingChanges changes = new UserMappingChanges();
List<UserMappingParam> listAdd = new ArrayList<UserMappingParam>();
UserMappingParam param = new UserMappingParam();
param.setDomain("Not Exist");
listAdd.add(param);
changes.setAdd(listAdd);
tenantUpdateParam.setUserMappingChanges(changes);
try {
tenantAdminClient.tenants().update(rootTenantID, tenantUpdateParam);
Assert.fail("Tenant admin should has no permission to modify tenant's user mapping");
} catch (ServiceErrorException see) {
Assert.assertEquals(see.getCode(), 3000);
Assert.assertTrue(see.getMessage().contains("Only users with SECURITY_ADMIN role can"));
}
}
Aggregations