(t *testing.T)
| 42 | } |
| 43 | |
| 44 | func artifactdecSetup(t *testing.T) (*spcovEnv, *artifactdecServer) { |
| 45 | t.Helper() |
| 46 | e := spcovSetup(t) |
| 47 | s := &artifactdecServer{} |
| 48 | s.srv = httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 49 | doc := etree.NewDocument() |
| 50 | if _, err := doc.ReadFrom(r.Body); err != nil { |
| 51 | http.Error(w, err.Error(), http.StatusBadRequest) |
| 52 | return |
| 53 | } |
| 54 | resolveEl := doc.FindElement("//ArtifactResolve") |
| 55 | if resolveEl == nil { |
| 56 | http.Error(w, "no ArtifactResolve", http.StatusBadRequest) |
| 57 | return |
| 58 | } |
| 59 | s.paths = append(s.paths, r.URL.Path) |
| 60 | s.artifacts = append(s.artifacts, resolveEl.FindElement("./Artifact").Text()) |
| 61 | el := e.artifactResponseEl(t, resolveEl.SelectAttrValue("ID", ""), true, nil) |
| 62 | w.Header().Set("Content-Type", "text/xml") |
| 63 | _, _ = w.Write(spcovSerialize(t, spcovSOAPEnvelope(el))) |
| 64 | })) |
| 65 | t.Cleanup(s.srv.Close) |
| 66 | e.sp.HTTPClient = s.srv.Client() |
| 67 | |
| 68 | idp := &e.sp.IDPMetadata.IDPSSODescriptors[0] |
| 69 | // The unindexed list (what IDP metadata parses into today) names a |
| 70 | // default endpoint; the indexed list names one endpoint per index. |
| 71 | idp.ArtifactResolutionServices = []Endpoint{ |
| 72 | {Binding: SOAPBinding, Location: s.srv.URL + "/default"}, |
| 73 | } |
| 74 | idp.SSODescriptor.ArtifactResolutionServices = []IndexedEndpoint{ |
| 75 | {Binding: HTTPPostBinding, Location: s.srv.URL + "/not-soap", Index: 7}, |
| 76 | {Binding: SOAPBinding, Location: s.srv.URL + "/ars0", Index: 0}, |
| 77 | {Binding: SOAPBinding, Location: s.srv.URL + "/ars7", Index: 7}, |
| 78 | } |
| 79 | return e, s |
| 80 | } |
| 81 | |
| 82 | // saml-bindings-2.0-os §3.6.4.1: the EndpointIndex of a type 0x0004 |
| 83 | // artifact identifies the artifact resolution endpoint the requester must |
no test coverage detected