-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ezatti
committed
Mar 3, 2022
1 parent
f3ce2c5
commit 47d971e
Showing
3 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package spidsaml | ||
|
||
import ( | ||
"github.com/beevik/etree" | ||
"testing" | ||
) | ||
|
||
func TestMetadata(t *testing.T) { | ||
sp := createSP() | ||
doc := etree.NewDocument() | ||
if doc.ReadFromString(sp.Metadata()) != nil { | ||
panic("error occurred during parsing metadata file") | ||
} | ||
|
||
testCases := []struct { | ||
name string | ||
entityPath string | ||
entityValue []string | ||
}{ | ||
{ | ||
name: "Organization name", | ||
entityPath: "/EntityDescriptor/Organization/OrganizationName", | ||
entityValue: []string{"Foobar"}, | ||
}, | ||
{ | ||
name: "Organization display name", | ||
entityPath: "/EntityDescriptor/Organization/OrganizationDisplayName", | ||
entityValue: []string{"Foobar"}, | ||
}, | ||
{ | ||
name: "Organization URL", | ||
entityPath: "/EntityDescriptor/Organization/OrganizationURL", | ||
entityValue: []string{"https://www.foobar.it/"}, | ||
}, | ||
} | ||
for _, tc := range testCases { | ||
t.Run(tc.name, func(t *testing.T) { | ||
for _, e := range doc.FindElements(tc.entityPath) { | ||
if !contains(tc.entityValue, e.Text()) { | ||
t.Fail() | ||
} | ||
} | ||
}) | ||
} | ||
} | ||
|
||
func createSP() *SP { | ||
return &SP{ | ||
EntityID: "https://www.foobar.it/", | ||
KeyFile: "test/resources/sp.key", | ||
CertFile: "test/resources/sp.pem", | ||
AssertionConsumerServices: []string{ | ||
"http://localhost:8000/spid-sso", | ||
}, | ||
SingleLogoutServices: map[string]SAMLBinding{ | ||
"http://localhost:8000/spid-slo": HTTPRedirect, | ||
}, | ||
AttributeConsumingServices: []AttributeConsumingService{ | ||
{ | ||
ServiceName: "Service 1", | ||
Attributes: []string{"fiscalNumber", "name", "familyName", "dateOfBirth"}, | ||
}, | ||
}, | ||
Organization: Organization{ | ||
Names: []string{"Foobar"}, | ||
DisplayNames: []string{"Foobar"}, | ||
URLs: []string{"https://www.foobar.it/"}, | ||
}, | ||
} | ||
} | ||
|
||
func contains(array []string, value string) bool { | ||
for _, el := range array { | ||
if el == value { | ||
return true | ||
} | ||
} | ||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
-----BEGIN RSA PRIVATE KEY----- | ||
MIIEogIBAAKCAQEAo4i2HsG/+Qm3qe0gqwEOh4wlBYK181WCn3RTuyFNQh6mdn6p | ||
Ldv/dYXY22zER2ufY227FFto3vqtSdT306lpIoVuXKBAVoWwcrzO0dadM4dyHX7K | ||
RmWSDT51GBqkP6Hj1UoUywbXp5q9GXP5uVL8U93caT11VZaalHhEjKxtSYJHDP7Z | ||
P/2k9p54JgVIonMF0DJVhx0smPZ3QdHX+my/JNevsnuXTZIyyu0KjcXlflKSldng | ||
VDjv9D6cGE4wGOa5Vz5M+z4tjKnJtfj/xacIWcj/4Ukuu6CDyQ8+YNCaE9YjitRm | ||
di5ZqTDOoGKonmlbhCcfqPeRvGwfWXJcVR+qUwIDAQABAoIBAEHEFRnBaWbJ1abs | ||
yhp7TlCMt8bDjlDRrrpZmeLDvcI9eUxmG7tpog6tSUzVLQpb6bmew4GoUUB7J31t | ||
vEzO8I0FhCCUAcvJ7+/0pmgVGxtB+U6LUuWEq3vQBl8vN6avgGSiakJL+iZZQHsf | ||
/OneycMgkidwo+NLsdbLlyXLohfRPA0eXJejKptV+8ylu0fdqxFBRlxOuHi8Rbhf | ||
nCSHG1o1eGAmLkhXgLNdVQ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file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIICljCCAX4CCQDP2/0y0d0/dzANBgkqhkiG9w0BAQsFADANMQswCQYDVQQGEwJJ | ||
VDAeFw0xODA2MjgwOTM2MDRaFw0xOTA2MjgwOTM2MDRaMA0xCzAJBgNVBAYTAklU | ||
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAo4i2HsG/+Qm3qe0gqwEO | ||
h4wlBYK181WCn3RTuyFNQh6mdn6pLdv/dYXY22zER2ufY227FFto3vqtSdT306lp | ||
IoVuXKBAVoWwcrzO0dadM4dyHX7KRmWSDT51GBqkP6Hj1UoUywbXp5q9GXP5uVL8 | ||
U93caT11VZaalHhEjKxtSYJHDP7ZP/2k9p54JgVIonMF0DJVhx0smPZ3QdHX+my/ | ||
JNevsnuXTZIyyu0KjcXlflKSldngVDjv9D6cGE4wGOa5Vz5M+z4tjKnJtfj/xacI | ||
Wcj/4Ukuu6CDyQ8+YNCaE9YjitRmdi5ZqTDOoGKonmlbhCcfqPeRvGwfWXJcVR+q | ||
UwIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQBVO9pGMnJ3X5D6ny/32TM4fvFesdRB | ||
tSTnivkdssvn4o8u6570XZIpz2AFQ9eltREbobAqYuWrXIr+1x5aACsReFSjusSM | ||
Nb9dUCwZbpcId53WQdGikXVkLwgRw9LfYSr73EfeUIIc9R5HCbR5p2piDzw9cNpR | ||
9wGhhL64g1zhy7O7bdWCXZ4cg9in9N2fCMTjdNpUvG4ZiToRdUqvuMDF4gsQJOwV | ||
wmN6BxQFloyODpdf1XoTk9dEqPqFO5B8h+DY/26JV8QYUPKzGUJkr24GxjFj5dly | ||
d8++oQDBEz0WVC0uRl5nGj+MDAO0DmHNeaS05gWQpp/KpykPzKyQw7cg | ||
-----END CERTIFICATE----- |