@@ -25,7 +25,6 @@ import (
2525 "gotest.tools/golden"
2626
2727 "github.com/beevik/etree"
28- "github.com/golang-jwt/jwt/v4"
2928 dsig "github.com/russellhaering/goxmldsig"
3029
3130 "github.com/crewjam/saml/logger"
@@ -104,7 +103,6 @@ func NewIdentityProviderTest(t *testing.T, opts ...idpTestOpts) *IdentityProvide
104103 rv , _ := time .Parse ("Mon Jan 2 15:04:05 MST 2006" , "Mon Dec 1 01:57:09 UTC 2015" )
105104 return rv
106105 }
107- jwt .TimeFunc = TimeNow
108106 RandReader = & testRandomReader {} // TODO(ross): remove this and use the below generator
109107 xmlenc .RandReader = rand .New (rand .NewSource (0 )) //nolint:gosec // deterministic random numbers for tests
110108
@@ -485,7 +483,6 @@ func TestIDPCanValidate(t *testing.T) {
485483 "</AuthnRequest>" ),
486484 }
487485 assert .Check (t , is .Error (req .Validate (), "cannot find assertion consumer service: file does not exist" ))
488-
489486}
490487
491488func TestIDPMakeAssertion (t * testing.T ) {
@@ -592,94 +589,93 @@ func TestIDPMakeAssertion(t *testing.T) {
592589 })
593590 assert .Check (t , err )
594591
595- expectedAttributes :=
596- []Attribute {
597- {
598- FriendlyName : "uid" ,
599- Name : "urn:oid:0.9.2342.19200300.100.1.1" ,
600- NameFormat : "urn:oasis:names:tc:SAML:2.0:attrname-format:uri" ,
601- Values : []AttributeValue {
602- {
603- Type : "xs:string" ,
604- Value : "alice" ,
605- },
592+ expectedAttributes := []Attribute {
593+ {
594+ FriendlyName : "uid" ,
595+ Name : "urn:oid:0.9.2342.19200300.100.1.1" ,
596+ NameFormat : "urn:oasis:names:tc:SAML:2.0:attrname-format:uri" ,
597+ Values : []AttributeValue {
598+ {
599+ Type : "xs:string" ,
600+ Value : "alice" ,
606601 },
607602 },
608- {
609- FriendlyName : "mail" ,
610- Name : "urn:oid:0.9.2342.19200300.100.1.3 " ,
611- NameFormat : "urn:oasis:names:tc:SAML:2.0:attrname-format:uri " ,
612- Values : [] AttributeValue {
613- {
614- Type : "xs:string" ,
615- Value : "alice@example.com " ,
616- } ,
603+ },
604+ {
605+ FriendlyName : "mail " ,
606+ Name : "urn:oid:0.9.2342.19200300.100.1.3 " ,
607+ NameFormat : "urn:oasis:names:tc:SAML:2.0:attrname-format:uri" ,
608+ Values : [] AttributeValue {
609+ {
610+ Type : "xs:string " ,
611+ Value : "alice@example.com" ,
617612 },
618613 },
619- {
620- FriendlyName : "eduPersonPrincipalName" ,
621- Name : "urn:oid:1.3.6.1.4.1.5923.1.1.1.6 " ,
622- NameFormat : "urn:oasis:names:tc:SAML:2.0:attrname-format:uri " ,
623- Values : [] AttributeValue {
624- {
625- Type : "xs:string" ,
626- Value : "alice@example.com " ,
627- } ,
614+ },
615+ {
616+ FriendlyName : "eduPersonPrincipalName " ,
617+ Name : "urn:oid:1.3.6.1.4.1.5923.1.1.1.6 " ,
618+ NameFormat : "urn:oasis:names:tc:SAML:2.0:attrname-format:uri" ,
619+ Values : [] AttributeValue {
620+ {
621+ Type : "xs:string " ,
622+ Value : "alice@example.com" ,
628623 },
629624 },
630- {
631- FriendlyName : "sn" ,
632- Name : "urn:oid:2.5.4.4 " ,
633- NameFormat : "urn:oasis:names:tc:SAML:2.0:attrname-format:uri " ,
634- Values : [] AttributeValue {
635- {
636- Type : "xs:string" ,
637- Value : "Smith " ,
638- } ,
625+ },
626+ {
627+ FriendlyName : "sn " ,
628+ Name : "urn:oid:2.5.4.4 " ,
629+ NameFormat : "urn:oasis:names:tc:SAML:2.0:attrname-format:uri" ,
630+ Values : [] AttributeValue {
631+ {
632+ Type : "xs:string " ,
633+ Value : "Smith" ,
639634 },
640635 },
641- {
642- FriendlyName : "givenName" ,
643- Name : "urn:oid:2.5.4.42 " ,
644- NameFormat : "urn:oasis:names:tc:SAML:2.0:attrname-format:uri " ,
645- Values : [] AttributeValue {
646- {
647- Type : "xs:string" ,
648- Value : "Alice " ,
649- } ,
636+ },
637+ {
638+ FriendlyName : "givenName " ,
639+ Name : "urn:oid:2.5.4.42 " ,
640+ NameFormat : "urn:oasis:names:tc:SAML:2.0:attrname-format:uri" ,
641+ Values : [] AttributeValue {
642+ {
643+ Type : "xs:string " ,
644+ Value : "Alice" ,
650645 },
651646 },
652- {
653- FriendlyName : "cn" ,
654- Name : "urn:oid:2.5.4.3 " ,
655- NameFormat : "urn:oasis:names:tc:SAML:2.0:attrname-format:uri " ,
656- Values : [] AttributeValue {
657- {
658- Type : "xs:string" ,
659- Value : "Alice Smith " ,
660- } ,
647+ },
648+ {
649+ FriendlyName : "cn " ,
650+ Name : "urn:oid:2.5.4.3 " ,
651+ NameFormat : "urn:oasis:names:tc:SAML:2.0:attrname-format:uri" ,
652+ Values : [] AttributeValue {
653+ {
654+ Type : "xs:string " ,
655+ Value : "Alice Smith" ,
661656 },
662657 },
663- {
664- FriendlyName : "eduPersonAffiliation" ,
665- Name : "urn:oid:1.3.6.1.4.1.5923.1.1.1.1 " ,
666- NameFormat : "urn:oasis:names:tc:SAML:2.0:attrname-format:uri " ,
667- Values : [] AttributeValue {
668- {
669- Type : "xs:string" ,
670- Value : "Users " ,
671- } ,
672- {
673- Type : "xs:string" ,
674- Value : "Administrators " ,
675- } ,
676- {
677- Type : "xs:string" ,
678- Value : "♀ " ,
679- } ,
658+ },
659+ {
660+ FriendlyName : "eduPersonAffiliation " ,
661+ Name : "urn:oid:1.3.6.1.4.1.5923.1.1.1.1 " ,
662+ NameFormat : "urn:oasis:names:tc:SAML:2.0:attrname-format:uri" ,
663+ Values : [] AttributeValue {
664+ {
665+ Type : "xs:string " ,
666+ Value : "Users" ,
667+ },
668+ {
669+ Type : "xs:string " ,
670+ Value : "Administrators" ,
671+ },
672+ {
673+ Type : "xs:string " ,
674+ Value : "♀" ,
680675 },
681676 },
682- }
677+ },
678+ }
683679 assert .Check (t , is .DeepEqual (expectedAttributes , req .Assertion .AttributeStatements [0 ].Attributes ))
684680}
685681
@@ -1044,7 +1040,8 @@ func TestIDPRequestedAttributes(t *testing.T) {
10441040 },
10451041 },
10461042 },
1047- }}}
1043+ },
1044+ }}
10481045 assert .Check (t , is .DeepEqual (expectedAttributes , req .Assertion .AttributeStatements ))
10491046}
10501047
0 commit comments