common.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  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 a secret with empty target name to test if it defaults to external secret name.
  54. // Not supported by: vault.
  55. func SyncWithoutTargetName(f *framework.Framework) (string, func(*framework.TestCase)) {
  56. return "[common] should sync with empty target name.", func(tc *framework.TestCase) {
  57. secretKey1 := fmt.Sprintf("%s-%s", f.Namespace.Name, "one")
  58. secretValue := "bar"
  59. tc.Secrets = map[string]string{
  60. secretKey1: secretValue,
  61. }
  62. tc.ExpectedSecret = &v1.Secret{
  63. Type: v1.SecretTypeOpaque,
  64. Data: map[string][]byte{
  65. secretKey1: []byte(secretValue),
  66. },
  67. }
  68. tc.ExternalSecret.Spec.Target.Name = ""
  69. tc.ExternalSecret.Spec.Data = []esv1alpha1.ExternalSecretData{
  70. {
  71. SecretKey: secretKey1,
  72. RemoteRef: esv1alpha1.ExternalSecretDataRemoteRef{
  73. Key: secretKey1,
  74. },
  75. },
  76. }
  77. }
  78. }
  79. // This case creates multiple secrets with json values and syncs them using multiple .Spec.Data blocks.
  80. // The data is extracted from the JSON key using ref.Property.
  81. func JSONDataWithProperty(f *framework.Framework) (string, func(*framework.TestCase)) {
  82. return "[common] should sync multiple secrets from .Data[]", func(tc *framework.TestCase) {
  83. secretKey1 := fmt.Sprintf("%s-%s", f.Namespace.Name, "one")
  84. secretKey2 := fmt.Sprintf("%s-%s", f.Namespace.Name, "two")
  85. secretValue1 := "{\"foo1\":\"foo1-val\",\"bar1\":\"bar1-val\"}"
  86. secretValue2 := "{\"foo2\":\"foo2-val\",\"bar2\":\"bar2-val\"}"
  87. tc.Secrets = map[string]string{
  88. secretKey1: secretValue1,
  89. secretKey2: secretValue2,
  90. }
  91. tc.ExpectedSecret = &v1.Secret{
  92. Type: v1.SecretTypeOpaque,
  93. Data: map[string][]byte{
  94. secretKey1: []byte("foo1-val"),
  95. secretKey2: []byte("bar2-val"),
  96. },
  97. }
  98. tc.ExternalSecret.Spec.Data = []esv1alpha1.ExternalSecretData{
  99. {
  100. SecretKey: secretKey1,
  101. RemoteRef: esv1alpha1.ExternalSecretDataRemoteRef{
  102. Key: secretKey1,
  103. Property: "foo1",
  104. },
  105. },
  106. {
  107. SecretKey: secretKey2,
  108. RemoteRef: esv1alpha1.ExternalSecretDataRemoteRef{
  109. Key: secretKey2,
  110. Property: "bar2",
  111. },
  112. },
  113. }
  114. }
  115. }
  116. // This case creates a secret with empty target name to test if it defaults to external secret name.
  117. // The data is extracted from the JSON key using ref.Property.
  118. func JSONDataWithoutTargetName(f *framework.Framework) (string, func(*framework.TestCase)) {
  119. return "[common] should sync with empty target name, using json.", func(tc *framework.TestCase) {
  120. secretKey := fmt.Sprintf("%s-%s", f.Namespace.Name, "one")
  121. secretValue := "{\"foo\":\"foo-val\",\"bar\":\"bar-val\"}"
  122. tc.Secrets = map[string]string{
  123. secretKey: secretValue,
  124. }
  125. tc.ExpectedSecret = &v1.Secret{
  126. Type: v1.SecretTypeOpaque,
  127. Data: map[string][]byte{
  128. secretKey: []byte("foo-val"),
  129. },
  130. }
  131. tc.ExternalSecret.Spec.Target.Name = ""
  132. tc.ExternalSecret.Spec.Data = []esv1alpha1.ExternalSecretData{
  133. {
  134. SecretKey: secretKey,
  135. RemoteRef: esv1alpha1.ExternalSecretDataRemoteRef{
  136. Key: secretKey,
  137. Property: "foo",
  138. },
  139. },
  140. }
  141. }
  142. }
  143. // This case creates multiple secrets with json values and renders a template.
  144. // The data is extracted from the JSON key using ref.Property.
  145. func JSONDataWithTemplate(f *framework.Framework) (string, func(*framework.TestCase)) {
  146. return "[common] should sync json secrets with template", func(tc *framework.TestCase) {
  147. secretKey1 := fmt.Sprintf("%s-%s", f.Namespace.Name, "one")
  148. secretKey2 := fmt.Sprintf("%s-%s", f.Namespace.Name, "other")
  149. secretValue1 := "{\"foo1\":\"foo1-val\",\"bar1\":\"bar1-val\"}"
  150. secretValue2 := "{\"foo2\":\"foo2-val\",\"bar2\":\"bar2-val\"}"
  151. tc.Secrets = map[string]string{
  152. secretKey1: secretValue1,
  153. secretKey2: secretValue2,
  154. }
  155. tc.ExpectedSecret = &v1.Secret{
  156. Type: v1.SecretTypeOpaque,
  157. ObjectMeta: metav1.ObjectMeta{
  158. Annotations: map[string]string{
  159. "example": "annotation",
  160. },
  161. Labels: map[string]string{
  162. "example": "label",
  163. },
  164. },
  165. Data: map[string][]byte{
  166. "my-data": []byte(`executed: foo1-val|bar2-val`),
  167. },
  168. }
  169. tc.ExternalSecret.Spec.Target.Template = &esv1alpha1.ExternalSecretTemplate{
  170. Metadata: esv1alpha1.ExternalSecretTemplateMetadata{
  171. Annotations: map[string]string{
  172. "example": "annotation",
  173. },
  174. Labels: map[string]string{
  175. "example": "label",
  176. },
  177. },
  178. Data: map[string]string{
  179. "my-data": "executed: {{ .one | toString }}|{{ .two | toString }}",
  180. },
  181. }
  182. tc.ExternalSecret.Spec.Data = []esv1alpha1.ExternalSecretData{
  183. {
  184. SecretKey: "one",
  185. RemoteRef: esv1alpha1.ExternalSecretDataRemoteRef{
  186. Key: secretKey1,
  187. Property: "foo1",
  188. },
  189. },
  190. {
  191. SecretKey: "two",
  192. RemoteRef: esv1alpha1.ExternalSecretDataRemoteRef{
  193. Key: secretKey2,
  194. Property: "bar2",
  195. },
  196. },
  197. }
  198. }
  199. }
  200. // This case creates one secret with json values and syncs them using a single .Spec.DataFrom block.
  201. func JSONDataFromSync(f *framework.Framework) (string, func(*framework.TestCase)) {
  202. return "[common] should sync secrets with dataFrom", func(tc *framework.TestCase) {
  203. secretKey1 := fmt.Sprintf("%s-%s", f.Namespace.Name, "one")
  204. targetSecretKey1 := "name"
  205. targetSecretValue1 := "great-name"
  206. targetSecretKey2 := "surname"
  207. targetSecretValue2 := "great-surname"
  208. secretValue := fmt.Sprintf("{ \"%s\": \"%s\", \"%s\": \"%s\" }", targetSecretKey1, targetSecretValue1, targetSecretKey2, targetSecretValue2)
  209. tc.Secrets = map[string]string{
  210. secretKey1: secretValue,
  211. }
  212. tc.ExpectedSecret = &v1.Secret{
  213. Type: v1.SecretTypeOpaque,
  214. Data: map[string][]byte{
  215. targetSecretKey1: []byte(targetSecretValue1),
  216. targetSecretKey2: []byte(targetSecretValue2),
  217. },
  218. }
  219. tc.ExternalSecret.Spec.DataFrom = []esv1alpha1.ExternalSecretDataRemoteRef{
  220. {
  221. Key: secretKey1,
  222. },
  223. }
  224. }
  225. }
  226. // This case creates a secret with a nested json value. It is synced into two secrets.
  227. // The values from the nested data are extracted using gjson.
  228. // not supported by: vault.
  229. func NestedJSONWithGJSON(f *framework.Framework) (string, func(*framework.TestCase)) {
  230. return "[common] should sync nested json secrets and get inner keys", func(tc *framework.TestCase) {
  231. secretKey1 := fmt.Sprintf("%s-%s", f.Namespace.Name, "one")
  232. targetSecretKey1 := "firstname"
  233. targetSecretValue1 := "Tom"
  234. targetSecretKey2 := "first_friend"
  235. targetSecretValue2 := "Roger"
  236. secretValue := fmt.Sprintf(
  237. `{
  238. "name": {"first": "%s", "last": "Anderson"},
  239. "friends":
  240. [
  241. {"first": "Dale", "last": "Murphy"},
  242. {"first": "%s", "last": "Craig"},
  243. {"first": "Jane", "last": "Murphy"}
  244. ]
  245. }`, targetSecretValue1, targetSecretValue2)
  246. tc.Secrets = map[string]string{
  247. secretKey1: secretValue,
  248. }
  249. tc.ExpectedSecret = &v1.Secret{
  250. Type: v1.SecretTypeOpaque,
  251. Data: map[string][]byte{
  252. targetSecretKey1: []byte(targetSecretValue1),
  253. targetSecretKey2: []byte(targetSecretValue2),
  254. },
  255. }
  256. tc.ExternalSecret.Spec.Data = []esv1alpha1.ExternalSecretData{
  257. {
  258. SecretKey: targetSecretKey1,
  259. RemoteRef: esv1alpha1.ExternalSecretDataRemoteRef{
  260. Key: secretKey1,
  261. Property: "name.first",
  262. },
  263. },
  264. {
  265. SecretKey: targetSecretKey2,
  266. RemoteRef: esv1alpha1.ExternalSecretDataRemoteRef{
  267. Key: secretKey1,
  268. Property: "friends.1.first",
  269. },
  270. },
  271. }
  272. }
  273. }
  274. // This case creates a secret with a Docker json configuration value.
  275. // The values from the nested data are extracted using gjson.
  276. // not supported by: vault.
  277. func DockerJSONConfig(f *framework.Framework) (string, func(*framework.TestCase)) {
  278. return "[common] should sync docker configurated json secrets with template simple", func(tc *framework.TestCase) {
  279. cloudSecretName := fmt.Sprintf("%s-%s", f.Namespace.Name, "docker-config-example")
  280. dockerconfig := `{"auths":{"https://index.docker.io/v1/": {"auth": "c3R...zE2"}}}`
  281. cloudSecretValue := fmt.Sprintf(`{"dockerconfig": %s}`, dockerconfig)
  282. tc.Secrets = map[string]string{
  283. cloudSecretName: cloudSecretValue,
  284. }
  285. tc.ExpectedSecret = &v1.Secret{
  286. Type: v1.SecretTypeOpaque,
  287. Data: map[string][]byte{
  288. ".dockerconfigjson": []byte(dockerconfig),
  289. },
  290. }
  291. tc.ExternalSecret.Spec.Data = []esv1alpha1.ExternalSecretData{
  292. {
  293. SecretKey: "mysecret",
  294. RemoteRef: esv1alpha1.ExternalSecretDataRemoteRef{
  295. Key: cloudSecretName,
  296. Property: "dockerconfig",
  297. },
  298. },
  299. }
  300. tc.ExternalSecret.Spec.Target.Template = &esv1alpha1.ExternalSecretTemplate{
  301. Data: map[string]string{
  302. ".dockerconfigjson": "{{ .mysecret | toString }}",
  303. },
  304. }
  305. }
  306. }
  307. // This case creates a secret with a Docker json configuration value.
  308. // The values from the nested data are extracted using gjson.
  309. // Need to have a key holding dockerconfig to be supported by vault.
  310. func DataPropertyDockerconfigJSON(f *framework.Framework) (string, func(*framework.TestCase)) {
  311. return "[common] should sync docker configurated json secrets with template", func(tc *framework.TestCase) {
  312. cloudSecretName := fmt.Sprintf("%s-%s", f.Namespace.Name, "docker-config-example")
  313. dockerconfigString := `"{\"auths\":{\"https://index.docker.io/v1/\": {\"auth\": \"c3R...zE2\"}}}"`
  314. dockerconfig := `{"auths":{"https://index.docker.io/v1/": {"auth": "c3R...zE2"}}}`
  315. cloudSecretValue := fmt.Sprintf(`{"dockerconfig": %s}`, dockerconfigString)
  316. tc.Secrets = map[string]string{
  317. cloudSecretName: cloudSecretValue,
  318. }
  319. tc.ExpectedSecret = &v1.Secret{
  320. Type: v1.SecretTypeDockerConfigJson,
  321. Data: map[string][]byte{
  322. ".dockerconfigjson": []byte(dockerconfig),
  323. },
  324. }
  325. tc.ExternalSecret.Spec.Data = []esv1alpha1.ExternalSecretData{
  326. {
  327. SecretKey: "mysecret",
  328. RemoteRef: esv1alpha1.ExternalSecretDataRemoteRef{
  329. Key: cloudSecretName,
  330. Property: "dockerconfig",
  331. },
  332. },
  333. }
  334. tc.ExternalSecret.Spec.Target.Template = &esv1alpha1.ExternalSecretTemplate{
  335. Type: v1.SecretTypeDockerConfigJson,
  336. Data: map[string]string{
  337. ".dockerconfigjson": "{{ .mysecret | toString }}",
  338. },
  339. }
  340. }
  341. }
  342. // This case adds an ssh private key secret and synchronizes it.
  343. // Not supported by: vault. Json parsing error.
  344. func SSHKeySync(f *framework.Framework) (string, func(*framework.TestCase)) {
  345. return "[common] should sync ssh key secret", func(tc *framework.TestCase) {
  346. sshSecretName := fmt.Sprintf("%s-%s", f.Namespace.Name, "ssh-priv-key-example")
  347. sshSecretValue := `-----BEGIN OPENSSH PRIVATE KEY-----
  348. b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcn
  349. NhAAAAAwEAAQAAAYEAsARoZUqo6L5dd0WRjZ2QPq/kKlbjtUY1njzJ01UtdC1u1eSJFUnV
  350. K1J+9b1kEqI4lgAaItaYbpJNSgCe97z6DRxEMTUQ3VhB+X+mPfcN2/I0bYklRxh59OTJcL
  351. FsPX0oCR/5eLXz9MCmelxDX7H8XDh9hP6PThooYP60oaDt0xsZvEyo6OQ43n5FuorSg4vL
  352. aMIQYK/znhBq9kR6XKMO8mULoDa+LnhOWsAY8kJ3fowF/UsQmh6PY/w4DJaypm85+a6Sak
  353. Lpn80ur7L6nV7yTqufYqXa4hgNsJHmJ7NGKqOxT/8vcvVRqRadNLl79g9bRRavBiYt/8fy
  354. DJGxOuutcVTzYlzS593Vo95In853cT+HuK4guaWkQdTrThG7jHAi0wVueaEDCTnDkuTk2h
  355. 7PXFBkYTUwE3y+NHo1X+nTE3LhiUJ0RBr3aaj5UBYKHK1uMo1C4zZH3GMvB5K2KmXwG/oB
  356. gCcD1j5hlp6QwOzBVfXsXBF4ewtf7g3RQF8DS3mBAAAFkDc7Drc3Ow63AAAAB3NzaC1yc2
  357. EAAAGBALAEaGVKqOi+XXdFkY2dkD6v5CpW47VGNZ48ydNVLXQtbtXkiRVJ1StSfvW9ZBKi
  358. OJYAGiLWmG6STUoAnve8+g0cRDE1EN1YQfl/pj33DdvyNG2JJUcYefTkyXCxbD19KAkf+X
  359. i18/TApnpcQ1+x/Fw4fYT+j04aKGD+tKGg7dMbGbxMqOjkON5+RbqK0oOLy2jCEGCv854Q
  360. avZEelyjDvJlC6A2vi54TlrAGPJCd36MBf1LEJoej2P8OAyWsqZvOfmukmpC6Z/NLq+y+p
  361. 1e8k6rn2Kl2uIYDbCR5iezRiqjsU//L3L1UakWnTS5e/YPW0UWrwYmLf/H8gyRsTrrrXFU
  362. 82Jc0ufd1aPeSJ/Od3E/h7iuILmlpEHU604Ru4xwItMFbnmhAwk5w5Lk5Noez1xQZGE1MB
  363. N8vjR6NV/p0xNy4YlCdEQa92mo+VAWChytbjKNQuM2R9xjLweStipl8Bv6AYAnA9Y+YZae
  364. kMDswVX17FwReHsLX+4N0UBfA0t5gQAAAAMBAAEAAAGAey4agQiGvJq8fkPJYPnrgHNHkf
  365. nM0YeY7mxMMgFiFfPVpQqShLtu2yqYfxFTf1bXkuHvaIIVmwv32tokZetycspdTrJ8Yurp
  366. ANo8VREYOdx+pEleNSsD7kZOUvdXcJCt+/TMeZWcbKSF3QvEeqvsl/1Qmkorr9TOfVLCxn
  367. oA9cP5drWPX6yXv91OnwWX3UdvyphFLeT08KE8uauilkHmq+va/vxQi+TVsNzOmHu7dGw5
  368. pNFrhO/uGWLhNq4fyCn9l33vpHZdMe2h/N32MnKZgjFOWLqyHy2Cx5BDJTfXyHwjVTqGN1
  369. 8fzrC+o3OuFsR1pPugwlYUW8B9XaxPI6h+Ke6GIxacNtVvOe67GrkdYbQkyrs4/EMqbXTl
  370. /BG/JZIMuchk0Da0TKDDjBwchMjAiwjsFp/wawlL9Y0dJIG0muEuHXxjInEa7xQoisAUCf
  371. B7lasXeUPOy/Z76qFwjVvyfkiVgWygncjGL44b0rgEC81L/dTZUyvNoCM9Bn7wSbuBAAAA
  372. wQDHw6NkJCvGOYa9lt2lMou6hSudokHejOo+J9jJCJdUlMXIbHhBUzrmSh47OSkgpAo4qf
  373. iVGHvBO55pZ5pI7o4woTQxaPFM8a/5BhMWcZ2LDMqU5iov9C2Dz8yKUyQmAodNkOGacQJU
  374. MDAVBJYeBFJSu04bj2EEhEd+9rIazeqVl91qkV1uGTz4aJ360PSmLuLAFT12BYGjIBfHrS
  375. yom+1HbBoUziG4a/kzzbJGTC7U66YTjpHAMEtz4mbpU0AhNg4AAADBANgTs8yjrEkL4pcC
  376. gfUr9oR42/BVl3ZxaFQ7PAvs9m0aut7b/ZRmsSF8F2TAl0H4H9M8uUKTTOhqRtdnTtDqm9
  377. QBUIQBzA6Blb5oP+yL+Eiez4gMFd9HumFXG3JoRu/JmDE19KviHaldV47QcvG6B3p0eb5Q
  378. hgVcNsrOGyBUZA0kBmzQBwv6gUoo++ETQMH89BlljZVCiPW7F6FCrPxHp7EB5txYJ62Qpu
  379. 2U40qgb2ONiUOuiI84EYRAgmDTbboMPQAAAMEA0Inn71l7LsYv81vstbmMQz0qLvhHkBcp
  380. mMhh6tyzI0dvLZabBLTPhIT4R/0VDMJGsH5X1cEaap47XDpu0/g3mfOV6PToUfYA2Ugw7N
  381. bs23UlVH1n0zL2x0QOMHX/Fkfc3OdIuc97ZHoMeW6Nf7Ii0iH7slIpH4hPVYcGXk/bX6wt
  382. PKDc8xGEXdd4A6jnwJBifJs+UpPrHAh0c63KfjO3rryDycvmxeWRnyU1yRCUjIuH31vi+L
  383. OkcGfqTaOoz2KVAAAAFGtpYW5AREVTS1RPUC1TNFI5S1JQAQIDBAUG
  384. -----END OPENSSH PRIVATE KEY-----`
  385. tc.Secrets = map[string]string{
  386. sshSecretName: sshSecretValue,
  387. }
  388. tc.ExpectedSecret = &v1.Secret{
  389. Type: v1.SecretTypeSSHAuth,
  390. Data: map[string][]byte{
  391. "ssh-privatekey": []byte(sshSecretValue),
  392. },
  393. }
  394. tc.ExternalSecret.Spec.Data = []esv1alpha1.ExternalSecretData{
  395. {
  396. SecretKey: "mysecret",
  397. RemoteRef: esv1alpha1.ExternalSecretDataRemoteRef{
  398. Key: sshSecretName,
  399. },
  400. },
  401. }
  402. tc.ExternalSecret.Spec.Target.Template = &esv1alpha1.ExternalSecretTemplate{
  403. Type: v1.SecretTypeSSHAuth,
  404. Data: map[string]string{
  405. "ssh-privatekey": "{{ .mysecret | toString }}",
  406. },
  407. }
  408. }
  409. }
  410. // This case adds an ssh private key secret and syncs it.
  411. func SSHKeySyncDataProperty(f *framework.Framework) (string, func(*framework.TestCase)) {
  412. return "[common] should sync ssh key with provider.", func(tc *framework.TestCase) {
  413. cloudSecretName := fmt.Sprintf("%s-%s", f.Namespace.Name, "docker-config-example")
  414. SSHKey := `-----BEGIN OPENSSH PRIVATE KEY-----
  415. b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcn
  416. NhAAAAAwEAAQAAAYEAsARoZUqo6L5dd0WRjZ2QPq/kKlbjtUY1njzJ01UtdC1u1eSJFUnV
  417. K1J+9b1kEqI4lgAaItaYbpJNSgCe97z6DRxEMTUQ3VhB+X+mPfcN2/I0bYklRxh59OTJcL
  418. FsPX0oCR/5eLXz9MCmelxDX7H8XDh9hP6PThooYP60oaDt0xsZvEyo6OQ43n5FuorSg4vL
  419. aMIQYK/znhBq9kR6XKMO8mULoDa+LnhOWsAY8kJ3fowF/UsQmh6PY/w4DJaypm85+a6Sak
  420. Lpn80ur7L6nV7yTqufYqXa4hgNsJHmJ7NGKqOxT/8vcvVRqRadNLl79g9bRRavBiYt/8fy
  421. DJGxOuutcVTzYlzS593Vo95In853cT+HuK4guaWkQdTrThG7jHAi0wVueaEDCTnDkuTk2h
  422. 7PXFBkYTUwE3y+NHo1X+nTE3LhiUJ0RBr3aaj5UBYKHK1uMo1C4zZH3GMvB5K2KmXwG/oB
  423. gCcD1j5hlp6QwOzBVfXsXBF4ewtf7g3RQF8DS3mBAAAFkDc7Drc3Ow63AAAAB3NzaC1yc2
  424. EAAAGBALAEaGVKqOi+XXdFkY2dkD6v5CpW47VGNZ48ydNVLXQtbtXkiRVJ1StSfvW9ZBKi
  425. OJYAGiLWmG6STUoAnve8+g0cRDE1EN1YQfl/pj33DdvyNG2JJUcYefTkyXCxbD19KAkf+X
  426. i18/TApnpcQ1+x/Fw4fYT+j04aKGD+tKGg7dMbGbxMqOjkON5+RbqK0oOLy2jCEGCv854Q
  427. avZEelyjDvJlC6A2vi54TlrAGPJCd36MBf1LEJoej2P8OAyWsqZvOfmukmpC6Z/NLq+y+p
  428. 1e8k6rn2Kl2uIYDbCR5iezRiqjsU//L3L1UakWnTS5e/YPW0UWrwYmLf/H8gyRsTrrrXFU
  429. 82Jc0ufd1aPeSJ/Od3E/h7iuILmlpEHU604Ru4xwItMFbnmhAwk5w5Lk5Noez1xQZGE1MB
  430. N8vjR6NV/p0xNy4YlCdEQa92mo+VAWChytbjKNQuM2R9xjLweStipl8Bv6AYAnA9Y+YZae
  431. kMDswVX17FwReHsLX+4N0UBfA0t5gQAAAAMBAAEAAAGAey4agQiGvJq8fkPJYPnrgHNHkf
  432. nM0YeY7mxMMgFiFfPVpQqShLtu2yqYfxFTf1bXkuHvaIIVmwv32tokZetycspdTrJ8Yurp
  433. ANo8VREYOdx+pEleNSsD7kZOUvdXcJCt+/TMeZWcbKSF3QvEeqvsl/1Qmkorr9TOfVLCxn
  434. oA9cP5drWPX6yXv91OnwWX3UdvyphFLeT08KE8uauilkHmq+va/vxQi+TVsNzOmHu7dGw5
  435. pNFrhO/uGWLhNq4fyCn9l33vpHZdMe2h/N32MnKZgjFOWLqyHy2Cx5BDJTfXyHwjVTqGN1
  436. 8fzrC+o3OuFsR1pPugwlYUW8B9XaxPI6h+Ke6GIxacNtVvOe67GrkdYbQkyrs4/EMqbXTl
  437. /BG/JZIMuchk0Da0TKDDjBwchMjAiwjsFp/wawlL9Y0dJIG0muEuHXxjInEa7xQoisAUCf
  438. B7lasXeUPOy/Z76qFwjVvyfkiVgWygncjGL44b0rgEC81L/dTZUyvNoCM9Bn7wSbuBAAAA
  439. wQDHw6NkJCvGOYa9lt2lMou6hSudokHejOo+J9jJCJdUlMXIbHhBUzrmSh47OSkgpAo4qf
  440. iVGHvBO55pZ5pI7o4woTQxaPFM8a/5BhMWcZ2LDMqU5iov9C2Dz8yKUyQmAodNkOGacQJU
  441. MDAVBJYeBFJSu04bj2EEhEd+9rIazeqVl91qkV1uGTz4aJ360PSmLuLAFT12BYGjIBfHrS
  442. yom+1HbBoUziG4a/kzzbJGTC7U66YTjpHAMEtz4mbpU0AhNg4AAADBANgTs8yjrEkL4pcC
  443. gfUr9oR42/BVl3ZxaFQ7PAvs9m0aut7b/ZRmsSF8F2TAl0H4H9M8uUKTTOhqRtdnTtDqm9
  444. QBUIQBzA6Blb5oP+yL+Eiez4gMFd9HumFXG3JoRu/JmDE19KviHaldV47QcvG6B3p0eb5Q
  445. hgVcNsrOGyBUZA0kBmzQBwv6gUoo++ETQMH89BlljZVCiPW7F6FCrPxHp7EB5txYJ62Qpu
  446. 2U40qgb2ONiUOuiI84EYRAgmDTbboMPQAAAMEA0Inn71l7LsYv81vstbmMQz0qLvhHkBcp
  447. mMhh6tyzI0dvLZabBLTPhIT4R/0VDMJGsH5X1cEaap47XDpu0/g3mfOV6PToUfYA2Ugw7N
  448. bs23UlVH1n0zL2x0QOMHX/Fkfc3OdIuc97ZHoMeW6Nf7Ii0iH7slIpH4hPVYcGXk/bX6wt
  449. PKDc8xGEXdd4A6jnwJBifJs+UpPrHAh0c63KfjO3rryDycvmxeWRnyU1yRCUjIuH31vi+L
  450. OkcGfqTaOoz2KVAAAAFGtpYW5AREVTS1RPUC1TNFI5S1JQAQIDBAUG
  451. -----END OPENSSH PRIVATE KEY-----`
  452. cloudSecretValue := fmt.Sprintf(`{"ssh-auth": "%s"}`, SSHKey)
  453. tc.Secrets = map[string]string{
  454. cloudSecretName: cloudSecretValue,
  455. }
  456. tc.ExpectedSecret = &v1.Secret{
  457. Type: v1.SecretTypeSSHAuth,
  458. Data: map[string][]byte{
  459. "ssh-privatekey": []byte(SSHKey),
  460. },
  461. }
  462. tc.ExternalSecret.Spec.Data = []esv1alpha1.ExternalSecretData{
  463. {
  464. SecretKey: "mysecret",
  465. RemoteRef: esv1alpha1.ExternalSecretDataRemoteRef{
  466. Key: cloudSecretName,
  467. Property: "ssh-auth",
  468. },
  469. },
  470. }
  471. tc.ExternalSecret.Spec.Target.Template = &esv1alpha1.ExternalSecretTemplate{
  472. Type: v1.SecretTypeSSHAuth,
  473. Data: map[string]string{
  474. "ssh-privatekey": "{{ .mysecret | toString }}",
  475. },
  476. }
  477. }
  478. }