Skip to content

Commit

Permalink
Provide Doc sample curl for SAML provider metadata url
Browse files Browse the repository at this point in the history
[#138172103] https://www.pivotaltracker.com/story/show/138172103
Signed-off-by: Bharath Sekar <bharath.sekar@ge.com>
  • Loading branch information
6palace committed Aug 11, 2017
1 parent 66f3672 commit a5caca9
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
4 changes: 4 additions & 0 deletions uaa/slateCustomizations/source/index.html.md.erb
Expand Up @@ -763,6 +763,10 @@ _Error Codes_
<%= ERB.new(File.read("../../build/generated-snippets/IdentityProviderEndpointsDocs/createSAMLIdentityProvider/http-request.md")).result(binding) %> <%= ERB.new(File.read("../../build/generated-snippets/IdentityProviderEndpointsDocs/createSAMLIdentityProvider/http-request.md")).result(binding) %>
<%= ERB.new(File.read("../../build/generated-snippets/IdentityProviderEndpointsDocs/createSAMLIdentityProvider/http-response.md")).result(binding) %> <%= ERB.new(File.read("../../build/generated-snippets/IdentityProviderEndpointsDocs/createSAMLIdentityProvider/http-response.md")).result(binding) %>
<%= ERB.new(File.read("../../build/generated-snippets/IdentityProviderEndpointsDocs/createSAMLIdentityProviderMetadataUrl/curl-request.md")).result(binding) %>
<%= ERB.new(File.read("../../build/generated-snippets/IdentityProviderEndpointsDocs/createSAMLIdentityProviderMetadataUrl/http-request.md")).result(binding) %>
<%= ERB.new(File.read("../../build/generated-snippets/IdentityProviderEndpointsDocs/createSAMLIdentityProviderMetadataUrl/http-response.md")).result(binding) %>

_Request Headers_ _Request Headers_


<%= ERB.new(File.read("../../build/generated-snippets/IdentityProviderEndpointsDocs/createSAMLIdentityProvider/request-headers.md")).result(binding) %> <%= ERB.new(File.read("../../build/generated-snippets/IdentityProviderEndpointsDocs/createSAMLIdentityProvider/request-headers.md")).result(binding) %>
Expand Down
Expand Up @@ -394,14 +394,42 @@ public void createSAMLIdentityProvider() throws Exception {
fieldWithPath("config.zoneId").type(STRING).description("This will be set to the ID of the zone where the provider is being created") fieldWithPath("config.zoneId").type(STRING).description("This will be set to the ID of the zone where the provider is being created")
})); }));


ResultActions resultActions = getMockMvc().perform(post("/identity-providers") ResultActions resultActionsMetadata = getMockMvc().perform(post("/identity-providers")
.param("rawConfig", "true") .param("rawConfig", "true")
.header("Authorization", "Bearer " + adminToken) .header("Authorization", "Bearer " + adminToken)
.contentType(APPLICATION_JSON) .contentType(APPLICATION_JSON)
.content(serializeExcludingProperties(identityProvider, "id", "version", "created", "last_modified", "identityZoneId", "config.zoneId", "config.idpEntityAlias", "config.additionalConfiguration"))) .content(serializeExcludingProperties(identityProvider, "id", "version", "created", "last_modified", "identityZoneId", "config.zoneId", "config.idpEntityAlias", "config.additionalConfiguration")))
.andExpect(status().isCreated()); .andExpect(status().isCreated());


resultActions.andDo(document("{ClassName}/{methodName}", resultActionsMetadata.andDo(document("{ClassName}/{methodName}",
preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint()),
requestHeaders(
headerWithName("Authorization").description("Bearer token containing `zones.<zone id>.admin` or `uaa.admin` or `idps.write` (only in the same zone that you are a user of)"),
headerWithName("X-Identity-Zone-Id").description("May include this header to administer another zone if using `zones.<zone id>.admin` or `uaa.admin` scope against the default UAA zone.").optional()
),
commonRequestParams,
requestFields,
responseFields
));

SamlIdentityProviderDefinition providerDefinition = new SamlIdentityProviderDefinition()
.setMetaDataLocation("http://simplesamlphp.cfapps.io/saml2/idp/metadata.php")
.setNameID("urn:oasis:names:tc:SAML:1.1:nameid-format:transient")
.setLinkText("IDPEndpointsMockTests Saml Provider:" + identityProvider.getOriginKey())
.setZoneId(IdentityZone.getUaa().getId());

identityProvider.setConfig(providerDefinition);
identityProvider.setOriginKey(identityProvider.getOriginKey() + "MetadataUrl");

ResultActions resultActionsUrl = getMockMvc().perform(post("/identity-providers")
.param("rawConfig", "true")
.header("Authorization", "Bearer " + adminToken)
.contentType(APPLICATION_JSON)
.content(serializeExcludingProperties(identityProvider, "id", "version", "created", "last_modified", "identityZoneId", "config.zoneId", "config.idpEntityAlias", "config.additionalConfiguration")))
.andExpect(status().isCreated());

resultActionsUrl.andDo(document("{ClassName}/{methodName}MetadataUrl",
preprocessRequest(prettyPrint()), preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint()), preprocessResponse(prettyPrint()),
requestHeaders( requestHeaders(
Expand Down

0 comments on commit a5caca9

Please sign in to comment.