8000 Add tests for Config and ServiceProvider by hcjulz · Pull Request #80 · hashicorp/cap · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Dismiss alert

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

Merged
merged 4 commits into from
Aug 7, 2023

Conversation

hcjulz
Copy link
Collaborator
@hcjulz hcjulz commented Aug 3, 2023

This PR adds table tests for creating new configs and cleans up a little bit of code.

type Config struct {
// ServiceBinding defines the mechanism that should be used
// when exchanging messages between the requester (SP) and responder (IDP).
ServiceBinding core.ServiceBinding
Copy link
Collaborator Author

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.

Copy link
Contributor

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
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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.

Copy link
Contributor

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,
Copy link
Collaborator Author

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.
@hcjulz hcjulz changed the title Add test for config generation Add tests for Config and ServiceProvider Aug 6, 2023
@hcjulz hcjulz merged commit e191c39 into saml-lib Aug 7, 2023
@hcjulz hcjulz deleted the saml-lib-impl-config-tests branch August 7, 2023 07:06
// 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)
Copy link
Contributor

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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@austingebauer
Copy link
Contributor

A little late here. Thanks, @hcjulz. Looks good ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0