List of usage examples for org.apache.commons.lang RandomStringUtils randomAlphabetic
public static String randomAlphabetic(int count)
Creates a random string whose length is the number of characters specified.
Characters will be chosen from the set of alphabetic characters.
From source file:org.cloudfoundry.identity.uaa.mock.providers.IdentityProviderEndpointsMockMvcTests.java
private BaseClientDetails getBaseClientDetails() throws Exception { String clientId = RandomStringUtils.randomAlphabetic(6); BaseClientDetails client = new BaseClientDetails(clientId, null, "idps.read,idps.write", "password", null); client.setClientSecret("test-client-secret"); mockMvcUtils.createClient(getMockMvc(), adminToken, client); return client; }
From source file:org.cloudfoundry.identity.uaa.mock.providers.IdentityProviderEndpointsMockMvcTests.java
public String setUpAccessToken() throws Exception { String clientId = RandomStringUtils.randomAlphabetic(6); BaseClientDetails client = new BaseClientDetails(clientId, null, "idps.read,idps.write", "password", null); client.setClientSecret("test-client-secret"); mockMvcUtils.createClient(getMockMvc(), adminToken, client); ScimUser user = mockMvcUtils.createAdminForZone(getMockMvc(), adminToken, "idps.write,idps.read"); return mockMvcUtils.getUserOAuthAccessToken(getMockMvc(), client.getClientId(), client.getClientSecret(), user.getUserName(), "secr3T", "idps.read idps.write"); }
From source file:org.cloudfoundry.identity.uaa.mock.util.MockMvcUtils.java
public static ScimUser createAdminForZone(MockMvc mockMvc, String accessToken, String scopes) throws Exception { String random = RandomStringUtils.randomAlphabetic(6); ScimUser user = new ScimUser(); user.setUserName(random + "@example.com"); ScimUser.Email email = new ScimUser.Email(); email.setValue(random + "@example.com"); user.setEmails(asList(email));//from w ww .j a v a 2 s . c om user.setPassword("secr3T"); ScimUser createdUser = createUser(mockMvc, accessToken, user); for (String scope : StringUtils.commaDelimitedListToSet(scopes)) { ScimGroup group = getGroup(mockMvc, accessToken, scope); if (group == null) { group = new ScimGroup(null, scope, IdentityZoneHolder.get().getId()); group.setMembers(Arrays.asList(new ScimGroupMember(createdUser.getId()))); createGroup(mockMvc, accessToken, group); } else { List<ScimGroupMember> members = new LinkedList(group.getMembers()); members.add(new ScimGroupMember(createdUser.getId())); group.setMembers(members); updateGroup(mockMvc, accessToken, group); } } return createdUser; }
From source file:org.cloudfoundry.identity.uaa.mock.zones.IdentityProviderEndpointsMockMvcTests.java
@Test public void testRetrieveIdpInZoneWithInsufficientScopes() throws Exception { BaseClientDetails client = getBaseClientDetails(); ScimUser user = mockMvcUtils.createAdminForZone(getMockMvc(), adminToken, "idps.write"); String accessToken = mockMvcUtils.getUserOAuthAccessToken(getMockMvc(), client.getClientId(), client.getClientSecret(), user.getUserName(), "secr3T", "idps.write"); String originKey = RandomStringUtils.randomAlphabetic(6); IdentityProvider newIdp = MultitenancyFixture.identityProvider(originKey, IdentityZone.getUaa().getId()); newIdp = createIdentityProvider(null, newIdp, accessToken, status().isCreated()); MockHttpServletRequestBuilder requestBuilder = get("/identity-providers/" + newIdp.getId()) .header("Authorization", "Bearer" + adminToken).contentType(APPLICATION_JSON); getMockMvc().perform(requestBuilder).andExpect(status().isForbidden()); }
From source file:org.cloudfoundry.identity.uaa.mock.zones.IdentityProviderEndpointsMockMvcTests.java
public String setUpAccessToken() throws Exception { String clientId = RandomStringUtils.randomAlphabetic(6); BaseClientDetails client = new BaseClientDetails(clientId, null, "idps.write", "password", null); client.setClientSecret("test-client-secret"); mockMvcUtils.createClient(getMockMvc(), adminToken, client); ScimUser user = mockMvcUtils.createAdminForZone(getMockMvc(), adminToken, "idps.write"); return mockMvcUtils.getUserOAuthAccessToken(getMockMvc(), client.getClientId(), client.getClientSecret(), user.getUserName(), "secr3T", "idps.write"); }
From source file:org.cobbler.test.MockConnection.java
private String random() { return RandomStringUtils.randomAlphabetic(10); }
From source file:org.craftercms.studio.controller.services.rest.AbstractControllerTest.java
protected SecurityPermission createSecurityPermissionMock() { SecurityPermission permission = new SecurityPermission(); permission.setName(RandomStringUtils.randomAlphabetic(10)); permission.setName(RandomStringUtils.randomAlphabetic(100)); return permission; }
From source file:org.craftercms.studio.controller.services.rest.AbstractControllerTest.java
protected Item createItemMock() { Item item = new Item(); item.setContentType(RandomStringUtils.randomAlphabetic(10)); item.setDisabled(false);//from w ww . jav a2 s .c o m item.setFileName(RandomStringUtils.randomAlphanumeric(10)); item.setId(new ItemId(UUID.randomUUID().toString())); item.setLastModifiedDate(new Date()); item.setLockOwner(RandomStringUtils.randomAlphabetic(10)); item.setMimeType(RandomStringUtils.randomAlphabetic(10)); item.setPackages(new ArrayList<String>()); item.setPath(RandomStringUtils.randomAlphabetic(100)); item.setPlaceInNav(true); item.setPreviewUrl(RandomStringUtils.randomAlphabetic(100)); item.setProperties(new HashMap<String, Object>()); item.setRenderingTemplates(new ArrayList<String>()); item.setRepoId(RandomStringUtils.randomAlphabetic(10)); item.setScheduledDate(new Date()); item.setState(RandomStringUtils.randomAlphabetic(10)); item.setLabel(RandomStringUtils.randomAlphabetic(10)); return item; }
From source file:org.craftercms.studio.controller.services.rest.AbstractControllerTest.java
protected DeploymentChannel createDeploymentChannelMock() { DeploymentChannel channel = new DeploymentChannel(); channel.setId(UUID.randomUUID().toString()); channel.setName(RandomStringUtils.randomAlphabetic(10)); channel.setDisabled(false);//from ww w .j a v a 2 s .c o m channel.setHost("localhost"); channel.setPort("9191"); channel.setPublishingUrl("http://localhost:9191/publish"); channel.setPublishMetadata(false); channel.setStatusUrl("http://localhost:9191/api/1/monitoring/status"); channel.setTarget(RandomStringUtils.randomAlphabetic(10)); channel.setType(RandomStringUtils.randomAlphanumeric(10)); channel.setVersionUrl("http://localhost:9191/api/1/version"); return channel; }
From source file:org.craftercms.studio.controller.services.rest.AbstractControllerTest.java
protected Action createActionMock() { TestAction action = new TestAction(); action.setId(UUID.randomUUID().toString()); action.setName(RandomStringUtils.randomAlphabetic(10)); return action; }