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

Function TestUnencryptedSuffix

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

Source from the content-addressed store, hash-verified

57}
58
59func TestUnencryptedSuffix(t *testing.T) {
60 branches := TreeBranches{
61 TreeBranch{
62 TreeItem{
63 Key: "foo_unencrypted",
64 Value: "bar",
65 },
66 TreeItem{
67 Key: "bar_unencrypted",
68 Value: TreeBranch{
69 TreeItem{
70 Key: "foo",
71 Value: "bar",
72 },
73 },
74 },
75 },
76 }
77 tree := Tree{Branches: branches, Metadata: Metadata{UnencryptedSuffix: "_unencrypted"}}
78 expected := TreeBranch{
79 TreeItem{
80 Key: "foo_unencrypted",
81 Value: "bar",
82 },
83 TreeItem{
84 Key: "bar_unencrypted",
85 Value: TreeBranch{
86 TreeItem{
87 Key: "foo",
88 Value: "bar",
89 },
90 },
91 },
92 }
93 cipher := reverseCipher{}
94 _, err := tree.Encrypt(bytes.Repeat([]byte("f"), 32), cipher)
95 if err != nil {
96 t.Errorf("Encrypting the tree failed: %s", err)
97 }
98 if !reflect.DeepEqual(tree.Branches[0], expected) {
99 t.Errorf("Trees don't match: \ngot \t\t%+v,\n expected \t\t%+v", tree.Branches[0], expected)
100 }
101 _, err = tree.Decrypt(bytes.Repeat([]byte("f"), 32), cipher)
102 if err != nil {
103 t.Errorf("Decrypting the tree failed: %s", err)
104 }
105 if !reflect.DeepEqual(tree.Branches[0], expected) {
106 t.Errorf("Trees don't match: \ngot\t\t\t%+v,\nexpected\t\t%+v", tree.Branches[0], expected)
107 }
108}
109
110func TestEncryptedSuffix(t *testing.T) {
111 branches := TreeBranches{

Callers

nothing calls this directly

Calls 2

EncryptMethod · 0.95
DecryptMethod · 0.95

Tested by

no test coverage detected