MCPcopy
hub / github.com/getsops/sops / TestMasterKeysFromURLs

Function TestMasterKeysFromURLs

azkv/keysource_test.go:54–138  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

52}
53
54func TestMasterKeysFromURLs(t *testing.T) {
55 tests := []struct {
56 name string
57 urls string
58 expectErr bool
59 expectKeyCount int
60 expectKeys []MasterKey
61 }{
62 {
63 name: "single URL",
64 urls: "https://test.vault.azure.net/keys/test-key/a2a690a4fcc04166b739da342a912c90",
65 expectKeyCount: 1,
66 expectKeys: []MasterKey{
67 {
68 VaultURL: "https://test.vault.azure.net",
69 Name: "test-key",
70 Version: "a2a690a4fcc04166b739da342a912c90",
71 },
72 },
73 },
74 {
75 name: "multiple URLs",
76 urls: "https://test.vault.azure.net/keys/test-key/a2a690a4fcc04166b739da342a912c90,https://test2.vault.azure.net/keys/another-test-key/cf0021e8b743453bae758e7fbf71b60e",
77 expectKeyCount: 2,
78 expectKeys: []MasterKey{
79 {
80 VaultURL: "https://test.vault.azure.net",
81 Name: "test-key",
82 Version: "a2a690a4fcc04166b739da342a912c90",
83 },
84 {
85 VaultURL: "https://test2.vault.azure.net",
86 Name: "another-test-key",
87 Version: "cf0021e8b743453bae758e7fbf71b60e",
88 },
89 },
90 },
91 {
92 name: "multiple URLs with leading and trailing spaces",
93 urls: " https://test.vault.azure.net/keys/test-key/a2a690a4fcc04166b739da342a912c90 , https://test2.vault.azure.net/keys/another-test-key/cf0021e8b743453bae758e7fbf71b60e ",
94 expectKeyCount: 2,
95 expectKeys: []MasterKey{
96 {
97 VaultURL: "https://test.vault.azure.net",
98 Name: "test-key",
99 Version: "a2a690a4fcc04166b739da342a912c90",
100 },
101 {
102 VaultURL: "https://test2.vault.azure.net",
103 Name: "another-test-key",
104 Version: "cf0021e8b743453bae758e7fbf71b60e",
105 },
106 },
107 },
108 {
109 name: "multiple URLs, one malformed",
110 urls: "https://test.vault.azure.net/keys/test-key/a2a690a4fcc04166b739da342a912c90,https://test.vault.azure.net/no-keys-here/test-key/a2a690a4fcc04166b739da342a912c90",
111 expectErr: true,

Callers

nothing calls this directly

Calls 3

MasterKeysFromURLsFunction · 0.85
LenMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected