mirror of
https://github.com/slsa-framework/slsa-verifier.git
synced 2026-08-20 12:06:25 +00:00
This PR updates go to 1.23.1 and updates golanci-lint to v1.61.1, while fixing new lint errors. --------- Signed-off-by: Ramon Petgrave <ramon.petgrave64@gmail.com> Signed-off-by: Ramon Petgrave <32398091+ramonpetgrave64@users.noreply.github.com>
55 lines
1.0 KiB
Go
55 lines
1.0 KiB
Go
package utils
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/google/go-cmp/cmp"
|
|
"github.com/google/go-cmp/cmp/cmpopts"
|
|
|
|
serrors "github.com/slsa-framework/slsa-verifier/v2/errors"
|
|
)
|
|
|
|
func Test_DecodeSignature(t *testing.T) {
|
|
t.Parallel()
|
|
tests := []struct {
|
|
name string
|
|
encoded string
|
|
decoded string
|
|
expected error
|
|
}{
|
|
{
|
|
name: "std encoding",
|
|
encoded: "YWJjMTIzIT8kKiYoKSctPUB+",
|
|
decoded: "abc123!?$*&()'-=@~",
|
|
},
|
|
{
|
|
name: "URL encoding",
|
|
encoded: "YWJjMTIzIT8kKiYoKSctPUB-",
|
|
decoded: "abc123!?$*&()'-=@~",
|
|
},
|
|
{
|
|
name: "invalid",
|
|
encoded: "invalid encoding",
|
|
expected: serrors.ErrorInvalidEncoding,
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
c, err := DecodeSignature(tt.encoded)
|
|
if !cmp.Equal(err, tt.expected, cmpopts.EquateErrors()) {
|
|
t.Error(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
|
|
}
|
|
if err != nil {
|
|
return
|
|
}
|
|
cs := string(c)
|
|
if cs != tt.decoded {
|
|
t.Error(cmp.Diff(cs, tt.decoded))
|
|
}
|
|
})
|
|
}
|
|
}
|