-
Notifications
You must be signed in to change notification settings - Fork 47
/
partition_test.go
66 lines (47 loc) · 1.95 KB
/
partition_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
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
package appencryption
import (
"testing"
"github.com/stretchr/testify/assert"
)
func Test_NewPartition(t *testing.T) {
partition := newPartition("partid", "service", "product")
assert.NotNil(t, partition)
}
func TestDefaultPartition_SystemKeyID(t *testing.T) {
partition := newPartition("partid", "service", "product")
assert.Equal(t, "_SK_service_product", partition.SystemKeyID())
}
func TestDefaultPartition_IntermediateKeyID(t *testing.T) {
partition := newPartition("partid", "service", "product")
assert.Equal(t, "_IK_partid_service_product", partition.IntermediateKeyID())
}
func TestDefaultPartition_IsValidIntermediateKeyID(t *testing.T) {
partition := newPartition("partid", "service", "product")
assert.True(t, partition.IsValidIntermediateKeyID("_IK_partid_service_product"))
}
func Test_NewSuffixedPartition(t *testing.T) {
partition := newSuffixedPartition("partid", "service", "product", "suffix")
assert.NotNil(t, partition)
}
func TestSuffixPartition_SystemKeyID(t *testing.T) {
partition := newSuffixedPartition("partid", "service", "product", "suffix")
assert.Equal(t, "_SK_service_product_suffix", partition.SystemKeyID())
}
func TestSuffixPartition_IntermediateKeyID(t *testing.T) {
partition := newSuffixedPartition("partid", "service", "product", "suffix")
assert.Equal(t, "_IK_partid_service_product_suffix", partition.IntermediateKeyID())
}
func TestSuffixPartition_IsValidIntermediateKeyID(t *testing.T) {
partition := newSuffixedPartition("partid", "service", "product", "suffix")
assert.True(t, partition.IsValidIntermediateKeyID("_IK_partid_service_product_suffix"))
assert.True(
t,
partition.IsValidIntermediateKeyID("_IK_partid_service_product"),
"key IDs without suffixes should be valid to maintain backwards compatibility",
)
assert.True(
t,
partition.IsValidIntermediateKeyID("_IK_partid_service_product_othersuffix"),
"key IDs with differing suffixes should be valid to allow cross-region operations",
)
}