Skip to content
This repository was archived by the owner on Dec 12, 2018. It is now read-only.

Commit f4c9efa

Browse files
author
Richard Blaylock
committed
Issue-1136 Happy path test for saml response creation.
1 parent 843d37a commit f4c9efa

2 files changed

Lines changed: 36 additions & 3 deletions

File tree

api/src/main/java/com/stormpath/sdk/saml/SamlResponse.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
import com.stormpath.sdk.resource.Resource;
44

55
/**
6-
* A SamlResponse has a single field whose value is the XML of a SAML response according to the SAML specification.
6+
* A SamlResponse has a single field whose value is the base 64 encoded XML of a SAML response according to the SAML specification.
77
*
88
* @since 1.3.0
99
*/
1010
public interface SamlResponse extends Resource {
1111

1212
/**
13-
* Returns the XML of the SAML response..
13+
* Returns the base 64 encoded XML of the SAML response..
1414
*
15-
* @return the XML of the SAML response.
15+
* @return the base 64 encoded XML of the SAML response.
1616
*/
1717
String getValue();
1818
}

extensions/httpclient/src/test/groovy/com/stormpath/sdk/impl/saml/SamlIdentityProviderIT.groovy

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package com.stormpath.sdk.impl.saml
1717

18+
import com.stormpath.sdk.account.Account
1819
import com.stormpath.sdk.application.Application
1920
import com.stormpath.sdk.application.webconfig.ApplicationWebConfig
2021
import com.stormpath.sdk.impl.ds.InternalDataStore
@@ -532,4 +533,36 @@ class SamlIdentityProviderIT extends AbstractSamlIT {
532533
registrationList = identityProvider.getSamlServiceProviderRegistrations(SamlServiceProviderRegistrations.where(SamlServiceProviderRegistrations.defaultRelayState().eq("aNotNice*")))
533534
assertEquals(registrationList.size, 0)
534535
}
536+
537+
@Test
538+
void testSamlResponse() {
539+
def identityProvider = getNewSamlIdentityProviderForNewApplication()
540+
541+
Account account = client.getAccounts().iterator().next()
542+
543+
def serviceProvider = client.instantiate(RegisteredSamlServiceProvider)
544+
serviceProvider
545+
.setName("testName")
546+
.setAssertionConsumerServiceUrl("https://some.sp.com/saml/sso/post")
547+
.setEntityId(uniquify("urn:entity:id"))
548+
.setEncodedX509SigningCert(validX509Cert)
549+
def registeredSamlServiceProvider = client.currentTenant.createRegisterdSamlServiceProvider(serviceProvider)
550+
551+
String requestId = "blargle"
552+
553+
CreateSamlResponseRequest createSamlResponseRequest = client.instantiate(CreateSamlResponseRequest.class)
554+
createSamlResponseRequest.setAccount(account)
555+
createSamlResponseRequest.setAuthnIssueInstant(new Date())
556+
createSamlResponseRequest.setRequestId(requestId)
557+
.setServiceProvider(registeredSamlServiceProvider)
558+
559+
SamlResponse samlResponse = identityProvider.createSamlResponse(createSamlResponseRequest)
560+
String base64EncodedXml = samlResponse.getValue()
561+
562+
String xml = new String(Base64.decoder.
563+
decode(base64EncodedXml))
564+
565+
assertTrue(xml.contains(account.email))
566+
assertTrue(xml.contains("InResponseTo=\"" + requestId + "\""))
567+
}
535568
}

0 commit comments

Comments
 (0)