The service provider sends attribute queries only to an https AttributeService, unless AllowInsecureSOAPEndpoints is set.
(t *testing.T)
| 68 | // The service provider sends attribute queries only to an https |
| 69 | // AttributeService, unless AllowInsecureSOAPEndpoints is set. |
| 70 | func 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 |
nothing calls this directly
no test coverage detected