MCPcopy Create free account
hub / github.com/crewjam/saml / TestArtifactResolutionRequiresHTTPS

Function TestArtifactResolutionRequiresHTTPS

service_provider_soap_https_test.go:104–129  ·  view source on GitHub ↗

The service provider resolves artifacts only at an https ArtifactResolutionService, unless AllowInsecureSOAPEndpoints is set: the ArtifactResponse carries the whole assertion.

(t *testing.T)

Source from the content-addressed store, hash-verified

102// ArtifactResolutionService, unless AllowInsecureSOAPEndpoints is set: the
103// ArtifactResponse carries the whole assertion.
104func TestArtifactResolutionRequiresHTTPS(t *testing.T) {
105 setup := func(t *testing.T) (*spcovEnv, *int) {
106 e := spcovSetup(t)
107 plain, hits := plainHTTPServer(t, e.artifactHandler(t))
108 e.sp.IDPMetadata.IDPSSODescriptors[0].ArtifactResolutionServices[0].Location = plain.URL + "/artifact"
109 e.sp.HTTPClient = plain.Client()
110 return e, hits
111 }
112
113 t.Run("refused", func(t *testing.T) {
114 e, hits := setup(t)
115 _, err := e.sp.ParseResponse(spcovArtifactRequest("the-artifact"), []string{spcovRequestID})
116 privateErr := spcovPrivateErr(t, err)
117 assert.Check(t, is.ErrorIs(privateErr, ErrInsecureSOAPEndpoint))
118 assert.Check(t, is.ErrorIs(privateErr, ErrArtifactResolution))
119 assert.Check(t, is.Equal(*hits, 0))
120 })
121 t.Run("allowed", func(t *testing.T) {
122 e, hits := setup(t)
123 e.sp.AllowInsecureSOAPEndpoints = true
124 assertion, err := e.sp.ParseResponse(spcovArtifactRequest("the-artifact"), []string{spcovRequestID})
125 assert.NilError(t, err)
126 assert.Check(t, is.Equal(assertion.Subject.NameID.Value, "alice@example.com"))
127 assert.Check(t, is.Equal(*hits, 1))
128 })
129}

Callers

nothing calls this directly

Calls 6

spcovSetupFunction · 0.85
plainHTTPServerFunction · 0.85
spcovArtifactRequestFunction · 0.85
spcovPrivateErrFunction · 0.85
artifactHandlerMethod · 0.80
ParseResponseMethod · 0.80

Tested by

no test coverage detected