forked from crewjam/saml
-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add SessionIndex to LogoutRequest if it's available #38
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -375,6 +375,19 @@ func TestSPFailToProduceSignedRequestWithBogusSignatureMethod(t *testing.T) { | |
} | ||
|
||
func TestSPCanProducePostLogoutRequest(t *testing.T) { | ||
testCases := []struct { | ||
name string | ||
sessionIndex string | ||
}{ | ||
{ | ||
name: "TestSPCanProducePostLogoutRequest_NoSessionIndex", | ||
}, | ||
{ | ||
name: "TestSPCanProducePostLogoutRequest_SessionIndex", | ||
sessionIndex: "session-123", | ||
}, | ||
} | ||
|
||
test := NewServiceProviderTest(t) | ||
TimeNow = func() time.Time { | ||
rv, _ := time.Parse("Mon Jan 2 15:04:05 UTC 2006", "Mon Dec 1 01:31:21 UTC 2015") | ||
|
@@ -390,12 +403,30 @@ func TestSPCanProducePostLogoutRequest(t *testing.T) { | |
err := xml.Unmarshal(test.IDPMetadata, &s.IDPMetadata) | ||
assert.Check(t, err) | ||
|
||
form, err := s.MakePostLogoutRequest("[email protected]", "relayState") | ||
assert.Check(t, err) | ||
golden.Assert(t, string(form), t.Name()+"_form") | ||
for _, tc := range testCases { | ||
t.Run(tc.name, func(t *testing.T) { | ||
RandReader = &testRandomReader{} | ||
form, err := s.MakePostLogoutRequest("[email protected]", "relayState", tc.sessionIndex) | ||
assert.Check(t, err) | ||
golden.Assert(t, string(form), tc.name+"_form") | ||
}) | ||
} | ||
} | ||
|
||
func TestSPCanProduceRedirectLogoutRequest(t *testing.T) { | ||
testCases := []struct { | ||
name string | ||
sessionIndex string | ||
}{ | ||
{ | ||
name: "TestSPCanProduceRedirectLogoutRequest_NoSessionIndex", | ||
}, | ||
{ | ||
name: "TestSPCanProduceRedirectLogoutRequest_SessionIndex", | ||
sessionIndex: "session-123", | ||
}, | ||
} | ||
|
||
test := NewServiceProviderTest(t) | ||
TimeNow = func() time.Time { | ||
rv, _ := time.Parse("Mon Jan 2 15:04:05.999999999 UTC 2006", "Mon Dec 1 01:31:21.123456789 UTC 2015") | ||
|
@@ -412,16 +443,22 @@ func TestSPCanProduceRedirectLogoutRequest(t *testing.T) { | |
err := xml.Unmarshal(test.IDPMetadata, &s.IDPMetadata) | ||
assert.Check(t, err) | ||
|
||
redirectURL, err := s.MakeRedirectLogoutRequest("[email protected]", "relayState") | ||
assert.Check(t, err) | ||
for _, tc := range testCases { | ||
t.Run(tc.name, func(t *testing.T) { | ||
RandReader = &testRandomReader{} | ||
|
||
decodedRequest, err := testsaml.ParseRedirectRequest(redirectURL) | ||
assert.Check(t, err) | ||
assert.Check(t, is.Equal("idp.testshib.org", | ||
redirectURL.Host)) | ||
assert.Check(t, is.Equal("/idp/profile/SAML2/Redirect/SLO", | ||
redirectURL.Path)) | ||
golden.Assert(t, string(decodedRequest), t.Name()+"_decodedRequest") | ||
redirectURL, err := s.MakeRedirectLogoutRequest("[email protected]", "relayState", tc.sessionIndex) | ||
assert.Check(t, err) | ||
|
||
decodedRequest, err := testsaml.ParseRedirectRequest(redirectURL) | ||
assert.Check(t, err) | ||
assert.Check(t, is.Equal("idp.testshib.org", | ||
redirectURL.Host)) | ||
assert.Check(t, is.Equal("/idp/profile/SAML2/Redirect/SLO", | ||
redirectURL.Path)) | ||
golden.Assert(t, string(decodedRequest), tc.name+"_decodedRequest") | ||
}) | ||
} | ||
} | ||
|
||
func TestSPCanProducePostLogoutResponse(t *testing.T) { | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<form method="post" action="https://idp.testshib.org/idp/profile/SAML2/POST/SLO" id="SAMLRequestForm"><input type="hidden" name="SAMLRequest" value="PHNhbWxwOkxvZ291dFJlcXVlc3QgeG1sbnM6c2FtbD0idXJuOm9hc2lzOm5hbWVzOnRjOlNBTUw6Mi4wOmFzc2VydGlvbiIgeG1sbnM6c2FtbHA9InVybjpvYXNpczpuYW1lczp0YzpTQU1MOjIuMDpwcm90b2NvbCIgSUQ9ImlkLTAwMDIwNDA2MDgwYTBjMGUxMDEyMTQxNjE4MWExYzFlMjAyMjI0MjYiIFZlcnNpb249IjIuMCIgSXNzdWVJbnN0YW50PSIyMDE1LTEyLTAxVDAxOjMxOjIxWiIgRGVzdGluYXRpb249Imh0dHBzOi8vaWRwLnRlc3RzaGliLm9yZy9pZHAvcHJvZmlsZS9TQU1MMi9QT1NUL1NMTyI+PHNhbWw6SXNzdWVyIEZvcm1hdD0idXJuOm9hc2lzOm5hbWVzOnRjOlNBTUw6Mi4wOm5hbWVpZC1mb3JtYXQ6ZW50aXR5Ij5odHRwczovLzE1NjYxNDQ0Lm5ncm9rLmlvL3NhbWwyL21ldGFkYXRhPC9zYW1sOklzc3Vlcj48c2FtbDpOYW1lSUQgTmFtZVF1YWxpZmllcj0iaHR0cHM6Ly9pZHAudGVzdHNoaWIub3JnL2lkcC9zaGliYm9sZXRoIiBTUE5hbWVRdWFsaWZpZXI9Imh0dHBzOi8vMTU2NjE0NDQubmdyb2suaW8vc2FtbDIvbWV0YWRhdGEiIEZvcm1hdD0idXJuOm9hc2lzOm5hbWVzOnRjOlNBTUw6Mi4wOm5hbWVpZC1mb3JtYXQ6dHJhbnNpZW50Ij5yb3NAb2N0b2xhYnMuaW88L3NhbWw6TmFtZUlEPjxzYW1scDpTZXNzaW9uSW5kZXggeG1sbnM6c2FtbHA9InVybjpvYXNpczpuYW1lczp0YzpTQU1MOjIuMDpwcm90b2NvbCI+c2Vzc2lvbi0xMjM8L3NhbWxwOlNlc3Npb25JbmRleD48L3NhbWxwOkxvZ291dFJlcXVlc3Q+" /><input type="hidden" name="RelayState" value="relayState" /><input id="SAMLSubmitButton" type="submit" value="Submit" /></form><script>document.getElementById('SAMLSubmitButton').style.visibility="hidden";document.getElementById('SAMLRequestForm').submit();</script> |
File renamed without changes.
1 change: 1 addition & 0 deletions
1
testdata/TestSPCanProduceRedirectLogoutRequest_SessionIndex_decodedRequest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<samlp:LogoutRequest xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" ID="id-00020406080a0c0e10121416181a1c1e20222426" Version="2.0" IssueInstant="2015-12-01T01:31:21.123Z" Destination="https://idp.testshib.org/idp/profile/SAML2/Redirect/SLO"><saml:Issuer Format="urn:oasis:names:tc:SAML:2.0:nameid-format:entity">https://15661444.ngrok.io/saml2/metadata</saml:Issuer><saml:NameID NameQualifier="https://idp.testshib.org/idp/shibboleth" SPNameQualifier="https://15661444.ngrok.io/saml2/metadata" Format="urn:oasis:names:tc:SAML:2.0:nameid-format:transient">[email protected]</saml:NameID><samlp:SessionIndex xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol">session-123</samlp:SessionIndex></samlp:LogoutRequest> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we get rid of the conditional statement? Can we get the same results if
req.SessionIndex
isnil
vs""
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I enclosed it in the if statement, because
req.SessionIndex
is a pointer and if that'snil
then the xml marshaller skips the field. If I would instantiate SessionIndex regardless of thesessionIndex
value then the SessionIndex would be marshalled to xml with an empty value in case of emptysessionIndex
and that would change the current behaviour.