Skip to content

Commit 547495f

Browse files
committed
Add testdata
1 parent f62de16 commit 547495f

5 files changed

Lines changed: 110 additions & 3 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const_format = "0.2.34"
2424
futures = { version = "0.3", features = ["compat"] }
2525
h2 = "0.4"
2626
hex = "0.4"
27+
indoc = "2.0"
2728
# We can't use the stackable-operator re-export because we need the special "unstable-runtime-stream-control"
2829
# feature. We don't want to enable it in stackable-operator, as we don't want to accidentally use
2930
# unstable features.

rust/operator-binary/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ rand.workspace = true
4747
const_format.workspace = true
4848

4949
[dev-dependencies]
50+
indoc.workspace = true
5051
serde_yaml.workspace = true
5152

5253
[build-dependencies]

rust/operator-binary/src/crd/secret_class/mod.rs

Lines changed: 96 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,15 +355,109 @@ mod test {
355355
},
356356
};
357357

358+
/// The test data for [`v1alpha1`] and [`v1alpha2`] is identical except for the names of the
359+
/// `certManager` backend variant and the `generateSamAccountName` field, both of which were
360+
/// renamed in v1alpha2. The differing names are templated in via `{{cert_manager_backend}}`
361+
/// and `{{generate_sam_account_name}}` so that the YAML can be shared between both versions.
362+
fn secret_class_roundtrip_test_data(
363+
cert_manager_backend: &str,
364+
generate_sam_account_name: &str,
365+
) -> String {
366+
indoc::indoc! {"
367+
- backend:
368+
autoTls:
369+
ca:
370+
secret:
371+
name: secret-provisioner-tls-ca
372+
namespace: default
373+
autoGenerate: true
374+
caCertificateLifetime: 100d
375+
caCertificateRetirementDuration: 1d
376+
keyGeneration:
377+
rsa:
378+
length: 3072
379+
additionalTrustRoots:
380+
- configMap:
381+
name: tls-root-ca-config-map
382+
namespace: default
383+
- secret:
384+
name: tls-root-ca-secret
385+
namespace: default
386+
maxCertificateLifetime: 31d
387+
- backend:
388+
k8sSearch:
389+
searchNamespace:
390+
name: default
391+
trustStoreConfigMapName: my-trust-store
392+
- backend:
393+
k8sSearch:
394+
searchNamespace:
395+
pod: {}
396+
- backend:
397+
{{cert_manager_backend}}:
398+
issuer:
399+
kind: ClusterIssuer
400+
name: secret-operator-issuer
401+
defaultCertificateLifetime: 2d
402+
keyGeneration:
403+
rsa:
404+
length: 4096
405+
- backend:
406+
kerberosKeytab:
407+
realmName: CLUSTER.LOCAL
408+
kdc: krb5-kdc.default.svc.cluster.local
409+
admin:
410+
mit:
411+
kadminServer: krb5-kdc.default.svc.cluster.local
412+
adminKeytabSecret:
413+
name: secret-operator-keytab
414+
namespace: default
415+
adminPrincipal: stackable-secret-operator
416+
- backend:
417+
kerberosKeytab:
418+
realmName: SBLE.TEST
419+
kdc: sble-adds.sble.test
420+
admin:
421+
activeDirectory:
422+
ldapServer: sble-adds.sble.test
423+
ldapTlsCaSecret:
424+
name: secret-operator-ad-ca
425+
namespace: default
426+
passwordCacheSecret:
427+
name: secret-operator-ad-passwords
428+
namespace: default
429+
userDistinguishedName: CN=Stackable,CN=Users,DC=sble,DC=test
430+
schemaDistinguishedName: CN=Schema,CN=Configuration,DC=sble,DC=test
431+
{{generate_sam_account_name}}:
432+
prefix: sble-
433+
totalLength: 15
434+
adminKeytabSecret:
435+
name: secret-operator-keytab
436+
namespace: default
437+
adminPrincipal: stackable-secret-operator
438+
"}
439+
.replace("{{cert_manager_backend}}", cert_manager_backend)
440+
.replace("{{generate_sam_account_name}}", generate_sam_account_name)
441+
}
442+
358443
impl RoundtripTestData for v1alpha1::SecretClassSpec {
359444
fn roundtrip_test_data() -> Vec<Self> {
360-
todo!()
445+
stackable_operator::utils::yaml_from_str_singleton_map(
446+
&secret_class_roundtrip_test_data(
447+
"experimentalCertManager",
448+
"experimentalGenerateSamAccountName",
449+
),
450+
)
451+
.expect("Failed to parse v1alpha1 SecretClassSpec YAML")
361452
}
362453
}
363454

364455
impl RoundtripTestData for v1alpha2::SecretClassSpec {
365456
fn roundtrip_test_data() -> Vec<Self> {
366-
todo!()
457+
stackable_operator::utils::yaml_from_str_singleton_map(
458+
&secret_class_roundtrip_test_data("certManager", "generateSamAccountName"),
459+
)
460+
.expect("Failed to parse v1alpha2 SecretClassSpec YAML")
367461
}
368462
}
369463

rust/operator-binary/src/crd/trust_store/mod.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,17 @@ mod tests {
7878

7979
impl RoundtripTestData for v1alpha1::TrustStoreSpec {
8080
fn roundtrip_test_data() -> Vec<Self> {
81-
todo!()
81+
stackable_operator::utils::yaml_from_str_singleton_map(indoc::indoc! {"
82+
- secretClassName: tls
83+
- secretClassName: tls
84+
targetKind: Secret
85+
format: tls-pem
86+
tlsPemCaName: my-ca.crt
87+
- secretClassName: tls
88+
targetKind: ConfigMap
89+
format: tls-pkcs12
90+
"})
91+
.expect("Failed to parse TrustStoreSpec YAML")
8292
}
8393
}
8494
}

0 commit comments

Comments
 (0)