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

Function TestEncryptedSuffix

sops_test.go:110–160  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

108}
109
110func TestEncryptedSuffix(t *testing.T) {
111 branches := TreeBranches{
112 TreeBranch{
113 TreeItem{
114 Key: "foo_encrypted",
115 Value: "bar",
116 },
117 TreeItem{
118 Key: "bar",
119 Value: TreeBranch{
120 TreeItem{
121 Key: "foo",
122 Value: "bar",
123 },
124 },
125 },
126 },
127 }
128 tree := Tree{Branches: branches, Metadata: Metadata{EncryptedSuffix: "_encrypted"}}
129 expected := TreeBranch{
130 TreeItem{
131 Key: "foo_encrypted",
132 Value: "rab",
133 },
134 TreeItem{
135 Key: "bar",
136 Value: TreeBranch{
137 TreeItem{
138 Key: "foo",
139 Value: "bar",
140 },
141 },
142 },
143 }
144 cipher := reverseCipher{}
145 _, err := tree.Encrypt(bytes.Repeat([]byte("f"), 32), cipher)
146 if err != nil {
147 t.Errorf("Encrypting the tree failed: %s", err)
148 }
149 if !reflect.DeepEqual(tree.Branches[0], expected) {
150 t.Errorf("Trees don't match: \ngot \t\t%+v,\n expected \t\t%+v", tree.Branches[0], expected)
151 }
152 _, err = tree.Decrypt(bytes.Repeat([]byte("f"), 32), cipher)
153 if err != nil {
154 t.Errorf("Decrypting the tree failed: %s", err)
155 }
156 expected[0].Value = "bar"
157 if !reflect.DeepEqual(tree.Branches[0], expected) {
158 t.Errorf("Trees don't match: \ngot\t\t\t%+v,\nexpected\t\t%+v", tree.Branches[0], expected)
159 }
160}
161
162func TestEncryptedRegex(t *testing.T) {
163 branches := TreeBranches{

Callers

nothing calls this directly

Calls 2

EncryptMethod · 0.95
DecryptMethod · 0.95

Tested by

no test coverage detected