testprovider

package
v0.0.0-...-c041881 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 3, 2024 License: MPL-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const ResponseSigned = `` /* 4524-byte string literal not displayed */

From https://www.samltool.com/generic_sso_res.php

Variables

This section is empty.

Functions

This section is empty.

Types

type ResponseOption

type ResponseOption func(*responseOptions)

func WithResponseExpired

func WithResponseExpired() ResponseOption

func WithResponseSigned

func WithResponseSigned() ResponseOption

type SAMLResponsePostData

type SAMLResponsePostData struct {
	SAMLResponse string `json:"saml_response"`
	RelayState   string `json:"relay_state"`
	Destination  string `json:"destination"`
}

SAMLResponsePostData represents the SAML response data that is expected in the form data of a POST request.

func (*SAMLResponsePostData) PostRequest

func (s *SAMLResponsePostData) PostRequest(t *testing.T) *http.Request

PostRequest creates an http POST request with the SAML response and relay state included as form data.

type TestProvider

type TestProvider struct {
	// contains filtered or unexported fields
}

TestProvider is an identity provider that can be used for testing SAML federeation and authentication flows.

func StartTestProvider

func StartTestProvider(t *testing.T) *TestProvider

StartTestProvider starts a new identity provider for testing. The metadata XML is served at the "/saml/metadata" path. The server URL can be obtained by calling the ServerURL() method.

The metadata XML contains the HTTP-Post and Redirect sign-on endpoints. The sign-on endpoints will validate the incoming requests on their correctness. The SAMLResponse, RelayState, and Destination URL will be returned in a JSON file, that can be unmarshalled into testprovider.SAMLResponsePostData.

func (*TestProvider) Close

func (p *TestProvider) Close()

Close shut downs the server and waits for all requests to complete.

func (*TestProvider) ExpectedInvalidRequestID

func (p *TestProvider) ExpectedInvalidRequestID()

ExpectInvalidRequestID expects that the ID isn't XSD:ID conform.

func (*TestProvider) SamlResponse

func (p *TestProvider) SamlResponse(t *testing.T, opts ...ResponseOption) string

func (*TestProvider) ServerURL

func (p *TestProvider) ServerURL() string

ServerURL returns the test server URL.

func (*TestProvider) SetExpectedACSURL

func (p *TestProvider) SetExpectedACSURL(acs string)

SetExpectedACSURL sets the in the SAML request expected assertion consumer service URL.

func (*TestProvider) SetExpectedBase64EncodedSAMLRequest

func (p *TestProvider) SetExpectedBase64EncodedSAMLRequest(sr string)

SetExpectedSAMLRequest sets the expected SAML request.

func (*TestProvider) SetExpectedIssueInstant

func (p *TestProvider) SetExpectedIssueInstant(ii time.Time)

SetExpectedACSURL sets the in the SAML request expected issue instant value.

func (*TestProvider) SetExpectedIssuer

func (p *TestProvider) SetExpectedIssuer(sr string)

SetExpectedIssuer sets the in the SAML request expected issuer value.

func (*TestProvider) SetExpectedProtocolBinding

func (p *TestProvider) SetExpectedProtocolBinding(pb string)

SetExpectedProtocolBinding sets the in the SAML request expected protocol binding. Defaults to the HTTP-POST binding.

func (*TestProvider) SetExpectedRelayState

func (p *TestProvider) SetExpectedRelayState(rs string)

SetExpectedRelayState sets the expected RelayState value.

func (*TestProvider) SetExpectedRequestID

func (p *TestProvider) SetExpectedRequestID(id string)

SetExpectedRequestID sets the in the SAML request expected request ID.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL