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

Function TestArtifactDecodingEndpointIndex

artifact_decoding_test.go:85–130  ·  view source on GitHub ↗

saml-bindings-2.0-os §3.6.4.1: the EndpointIndex of a type 0x0004 artifact identifies the artifact resolution endpoint the requester must use, and §3.6.5.2 has the requester send its ArtifactResolve there.

(t *testing.T)

Source from the content-addressed store, hash-verified

83// artifact identifies the artifact resolution endpoint the requester must
84// use, and §3.6.5.2 has the requester send its ArtifactResolve there.
85func TestArtifactDecodingEndpointIndex(t *testing.T) {
86 e, s := artifactdecSetup(t)
87
88 t.Run("index names an indexed SOAP endpoint", func(t *testing.T) {
89 s.paths = nil
90 artifact := artifactdecMake(7, artifactdecIDPSourceID(), 0x01)
91 assertion, err := e.sp.ParseResponse(spcovArtifactRequest(artifact), []string{spcovRequestID})
92 assert.NilError(t, err)
93 assert.Check(t, is.Equal("alice@example.com", assertion.Subject.NameID.Value))
94 assert.Check(t, is.DeepEqual([]string{"/ars7"}, s.paths))
95 assert.Check(t, is.Equal(artifact, s.artifacts[len(s.artifacts)-1]))
96 })
97
98 t.Run("index zero", func(t *testing.T) {
99 s.paths = nil
100 _, err := e.sp.ParseResponse(spcovArtifactRequest(artifactdecMake(0, artifactdecIDPSourceID(), 0x02)), []string{spcovRequestID})
101 assert.NilError(t, err)
102 assert.Check(t, is.DeepEqual([]string{"/ars0"}, s.paths))
103 })
104
105 t.Run("no endpoint has the index: first SOAP endpoint", func(t *testing.T) {
106 s.paths = nil
107 _, err := e.sp.ParseResponse(spcovArtifactRequest(artifactdecMake(9, artifactdecIDPSourceID(), 0x03)), []string{spcovRequestID})
108 assert.NilError(t, err)
109 assert.Check(t, is.DeepEqual([]string{"/default"}, s.paths))
110 })
111
112 t.Run("non-standard artifact: first SOAP endpoint", func(t *testing.T) {
113 s.paths = nil
114 _, err := e.sp.ParseResponse(spcovArtifactRequest("the-artifact"), []string{spcovRequestID})
115 assert.NilError(t, err)
116 assert.Check(t, is.DeepEqual([]string{"/default"}, s.paths))
117 })
118
119 t.Run("only indexed endpoints, no index match: first indexed SOAP endpoint", func(t *testing.T) {
120 s.paths = nil
121 sp := *e.sp
122 md := *sp.IDPMetadata
123 md.IDPSSODescriptors = append([]IDPSSODescriptor(nil), md.IDPSSODescriptors...)
124 md.IDPSSODescriptors[0].ArtifactResolutionServices = nil
125 sp.IDPMetadata = &md
126 _, err := sp.ParseResponse(spcovArtifactRequest(artifactdecMake(9, artifactdecIDPSourceID(), 0x04)), []string{spcovRequestID})
127 assert.NilError(t, err)
128 assert.Check(t, is.DeepEqual([]string{"/ars0"}, s.paths))
129 })
130}
131
132// By default, artifacts that are not type 0x0004 artifacts of this IdP are
133// still sent to the IdP unchanged, as before; with RequireStandardArtifacts

Callers

nothing calls this directly

Calls 5

artifactdecSetupFunction · 0.85
artifactdecMakeFunction · 0.85
artifactdecIDPSourceIDFunction · 0.85
spcovArtifactRequestFunction · 0.85
ParseResponseMethod · 0.80

Tested by

no test coverage detected