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

Function TestAttributeQueryRequiresHTTPS

service_provider_soap_https_test.go:70–99  ·  view source on GitHub ↗

The service provider sends attribute queries only to an https AttributeService, unless AllowInsecureSOAPEndpoints is set.

(t *testing.T)

Source from the content-addressed store, hash-verified

68// The service provider sends attribute queries only to an https
69// AttributeService, unless AllowInsecureSOAPEndpoints is set.
70func TestAttributeQueryRequiresHTTPS(t *testing.T) {
71 setup := func(t *testing.T) (*spcovEnv, *int) {
72 e := aqSetup(t)
73 s := newAQServer(t, e)
74 s.respond = func(query *AttributeQuery) []byte {
75 return e.aqSOAP(t, query, aqOptions{signAssertion: true})
76 }
77 plain, hits := plainHTTPServer(t, s.Config.Handler)
78 e.sp.IDPMetadata.AttributeAuthorityDescriptors[0].AttributeServices[0].Location = plain.URL
79 e.sp.HTTPClient = plain.Client()
80 return e, hits
81 }
82
83 t.Run("refused", func(t *testing.T) {
84 e, hits := setup(t)
85 _, err := e.sp.MakeAttributeQuery(aqNameID)
86 assert.Check(t, is.ErrorIs(err, ErrInsecureSOAPEndpoint))
87 _, err = e.sp.QueryAttributes(context.Background(), aqNameID)
88 assert.Check(t, is.ErrorIs(err, ErrInsecureSOAPEndpoint))
89 assert.Check(t, is.Equal(*hits, 0))
90 })
91 t.Run("allowed", func(t *testing.T) {
92 e, hits := setup(t)
93 e.sp.AllowInsecureSOAPEndpoints = true
94 result, err := e.sp.QueryAttributes(context.Background(), aqNameID)
95 assert.NilError(t, err)
96 assert.Check(t, len(result.Attributes) > 0)
97 assert.Check(t, is.Equal(*hits, 1))
98 })
99}
100
101// The service provider resolves artifacts only at an https
102// ArtifactResolutionService, unless AllowInsecureSOAPEndpoints is set: the

Callers

nothing calls this directly

Calls 6

aqSetupFunction · 0.85
newAQServerFunction · 0.85
plainHTTPServerFunction · 0.85
aqSOAPMethod · 0.80
MakeAttributeQueryMethod · 0.80
QueryAttributesMethod · 0.45

Tested by

no test coverage detected