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

Function TestSOAPLogoutRequestRequiresHTTPS

service_provider_soap_https_test.go:28–66  ·  view source on GitHub ↗

The service provider sends SOAP LogoutRequests only to an https SingleLogoutService, unless AllowInsecureSOAPEndpoints is set.

(t *testing.T)

Source from the content-addressed store, hash-verified

26// The service provider sends SOAP LogoutRequests only to an https
27// SingleLogoutService, unless AllowInsecureSOAPEndpoints is set.
28func TestSOAPLogoutRequestRequiresHTTPS(t *testing.T) {
29 setup := func(t *testing.T) (*spcovEnv, *int) {
30 e := spcovSetup(t)
31 s := newSOAPLogoutIDPServer(t, e)
32 s.respond = func(req *LogoutRequest) []byte { return e.idpSOAPLogoutResponse(t, req, true, nil) }
33 plain, hits := plainHTTPServer(t, s.Config.Handler)
34 slos := e.sp.IDPMetadata.IDPSSODescriptors[0].SingleLogoutServices
35 slos[len(slos)-1].Location = plain.URL
36 e.sp.HTTPClient = plain.Client()
37 return e, hits
38 }
39
40 t.Run("make refuses http", func(t *testing.T) {
41 e, hits := setup(t)
42 _, err := e.sp.MakeSOAPLogoutRequest(NameID{Value: "alice"})
43 assert.Check(t, is.ErrorIs(err, ErrInsecureSOAPEndpoint))
44 assert.Check(t, is.Equal(*hits, 0))
45 })
46 t.Run("send refuses http", func(t *testing.T) {
47 e, hits := setup(t)
48 e.sp.AllowInsecureSOAPEndpoints = true
49 req, err := e.sp.MakeSOAPLogoutRequest(NameID{Value: "alice"})
50 assert.NilError(t, err)
51 e.sp.AllowInsecureSOAPEndpoints = false
52 _, err = e.sp.SendSOAPLogoutRequest(context.Background(), req)
53 assert.Check(t, is.ErrorIs(err, ErrInsecureSOAPEndpoint))
54 assert.Check(t, is.Equal(*hits, 0))
55 })
56 t.Run("allowed", func(t *testing.T) {
57 e, hits := setup(t)
58 e.sp.AllowInsecureSOAPEndpoints = true
59 req, err := e.sp.MakeSOAPLogoutRequest(NameID{Value: "alice"})
60 assert.NilError(t, err)
61 resp, err := e.sp.SendSOAPLogoutRequest(context.Background(), req)
62 assert.NilError(t, err)
63 assert.Check(t, is.Equal(resp.InResponseTo, req.ID))
64 assert.Check(t, is.Equal(*hits, 1))
65 })
66}
67
68// The service provider sends attribute queries only to an https
69// AttributeService, unless AllowInsecureSOAPEndpoints is set.

Callers

nothing calls this directly

Calls 6

spcovSetupFunction · 0.85
newSOAPLogoutIDPServerFunction · 0.85
plainHTTPServerFunction · 0.85
idpSOAPLogoutResponseMethod · 0.80
MakeSOAPLogoutRequestMethod · 0.80
SendSOAPLogoutRequestMethod · 0.80

Tested by

no test coverage detected