aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/aws/aws-sdk-go-v2/internal/auth/scheme_test.go
blob: 49fc3c94be28d37853b1b911814a3e6b3fe059b9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package auth

import (
	"testing"

	smithy "github.com/aws/smithy-go"
)

func TestV4(t *testing.T) {

	propsV4 := smithy.Properties{}

	propsV4.Set("authSchemes", interface{}([]interface{}{
		map[string]interface{}{
			"disableDoubleEncoding": true,
			"name":                  "sigv4",
			"signingName":           "s3",
			"signingRegion":         "us-west-2",
		},
	}))

	result, err := GetAuthenticationSchemes(&propsV4)
	if err != nil {
		t.Fatalf("Did not expect error, got %v", err)
	}

	_, ok := result[0].(AuthenticationScheme)
	if !ok {
		t.Fatalf("Did not get expected AuthenticationScheme. %v", result[0])
	}

	v4Scheme, ok := result[0].(*AuthenticationSchemeV4)
	if !ok {
		t.Fatalf("Did not get expected AuthenticationSchemeV4. %v", result[0])
	}

	if v4Scheme.Name != "sigv4" {
		t.Fatalf("Did not get expected AuthenticationSchemeV4 signer version name")
	}

}

func TestV4A(t *testing.T) {

	propsV4A := smithy.Properties{}

	propsV4A.Set("authSchemes", []interface{}{
		map[string]interface{}{
			"disableDoubleEncoding": true,
			"name":                  "sigv4a",
			"signingName":           "s3",
			"signingRegionSet":      []string{"*"},
		},
	})

	result, err := GetAuthenticationSchemes(&propsV4A)
	if err != nil {
		t.Fatalf("Did not expect error, got %v", err)
	}

	_, ok := result[0].(AuthenticationScheme)
	if !ok {
		t.Fatalf("Did not get expected AuthenticationScheme. %v", result[0])
	}

	v4AScheme, ok := result[0].(*AuthenticationSchemeV4A)
	if !ok {
		t.Fatalf("Did not get expected AuthenticationSchemeV4A. %v", result[0])
	}

	if v4AScheme.Name != "sigv4a" {
		t.Fatalf("Did not get expected AuthenticationSchemeV4A signer version name")
	}

}