github.com/greenpau/go-authcrunch@v1.1.4/pkg/kms/methods_test.go (about) 1 // Copyright 2022 Paul Greenberg greenpau@outlook.com 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package kms 16 17 import ( 18 "github.com/greenpau/go-authcrunch/internal/tests" 19 "testing" 20 ) 21 22 func TestGetSigningMethodAlias(t *testing.T) { 23 var testcases = []struct { 24 name string 25 input string 26 want string 27 }{ 28 {name: "HS256", want: "hmac"}, 29 {name: "HS384", want: "hmac"}, 30 {name: "HS512", want: "hmac"}, 31 {name: "RS256", want: "rsa"}, 32 {name: "RS384", want: "rsa"}, 33 {name: "RS512", want: "rsa"}, 34 {name: "ES256", want: "ecdsa"}, 35 {name: "ES384", want: "ecdsa"}, 36 {name: "ES512", want: "ecdsa"}, 37 {name: "TBD", want: "unknown"}, 38 } 39 for _, tc := range testcases { 40 t.Run(tc.name, func(t *testing.T) { 41 var input, want, got string 42 input = tc.input 43 if input == "" { 44 input = tc.name 45 } 46 want = tc.want 47 if want == "" { 48 want = input 49 } 50 got = getSigningMethodAlias(input) 51 tests.EvalObjects(t, "output", want, got) 52 }) 53 } 54 }