...
1 package auth
2
3 import (
4 "testing"
5
6 smithy "github.com/aws/smithy-go"
7 )
8
9 func TestV4(t *testing.T) {
10
11 propsV4 := smithy.Properties{}
12
13 propsV4.Set("authSchemes", interface{}([]interface{}{
14 map[string]interface{}{
15 "disableDoubleEncoding": true,
16 "name": "sigv4",
17 "signingName": "s3",
18 "signingRegion": "us-west-2",
19 },
20 }))
21
22 result, err := GetAuthenticationSchemes(&propsV4)
23 if err != nil {
24 t.Fatalf("Did not expect error, got %v", err)
25 }
26
27 _, ok := result[0].(AuthenticationScheme)
28 if !ok {
29 t.Fatalf("Did not get expected AuthenticationScheme. %v", result[0])
30 }
31
32 v4Scheme, ok := result[0].(*AuthenticationSchemeV4)
33 if !ok {
34 t.Fatalf("Did not get expected AuthenticationSchemeV4. %v", result[0])
35 }
36
37 if v4Scheme.Name != "sigv4" {
38 t.Fatalf("Did not get expected AuthenticationSchemeV4 signer version name")
39 }
40
41 }
42
43 func TestV4A(t *testing.T) {
44
45 propsV4A := smithy.Properties{}
46
47 propsV4A.Set("authSchemes", []interface{}{
48 map[string]interface{}{
49 "disableDoubleEncoding": true,
50 "name": "sigv4a",
51 "signingName": "s3",
52 "signingRegionSet": []string{"*"},
53 },
54 })
55
56 result, err := GetAuthenticationSchemes(&propsV4A)
57 if err != nil {
58 t.Fatalf("Did not expect error, got %v", err)
59 }
60
61 _, ok := result[0].(AuthenticationScheme)
62 if !ok {
63 t.Fatalf("Did not get expected AuthenticationScheme. %v", result[0])
64 }
65
66 v4AScheme, ok := result[0].(*AuthenticationSchemeV4A)
67 if !ok {
68 t.Fatalf("Did not get expected AuthenticationSchemeV4A. %v", result[0])
69 }
70
71 if v4AScheme.Name != "sigv4a" {
72 t.Fatalf("Did not get expected AuthenticationSchemeV4A signer version name")
73 }
74
75 }
76
77 func TestV4S3Express(t *testing.T) {
78 props := smithy.Properties{}
79 props.Set("authSchemes", []interface{}{
80 map[string]interface{}{
81 "name": SigV4S3Express,
82 "signingName": "s3",
83 "signingRegion": "us-east-1",
84 "disableDoubleEncoding": true,
85 },
86 })
87
88 result, err := GetAuthenticationSchemes(&props)
89 if err != nil {
90 t.Fatalf("Did not expect error, got %v", err)
91 }
92
93 scheme, ok := result[0].(*AuthenticationSchemeV4)
94 if !ok {
95 t.Fatalf("Did not get expected AuthenticationSchemeV4. %v", result[0])
96 }
97
98 if scheme.Name != SigV4S3Express {
99 t.Fatalf("expected %s, got %s", SigV4S3Express, scheme.Name)
100 }
101 }
102
View as plain text