-
Notifications
You must be signed in to change notification settings - Fork 19
Add tests for Config and ServiceProvider #80
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
Conversation
type Config struct { | ||
// ServiceBinding defines the mechanism that should be used | ||
// when exchanging messages between the requester (SP) and responder (IDP). | ||
ServiceBinding core.ServiceBinding |
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.
We don't really need this here. The idea in the beginning was to configure what kind of binding should be used, but that can be decided when creating the SAML AuthnRequest.
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.
Makes sense to me.
|
||
// NameIDFormat controls how the users at the IDP are mapped to | ||
// users at the SP during SSO. | ||
NameIDFormat core.NameIDFormat |
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 made this the default for the AuthnRequest and the plan is to add options to the create AuthnRequest methods later.
ValidUntil ValidUntilFunc | ||
|
||
// Certificate is used to sign SAML Authentication Requests. | ||
Certificate *tls.Certificate |
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.
As we don't plan to sign Auth request in first place I removed it for now. We can add it back when implementing that feature.
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.
Sounds good to me 👍
func NewConfig(entityID, acs, issuer, metadata *url.URL) (*Config, error) { | ||
const op = "saml.NewConfig" | ||
|
||
cfg := &Config{ | ||
EntityID: entityID, | ||
Issuer: issuer, | ||
AssertionConsumerServiceURL: acs, | ||
ValidUntil: DefaultValidUntil, |
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 left this for now. I'd make this an option later too.
As part of the tests, this commit refactors the sp.go and adds a test provider with the feature to serve a metadata xml.
// AssertionConsumerServiceURL defines the endpoint at the SP where the IDP | ||
// will redirect to with its authentication response. | ||
// will redirect to with its authentication response. (required) |
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.
Nice addition of required/optional for the godocs.
</md:EntityDescriptor> | ||
` | ||
|
||
type TestProvider struct { | 8000 tr>
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.
👍
A little late here. Thanks, @hcjulz. Looks good ✅ |
This PR adds table tests for creating new configs and cleans up a little bit of code.