MCPcopy Index your code
hub / github.com/getsops/sops / TestMasterKeyFromRecipient

Function TestMasterKeyFromRecipient

age/keysource_test.go:110–148  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

108}
109
110func TestMasterKeyFromRecipient(t *testing.T) {
111 t.Run("recipient", func(t *testing.T) {
112 got, err := MasterKeyFromRecipient(mockRecipient)
113 assert.NoError(t, err)
114 assert.EqualValues(t, mockRecipient, got.Recipient)
115 assert.NotNil(t, got.parsedRecipient)
116 assert.Nil(t, got.parsedIdentities)
117 })
118
119 t.Run("recipient-ssh", func(t *testing.T) {
120 got, err := MasterKeyFromRecipient(mockSshRecipient)
121 assert.NoError(t, err)
122 assert.EqualValues(t, mockSshRecipient, got.Recipient)
123 assert.NotNil(t, got.parsedRecipient)
124 assert.Nil(t, got.parsedIdentities)
125 })
126
127 t.Run("leading and trailing spaces", func(t *testing.T) {
128 got, err := MasterKeyFromRecipient(" " + mockRecipient + " ")
129 assert.NoError(t, err)
130 assert.EqualValues(t, mockRecipient, got.Recipient)
131 assert.NotNil(t, got.parsedRecipient)
132 assert.Nil(t, got.parsedIdentities)
133 })
134
135 t.Run("leading and trailing spaces - ssh", func(t *testing.T) {
136 got, err := MasterKeyFromRecipient(" " + mockSshRecipient + " ")
137 assert.NoError(t, err)
138 assert.EqualValues(t, mockSshRecipient, got.Recipient)
139 assert.NotNil(t, got.parsedRecipient)
140 assert.Nil(t, got.parsedIdentities)
141 })
142
143 t.Run("invalid recipient", func(t *testing.T) {
144 got, err := MasterKeyFromRecipient("invalid")
145 assert.Error(t, err)
146 assert.Nil(t, got)
147 })
148}
149
150func TestParsedIdentities_Import(t *testing.T) {
151 i := make(ParsedIdentities, 0)

Callers

nothing calls this directly

Calls 2

MasterKeyFromRecipientFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected