-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathpath_creds_test.go
38 lines (34 loc) · 1.24 KB
/
path_creds_test.go
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
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package alicloud
import (
"testing"
)
func TestGenerateUsername(t *testing.T) {
result := generateUsername("displayName", "roleName")
if len(result) > 64 {
t.Fatal("too long: " + result)
}
result = generateUsername("displayNamedisplayNamedisplayNamedisplayNamedisplayNamedisplayNamedisplayNamedisplayNamedisplayNamedisplayName", "roleName")
if len(result) > 64 {
t.Fatal("too long: " + result)
}
result = generateUsername("displayName", "roleNameroleNameroleNameroleNameroleNameroleNameroleNameroleNameroleNameroleName")
if len(result) > 64 {
t.Fatal("too long: " + result)
}
}
func TestGenerateRoleSessionName(t *testing.T) {
result := generateRoleSessionName("displayName", "roleName")
if len(result) > 32 {
t.Fatalf("too long: %d, %s", len(result), result)
}
result = generateRoleSessionName("displayNamedisplayNamedisplayNamedisplayNamedisplayNamedisplayNamedisplayNamedisplayNamedisplayNamedisplayName", "roleName")
if len(result) > 32 {
t.Fatal("too long: " + result)
}
result = generateRoleSessionName("displayName", "roleNameroleNameroleNameroleNameroleNameroleNameroleNameroleNameroleNameroleName")
if len(result) > 32 {
t.Fatal("too long: " + result)
}
}