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

Function TestJWTSessionCodec_CryptoSignerEncodeDecode

samlsp/middleware_test.go:784–883  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

782}
783
784func TestJWTSessionCodec_CryptoSignerEncodeDecode(t *testing.T) {
785 tests := []struct {
786 name string
787 method jwt.SigningMethod
788 genKey func(t *testing.T) crypto.Signer
789 subject string
790 }{
791 {
792 name: "ECDSA-P256",
793 method: jwt.SigningMethodES256,
794 genKey: func(t *testing.T) crypto.Signer {
795 k, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
796 assert.Check(t, err)
797 return k
798 },
799 subject: "test-ecdsa-p256",
800 },
801 {
802 name: "ECDSA-P384",
803 method: jwt.SigningMethodES384,
804 genKey: func(t *testing.T) crypto.Signer {
805 k, err := ecdsa.GenerateKey(elliptic.P384(), rand.Reader)
806 assert.Check(t, err)
807 return k
808 },
809 subject: "test-ecdsa-p384",
810 },
811 {
812 name: "ECDSA-P521",
813 method: jwt.SigningMethodES512,
814 genKey: func(t *testing.T) crypto.Signer {
815 k, err := ecdsa.GenerateKey(elliptic.P521(), rand.Reader)
816 assert.Check(t, err)
817 return k
818 },
819 subject: "test-ecdsa-p521",
820 },
821 {
822 name: "RSA-PSS",
823 method: jwt.SigningMethodPS256,
824 genKey: func(t *testing.T) crypto.Signer {
825 k, err := rsa.GenerateKey(rand.Reader, 2048)
826 assert.Check(t, err)
827 return k
828 },
829 subject: "test-rsa-pss",
830 },
831 {
832 name: "EdDSA",
833 method: jwt.SigningMethodEdDSA,
834 genKey: func(t *testing.T) crypto.Signer {
835 _, k, err := ed25519.GenerateKey(rand.Reader)
836 assert.Check(t, err)
837 return k
838 },
839 subject: "test-eddsa",
840 },
841 }

Callers

nothing calls this directly

Calls 2

EncodeMethod · 0.95
DecodeMethod · 0.95

Tested by

no test coverage detected