common.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  1. /*
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. limitations under the License.
  10. */
  11. package common
  12. import (
  13. "fmt"
  14. v1 "k8s.io/api/core/v1"
  15. metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
  16. esv1alpha1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1alpha1"
  17. "github.com/external-secrets/external-secrets/e2e/framework"
  18. )
  19. // This case creates multiple secrets with simple key/value pairs and syncs them using multiple .Spec.Data blocks.
  20. // Not supported by: vault.
  21. func SimpleDataSync(f *framework.Framework) (string, func(*framework.TestCase)) {
  22. return "[common] should sync simple secrets from .Data[]", func(tc *framework.TestCase) {
  23. secretKey1 := fmt.Sprintf("%s-%s", f.Namespace.Name, "one")
  24. secretKey2 := fmt.Sprintf("%s-%s", f.Namespace.Name, "other")
  25. secretValue := "bar"
  26. tc.Secrets = map[string]string{
  27. secretKey1: secretValue,
  28. secretKey2: secretValue,
  29. }
  30. tc.ExpectedSecret = &v1.Secret{
  31. Type: v1.SecretTypeOpaque,
  32. Data: map[string][]byte{
  33. secretKey1: []byte(secretValue),
  34. secretKey2: []byte(secretValue),
  35. },
  36. }
  37. tc.ExternalSecret.Spec.Data = []esv1alpha1.ExternalSecretData{
  38. {
  39. SecretKey: secretKey1,
  40. RemoteRef: esv1alpha1.ExternalSecretDataRemoteRef{
  41. Key: secretKey1,
  42. },
  43. },
  44. {
  45. SecretKey: secretKey2,
  46. RemoteRef: esv1alpha1.ExternalSecretDataRemoteRef{
  47. Key: secretKey2,
  48. },
  49. },
  50. }
  51. }
  52. }
  53. // This case creates multiple secrets with json values and syncs them using multiple .Spec.Data blocks.
  54. // The data is extracted from the JSON key using ref.Property.
  55. func JSONDataWithProperty(f *framework.Framework) (string, func(*framework.TestCase)) {
  56. return "[common] should sync multiple secrets from .Data[]", func(tc *framework.TestCase) {
  57. secretKey1 := fmt.Sprintf("%s-%s", f.Namespace.Name, "one")
  58. secretKey2 := fmt.Sprintf("%s-%s", f.Namespace.Name, "two")
  59. secretValue1 := "{\"foo1\":\"foo1-val\",\"bar1\":\"bar1-val\"}"
  60. secretValue2 := "{\"foo2\":\"foo2-val\",\"bar2\":\"bar2-val\"}"
  61. tc.Secrets = map[string]string{
  62. secretKey1: secretValue1,
  63. secretKey2: secretValue2,
  64. }
  65. tc.ExpectedSecret = &v1.Secret{
  66. Type: v1.SecretTypeOpaque,
  67. Data: map[string][]byte{
  68. secretKey1: []byte("foo1-val"),
  69. secretKey2: []byte("bar2-val"),
  70. },
  71. }
  72. tc.ExternalSecret.Spec.Data = []esv1alpha1.ExternalSecretData{
  73. {
  74. SecretKey: secretKey1,
  75. RemoteRef: esv1alpha1.ExternalSecretDataRemoteRef{
  76. Key: secretKey1,
  77. Property: "foo1",
  78. },
  79. },
  80. {
  81. SecretKey: secretKey2,
  82. RemoteRef: esv1alpha1.ExternalSecretDataRemoteRef{
  83. Key: secretKey2,
  84. Property: "bar2",
  85. },
  86. },
  87. }
  88. }
  89. }
  90. // This case creates multiple secrets with json values and renders a template.
  91. // The data is extracted from the JSON key using ref.Property.
  92. func JSONDataWithTemplate(f *framework.Framework) (string, func(*framework.TestCase)) {
  93. return "[common] should sync json secrets with template", func(tc *framework.TestCase) {
  94. secretKey1 := fmt.Sprintf("%s-%s", f.Namespace.Name, "one")
  95. secretKey2 := fmt.Sprintf("%s-%s", f.Namespace.Name, "other")
  96. secretValue1 := "{\"foo1\":\"foo1-val\",\"bar1\":\"bar1-val\"}"
  97. secretValue2 := "{\"foo2\":\"foo2-val\",\"bar2\":\"bar2-val\"}"
  98. tc.Secrets = map[string]string{
  99. secretKey1: secretValue1,
  100. secretKey2: secretValue2,
  101. }
  102. tc.ExpectedSecret = &v1.Secret{
  103. Type: v1.SecretTypeOpaque,
  104. ObjectMeta: metav1.ObjectMeta{
  105. Annotations: map[string]string{
  106. "example": "annotation",
  107. },
  108. Labels: map[string]string{
  109. "example": "label",
  110. },
  111. },
  112. Data: map[string][]byte{
  113. "my-data": []byte(`executed: foo1-val|bar2-val`),
  114. },
  115. }
  116. tc.ExternalSecret.Spec.Target.Template = &esv1alpha1.ExternalSecretTemplate{
  117. Metadata: esv1alpha1.ExternalSecretTemplateMetadata{
  118. Annotations: map[string]string{
  119. "example": "annotation",
  120. },
  121. Labels: map[string]string{
  122. "example": "label",
  123. },
  124. },
  125. Data: map[string]string{
  126. "my-data": "executed: {{ .one | toString }}|{{ .two | toString }}",
  127. },
  128. }
  129. tc.ExternalSecret.Spec.Data = []esv1alpha1.ExternalSecretData{
  130. {
  131. SecretKey: "one",
  132. RemoteRef: esv1alpha1.ExternalSecretDataRemoteRef{
  133. Key: secretKey1,
  134. Property: "foo1",
  135. },
  136. },
  137. {
  138. SecretKey: "two",
  139. RemoteRef: esv1alpha1.ExternalSecretDataRemoteRef{
  140. Key: secretKey2,
  141. Property: "bar2",
  142. },
  143. },
  144. }
  145. }
  146. }
  147. // This case creates one secret with json values and syncs them using a single .Spec.DataFrom block.
  148. func JSONDataFromSync(f *framework.Framework) (string, func(*framework.TestCase)) {
  149. return "[common] should sync secrets with dataFrom", func(tc *framework.TestCase) {
  150. secretKey1 := fmt.Sprintf("%s-%s", f.Namespace.Name, "one")
  151. targetSecretKey1 := "name"
  152. targetSecretValue1 := "great-name"
  153. targetSecretKey2 := "surname"
  154. targetSecretValue2 := "great-surname"
  155. secretValue := fmt.Sprintf("{ \"%s\": \"%s\", \"%s\": \"%s\" }", targetSecretKey1, targetSecretValue1, targetSecretKey2, targetSecretValue2)
  156. tc.Secrets = map[string]string{
  157. secretKey1: secretValue,
  158. }
  159. tc.ExpectedSecret = &v1.Secret{
  160. Type: v1.SecretTypeOpaque,
  161. Data: map[string][]byte{
  162. targetSecretKey1: []byte(targetSecretValue1),
  163. targetSecretKey2: []byte(targetSecretValue2),
  164. },
  165. }
  166. tc.ExternalSecret.Spec.DataFrom = []esv1alpha1.ExternalSecretDataRemoteRef{
  167. {
  168. Key: secretKey1,
  169. },
  170. }
  171. }
  172. }
  173. // This case creates a secret with a nested json value. It is synced into two secrets.
  174. // The values from the nested data are extracted using gjson.
  175. // not supported by: vault.
  176. func NestedJSONWithGJSON(f *framework.Framework) (string, func(*framework.TestCase)) {
  177. return "[common] should sync nested json secrets and get inner keys", func(tc *framework.TestCase) {
  178. secretKey1 := fmt.Sprintf("%s-%s", f.Namespace.Name, "one")
  179. targetSecretKey1 := "firstname"
  180. targetSecretValue1 := "Tom"
  181. targetSecretKey2 := "first_friend"
  182. targetSecretValue2 := "Roger"
  183. secretValue := fmt.Sprintf(
  184. `{
  185. "name": {"first": "%s", "last": "Anderson"},
  186. "friends":
  187. [
  188. {"first": "Dale", "last": "Murphy"},
  189. {"first": "%s", "last": "Craig"},
  190. {"first": "Jane", "last": "Murphy"}
  191. ]
  192. }`, targetSecretValue1, targetSecretValue2)
  193. tc.Secrets = map[string]string{
  194. secretKey1: secretValue,
  195. }
  196. tc.ExpectedSecret = &v1.Secret{
  197. Type: v1.SecretTypeOpaque,
  198. Data: map[string][]byte{
  199. targetSecretKey1: []byte(targetSecretValue1),
  200. targetSecretKey2: []byte(targetSecretValue2),
  201. },
  202. }
  203. tc.ExternalSecret.Spec.Data = []esv1alpha1.ExternalSecretData{
  204. {
  205. SecretKey: targetSecretKey1,
  206. RemoteRef: esv1alpha1.ExternalSecretDataRemoteRef{
  207. Key: secretKey1,
  208. Property: "name.first",
  209. },
  210. },
  211. {
  212. SecretKey: targetSecretKey2,
  213. RemoteRef: esv1alpha1.ExternalSecretDataRemoteRef{
  214. Key: secretKey1,
  215. Property: "friends.1.first",
  216. },
  217. },
  218. }
  219. }
  220. }
  221. // This case creates a secret with a Docker json configuration value.
  222. // The values from the nested data are extracted using gjson.
  223. // not supported by: vault.
  224. func DockerJSONConfig(f *framework.Framework) (string, func(*framework.TestCase)) {
  225. return "[common] should sync docker configurated json secrets with template simple", func(tc *framework.TestCase) {
  226. cloudSecretName := fmt.Sprintf("%s-%s", f.Namespace.Name, "docker-config-example")
  227. dockerconfig := `{"auths":{"https://index.docker.io/v1/": {"auth": "c3R...zE2"}}}`
  228. cloudSecretValue := fmt.Sprintf(`{"dockerconfig": %s}`, dockerconfig)
  229. tc.Secrets = map[string]string{
  230. cloudSecretName: cloudSecretValue,
  231. }
  232. tc.ExpectedSecret = &v1.Secret{
  233. Type: v1.SecretTypeOpaque,
  234. Data: map[string][]byte{
  235. ".dockerconfigjson": []byte(dockerconfig),
  236. },
  237. }
  238. tc.ExternalSecret.Spec.Data = []esv1alpha1.ExternalSecretData{
  239. {
  240. SecretKey: "mysecret",
  241. RemoteRef: esv1alpha1.ExternalSecretDataRemoteRef{
  242. Key: cloudSecretName,
  243. Property: "dockerconfig",
  244. },
  245. },
  246. }
  247. tc.ExternalSecret.Spec.Target.Template = &esv1alpha1.ExternalSecretTemplate{
  248. Data: map[string]string{
  249. ".dockerconfigjson": "{{ .mysecret | toString }}",
  250. },
  251. }
  252. }
  253. }
  254. // This case creates a secret with a Docker json configuration value.
  255. // The values from the nested data are extracted using gjson.
  256. // Need to have a key holding dockerconfig to be supported by vault.
  257. func DataPropertyDockerconfigJSON(f *framework.Framework) (string, func(*framework.TestCase)) {
  258. return "[common] should sync docker configurated json secrets with template", func(tc *framework.TestCase) {
  259. cloudSecretName := fmt.Sprintf("%s-%s", f.Namespace.Name, "docker-config-example")
  260. dockerconfigString := `"{\"auths\":{\"https://index.docker.io/v1/\": {\"auth\": \"c3R...zE2\"}}}"`
  261. dockerconfig := `{"auths":{"https://index.docker.io/v1/": {"auth": "c3R...zE2"}}}`
  262. cloudSecretValue := fmt.Sprintf(`{"dockerconfig": %s}`, dockerconfigString)
  263. tc.Secrets = map[string]string{
  264. cloudSecretName: cloudSecretValue,
  265. }
  266. tc.ExpectedSecret = &v1.Secret{
  267. Type: v1.SecretTypeDockerConfigJson,
  268. Data: map[string][]byte{
  269. ".dockerconfigjson": []byte(dockerconfig),
  270. },
  271. }
  272. tc.ExternalSecret.Spec.Data = []esv1alpha1.ExternalSecretData{
  273. {
  274. SecretKey: "mysecret",
  275. RemoteRef: esv1alpha1.ExternalSecretDataRemoteRef{
  276. Key: cloudSecretName,
  277. Property: "dockerconfig",
  278. },
  279. },
  280. }
  281. tc.ExternalSecret.Spec.Target.Template = &esv1alpha1.ExternalSecretTemplate{
  282. Type: v1.SecretTypeDockerConfigJson,
  283. Data: map[string]string{
  284. ".dockerconfigjson": "{{ .mysecret | toString }}",
  285. },
  286. }
  287. }
  288. }
  289. // This case adds an ssh private key secret and synchronizes it.
  290. // Not supported by: vault. Json parsing error.
  291. func SSHKeySync(f *framework.Framework) (string, func(*framework.TestCase)) {
  292. return "[common] should sync ssh key secret", func(tc *framework.TestCase) {
  293. sshSecretName := fmt.Sprintf("%s-%s", f.Namespace.Name, "ssh-priv-key-example")
  294. sshSecretValue := `-----BEGIN OPENSSH PRIVATE KEY-----
  295. b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcn
  296. NhAAAAAwEAAQAAAYEAsARoZUqo6L5dd0WRjZ2QPq/kKlbjtUY1njzJ01UtdC1u1eSJFUnV
  297. K1J+9b1kEqI4lgAaItaYbpJNSgCe97z6DRxEMTUQ3VhB+X+mPfcN2/I0bYklRxh59OTJcL
  298. FsPX0oCR/5eLXz9MCmelxDX7H8XDh9hP6PThooYP60oaDt0xsZvEyo6OQ43n5FuorSg4vL
  299. aMIQYK/znhBq9kR6XKMO8mULoDa+LnhOWsAY8kJ3fowF/UsQmh6PY/w4DJaypm85+a6Sak
  300. Lpn80ur7L6nV7yTqufYqXa4hgNsJHmJ7NGKqOxT/8vcvVRqRadNLl79g9bRRavBiYt/8fy
  301. DJGxOuutcVTzYlzS593Vo95In853cT+HuK4guaWkQdTrThG7jHAi0wVueaEDCTnDkuTk2h
  302. 7PXFBkYTUwE3y+NHo1X+nTE3LhiUJ0RBr3aaj5UBYKHK1uMo1C4zZH3GMvB5K2KmXwG/oB
  303. gCcD1j5hlp6QwOzBVfXsXBF4ewtf7g3RQF8DS3mBAAAFkDc7Drc3Ow63AAAAB3NzaC1yc2
  304. EAAAGBALAEaGVKqOi+XXdFkY2dkD6v5CpW47VGNZ48ydNVLXQtbtXkiRVJ1StSfvW9ZBKi
  305. OJYAGiLWmG6STUoAnve8+g0cRDE1EN1YQfl/pj33DdvyNG2JJUcYefTkyXCxbD19KAkf+X
  306. i18/TApnpcQ1+x/Fw4fYT+j04aKGD+tKGg7dMbGbxMqOjkON5+RbqK0oOLy2jCEGCv854Q
  307. avZEelyjDvJlC6A2vi54TlrAGPJCd36MBf1LEJoej2P8OAyWsqZvOfmukmpC6Z/NLq+y+p
  308. 1e8k6rn2Kl2uIYDbCR5iezRiqjsU//L3L1UakWnTS5e/YPW0UWrwYmLf/H8gyRsTrrrXFU
  309. 82Jc0ufd1aPeSJ/Od3E/h7iuILmlpEHU604Ru4xwItMFbnmhAwk5w5Lk5Noez1xQZGE1MB
  310. N8vjR6NV/p0xNy4YlCdEQa92mo+VAWChytbjKNQuM2R9xjLweStipl8Bv6AYAnA9Y+YZae
  311. kMDswVX17FwReHsLX+4N0UBfA0t5gQAAAAMBAAEAAAGAey4agQiGvJq8fkPJYPnrgHNHkf
  312. nM0YeY7mxMMgFiFfPVpQqShLtu2yqYfxFTf1bXkuHvaIIVmwv32tokZetycspdTrJ8Yurp
  313. ANo8VREYOdx+pEleNSsD7kZOUvdXcJCt+/TMeZWcbKSF3QvEeqvsl/1Qmkorr9TOfVLCxn
  314. oA9cP5drWPX6yXv91OnwWX3UdvyphFLeT08KE8uauilkHmq+va/vxQi+TVsNzOmHu7dGw5
  315. pNFrhO/uGWLhNq4fyCn9l33vpHZdMe2h/N32MnKZgjFOWLqyHy2Cx5BDJTfXyHwjVTqGN1
  316. 8fzrC+o3OuFsR1pPugwlYUW8B9XaxPI6h+Ke6GIxacNtVvOe67GrkdYbQkyrs4/EMqbXTl
  317. /BG/JZIMuchk0Da0TKDDjBwchMjAiwjsFp/wawlL9Y0dJIG0muEuHXxjInEa7xQoisAUCf
  318. B7lasXeUPOy/Z76qFwjVvyfkiVgWygncjGL44b0rgEC81L/dTZUyvNoCM9Bn7wSbuBAAAA
  319. wQDHw6NkJCvGOYa9lt2lMou6hSudokHejOo+J9jJCJdUlMXIbHhBUzrmSh47OSkgpAo4qf
  320. iVGHvBO55pZ5pI7o4woTQxaPFM8a/5BhMWcZ2LDMqU5iov9C2Dz8yKUyQmAodNkOGacQJU
  321. MDAVBJYeBFJSu04bj2EEhEd+9rIazeqVl91qkV1uGTz4aJ360PSmLuLAFT12BYGjIBfHrS
  322. yom+1HbBoUziG4a/kzzbJGTC7U66YTjpHAMEtz4mbpU0AhNg4AAADBANgTs8yjrEkL4pcC
  323. gfUr9oR42/BVl3ZxaFQ7PAvs9m0aut7b/ZRmsSF8F2TAl0H4H9M8uUKTTOhqRtdnTtDqm9
  324. QBUIQBzA6Blb5oP+yL+Eiez4gMFd9HumFXG3JoRu/JmDE19KviHaldV47QcvG6B3p0eb5Q
  325. hgVcNsrOGyBUZA0kBmzQBwv6gUoo++ETQMH89BlljZVCiPW7F6FCrPxHp7EB5txYJ62Qpu
  326. 2U40qgb2ONiUOuiI84EYRAgmDTbboMPQAAAMEA0Inn71l7LsYv81vstbmMQz0qLvhHkBcp
  327. mMhh6tyzI0dvLZabBLTPhIT4R/0VDMJGsH5X1cEaap47XDpu0/g3mfOV6PToUfYA2Ugw7N
  328. bs23UlVH1n0zL2x0QOMHX/Fkfc3OdIuc97ZHoMeW6Nf7Ii0iH7slIpH4hPVYcGXk/bX6wt
  329. PKDc8xGEXdd4A6jnwJBifJs+UpPrHAh0c63KfjO3rryDycvmxeWRnyU1yRCUjIuH31vi+L
  330. OkcGfqTaOoz2KVAAAAFGtpYW5AREVTS1RPUC1TNFI5S1JQAQIDBAUG
  331. -----END OPENSSH PRIVATE KEY-----`
  332. tc.Secrets = map[string]string{
  333. sshSecretName: sshSecretValue,
  334. }
  335. tc.ExpectedSecret = &v1.Secret{
  336. Type: v1.SecretTypeSSHAuth,
  337. Data: map[string][]byte{
  338. "ssh-privatekey": []byte(sshSecretValue),
  339. },
  340. }
  341. tc.ExternalSecret.Spec.Data = []esv1alpha1.ExternalSecretData{
  342. {
  343. SecretKey: "mysecret",
  344. RemoteRef: esv1alpha1.ExternalSecretDataRemoteRef{
  345. Key: sshSecretName,
  346. },
  347. },
  348. }
  349. tc.ExternalSecret.Spec.Target.Template = &esv1alpha1.ExternalSecretTemplate{
  350. Type: v1.SecretTypeSSHAuth,
  351. Data: map[string]string{
  352. "ssh-privatekey": "{{ .mysecret | toString }}",
  353. },
  354. }
  355. }
  356. }
  357. // This case adds an ssh private key secret and syncs it.
  358. func SSHKeySyncDataProperty(f *framework.Framework) (string, func(*framework.TestCase)) {
  359. return "[common] should sync ssh key with provider.", func(tc *framework.TestCase) {
  360. cloudSecretName := fmt.Sprintf("%s-%s", f.Namespace.Name, "docker-config-example")
  361. SSHKey := `-----BEGIN OPENSSH PRIVATE KEY-----
  362. b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcn
  363. NhAAAAAwEAAQAAAYEAsARoZUqo6L5dd0WRjZ2QPq/kKlbjtUY1njzJ01UtdC1u1eSJFUnV
  364. K1J+9b1kEqI4lgAaItaYbpJNSgCe97z6DRxEMTUQ3VhB+X+mPfcN2/I0bYklRxh59OTJcL
  365. FsPX0oCR/5eLXz9MCmelxDX7H8XDh9hP6PThooYP60oaDt0xsZvEyo6OQ43n5FuorSg4vL
  366. aMIQYK/znhBq9kR6XKMO8mULoDa+LnhOWsAY8kJ3fowF/UsQmh6PY/w4DJaypm85+a6Sak
  367. Lpn80ur7L6nV7yTqufYqXa4hgNsJHmJ7NGKqOxT/8vcvVRqRadNLl79g9bRRavBiYt/8fy
  368. DJGxOuutcVTzYlzS593Vo95In853cT+HuK4guaWkQdTrThG7jHAi0wVueaEDCTnDkuTk2h
  369. 7PXFBkYTUwE3y+NHo1X+nTE3LhiUJ0RBr3aaj5UBYKHK1uMo1C4zZH3GMvB5K2KmXwG/oB
  370. gCcD1j5hlp6QwOzBVfXsXBF4ewtf7g3RQF8DS3mBAAAFkDc7Drc3Ow63AAAAB3NzaC1yc2
  371. EAAAGBALAEaGVKqOi+XXdFkY2dkD6v5CpW47VGNZ48ydNVLXQtbtXkiRVJ1StSfvW9ZBKi
  372. OJYAGiLWmG6STUoAnve8+g0cRDE1EN1YQfl/pj33DdvyNG2JJUcYefTkyXCxbD19KAkf+X
  373. i18/TApnpcQ1+x/Fw4fYT+j04aKGD+tKGg7dMbGbxMqOjkON5+RbqK0oOLy2jCEGCv854Q
  374. avZEelyjDvJlC6A2vi54TlrAGPJCd36MBf1LEJoej2P8OAyWsqZvOfmukmpC6Z/NLq+y+p
  375. 1e8k6rn2Kl2uIYDbCR5iezRiqjsU//L3L1UakWnTS5e/YPW0UWrwYmLf/H8gyRsTrrrXFU
  376. 82Jc0ufd1aPeSJ/Od3E/h7iuILmlpEHU604Ru4xwItMFbnmhAwk5w5Lk5Noez1xQZGE1MB
  377. N8vjR6NV/p0xNy4YlCdEQa92mo+VAWChytbjKNQuM2R9xjLweStipl8Bv6AYAnA9Y+YZae
  378. kMDswVX17FwReHsLX+4N0UBfA0t5gQAAAAMBAAEAAAGAey4agQiGvJq8fkPJYPnrgHNHkf
  379. nM0YeY7mxMMgFiFfPVpQqShLtu2yqYfxFTf1bXkuHvaIIVmwv32tokZetycspdTrJ8Yurp
  380. ANo8VREYOdx+pEleNSsD7kZOUvdXcJCt+/TMeZWcbKSF3QvEeqvsl/1Qmkorr9TOfVLCxn
  381. oA9cP5drWPX6yXv91OnwWX3UdvyphFLeT08KE8uauilkHmq+va/vxQi+TVsNzOmHu7dGw5
  382. pNFrhO/uGWLhNq4fyCn9l33vpHZdMe2h/N32MnKZgjFOWLqyHy2Cx5BDJTfXyHwjVTqGN1
  383. 8fzrC+o3OuFsR1pPugwlYUW8B9XaxPI6h+Ke6GIxacNtVvOe67GrkdYbQkyrs4/EMqbXTl
  384. /BG/JZIMuchk0Da0TKDDjBwchMjAiwjsFp/wawlL9Y0dJIG0muEuHXxjInEa7xQoisAUCf
  385. B7lasXeUPOy/Z76qFwjVvyfkiVgWygncjGL44b0rgEC81L/dTZUyvNoCM9Bn7wSbuBAAAA
  386. wQDHw6NkJCvGOYa9lt2lMou6hSudokHejOo+J9jJCJdUlMXIbHhBUzrmSh47OSkgpAo4qf
  387. iVGHvBO55pZ5pI7o4woTQxaPFM8a/5BhMWcZ2LDMqU5iov9C2Dz8yKUyQmAodNkOGacQJU
  388. MDAVBJYeBFJSu04bj2EEhEd+9rIazeqVl91qkV1uGTz4aJ360PSmLuLAFT12BYGjIBfHrS
  389. yom+1HbBoUziG4a/kzzbJGTC7U66YTjpHAMEtz4mbpU0AhNg4AAADBANgTs8yjrEkL4pcC
  390. gfUr9oR42/BVl3ZxaFQ7PAvs9m0aut7b/ZRmsSF8F2TAl0H4H9M8uUKTTOhqRtdnTtDqm9
  391. QBUIQBzA6Blb5oP+yL+Eiez4gMFd9HumFXG3JoRu/JmDE19KviHaldV47QcvG6B3p0eb5Q
  392. hgVcNsrOGyBUZA0kBmzQBwv6gUoo++ETQMH89BlljZVCiPW7F6FCrPxHp7EB5txYJ62Qpu
  393. 2U40qgb2ONiUOuiI84EYRAgmDTbboMPQAAAMEA0Inn71l7LsYv81vstbmMQz0qLvhHkBcp
  394. mMhh6tyzI0dvLZabBLTPhIT4R/0VDMJGsH5X1cEaap47XDpu0/g3mfOV6PToUfYA2Ugw7N
  395. bs23UlVH1n0zL2x0QOMHX/Fkfc3OdIuc97ZHoMeW6Nf7Ii0iH7slIpH4hPVYcGXk/bX6wt
  396. PKDc8xGEXdd4A6jnwJBifJs+UpPrHAh0c63KfjO3rryDycvmxeWRnyU1yRCUjIuH31vi+L
  397. OkcGfqTaOoz2KVAAAAFGtpYW5AREVTS1RPUC1TNFI5S1JQAQIDBAUG
  398. -----END OPENSSH PRIVATE KEY-----`
  399. cloudSecretValue := fmt.Sprintf(`{"ssh-auth": "%s"}`, SSHKey)
  400. tc.Secrets = map[string]string{
  401. cloudSecretName: cloudSecretValue,
  402. }
  403. tc.ExpectedSecret = &v1.Secret{
  404. Type: v1.SecretTypeSSHAuth,
  405. Data: map[string][]byte{
  406. "ssh-privatekey": []byte(SSHKey),
  407. },
  408. }
  409. tc.ExternalSecret.Spec.Data = []esv1alpha1.ExternalSecretData{
  410. {
  411. SecretKey: "mysecret",
  412. RemoteRef: esv1alpha1.ExternalSecretDataRemoteRef{
  413. Key: cloudSecretName,
  414. Property: "ssh-auth",
  415. },
  416. },
  417. }
  418. tc.ExternalSecret.Spec.Target.Template = &esv1alpha1.ExternalSecretTemplate{
  419. Type: v1.SecretTypeSSHAuth,
  420. Data: map[string]string{
  421. "ssh-privatekey": "{{ .mysecret | toString }}",
  422. },
  423. }
  424. }
  425. }