Skip to content

Commit 2d076ac

Browse files
committed
ApplicationCredential Tests and Config Samples
On-behalf-of: SAP nils.gondermann@sap.com
1 parent 118d5b3 commit 2d076ac

File tree

24 files changed

+63
-145
lines changed

24 files changed

+63
-145
lines changed

config/samples/openstack_v1alpha1_applicationcredential.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,18 @@ metadata:
55
name: applicationcredential-sample
66
spec:
77
cloudCredentialsRef:
8-
# TODO(scaffolding): Use openstack-admin if the resource needs admin credentials to be created
98
cloudName: openstack
109
secretName: openstack-clouds
1110
managementPolicy: managed
1211
resource:
1312
description: Sample ApplicationCredential
14-
# TODO(scaffolding): Add all fields the resource supports
13+
name: application-credential
14+
userID: "00000000000000000000000000000000"
15+
unrestricted: False
16+
secret: "Secret"
17+
roles:
18+
- name: "role-name"
19+
accessRules:
20+
- method: "GET"
21+
service: "monitoring"
22+
expiresAt: "2022-02-02T22:22:22.000000"

internal/controllers/applicationcredential/tests/applicationcredential-create-full/00-assert.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@ status:
77
resource:
88
name: applicationcredential-create-full-override
99
description: ApplicationCredential from "create full" test
10-
# TODO(scaffolding): Add all fields the resource supports
10+
unrestricted: true
11+
roles:
12+
- name: "reader"
13+
accessRules:
14+
- method: "GET"
15+
service: "compute"
16+
path: "/v2.1/servers"
17+
expiresAt: "2033-03-03T22:22:22Z"
1118
conditions:
1219
- type: Available
1320
status: "True"
@@ -25,4 +32,5 @@ resourceRefs:
2532
ref: applicationcredential
2633
assertAll:
2734
- celExpr: "applicationcredential.status.id != ''"
28-
# TODO(scaffolding): Add more checks
35+
- celExpr: "applicationcredential.status.resource.roles[0].id != ''"
36+
- celExpr: "applicationcredential.status.resource.accessRules[0].id != ''"

internal/controllers/applicationcredential/tests/applicationcredential-create-full/00-create-resource.yaml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,20 @@ metadata:
55
name: applicationcredential-create-full
66
spec:
77
cloudCredentialsRef:
8-
# TODO(scaffolding): Use openstack-admin if the resource needs admin credentials to be created
98
cloudName: openstack
109
secretName: openstack-clouds
1110
managementPolicy: managed
1211
resource:
1312
name: applicationcredential-create-full-override
1413
description: ApplicationCredential from "create full" test
15-
# TODO(scaffolding): Add all fields the resource supports
14+
userID: "token"
15+
unrestricted: true
16+
secret:
17+
secretRef: "application-credential-secret"
18+
roles:
19+
- name: "reader"
20+
accessRules:
21+
- method: "GET"
22+
service: "compute"
23+
path: "/v2.1/servers"
24+
expiresAt: "2033-03-03T22:22:22Z"

internal/controllers/applicationcredential/tests/applicationcredential-create-full/00-secret.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ kind: TestStep
44
commands:
55
- command: kubectl create secret generic openstack-clouds --from-file=clouds.yaml=${E2E_KUTTL_OSCLOUDS} ${E2E_KUTTL_CACERT_OPT}
66
namespaced: true
7+
- command: kubectl create secret generic application-credential-secret --from-literal=value=abc123
8+
namespaced: true

internal/controllers/applicationcredential/tests/applicationcredential-create-minimal/00-assert.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ metadata:
55
name: applicationcredential-create-minimal
66
status:
77
resource:
8+
# Name should default to object name
89
name: applicationcredential-create-minimal
9-
# TODO(scaffolding): Add all fields the resource supports
10+
unrestricted: false
1011
conditions:
1112
- type: Available
1213
status: "True"
@@ -24,4 +25,5 @@ resourceRefs:
2425
ref: applicationcredential
2526
assertAll:
2627
- celExpr: "applicationcredential.status.id != ''"
27-
# TODO(scaffolding): Add more checks
28+
- celExpr: "applicationcredential.status.resource.projectID != ''"
29+
- celExpr: "!has(applicationcredential.status.resource.description)"

internal/controllers/applicationcredential/tests/applicationcredential-create-minimal/00-create-resource.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ metadata:
55
name: applicationcredential-create-minimal
66
spec:
77
cloudCredentialsRef:
8-
# TODO(scaffolding): Use openstack-admin if the resource needs admin credentials to be created
98
cloudName: openstack
109
secretName: openstack-clouds
1110
managementPolicy: managed
12-
# TODO(scaffolding): Only add the mandatory fields. It's possible the resource
13-
# doesn't have mandatory fields, in that case, leave it empty.
14-
resource: {}
11+
resource:
12+
userID: "token"
13+
secret:
14+
secretRef: "application-credential-secret"

internal/controllers/applicationcredential/tests/applicationcredential-create-minimal/00-secret.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ kind: TestStep
44
commands:
55
- command: kubectl create secret generic openstack-clouds --from-file=clouds.yaml=${E2E_KUTTL_OSCLOUDS} ${E2E_KUTTL_CACERT_OPT}
66
namespaced: true
7+
- command: kubectl create secret generic application-credential-secret --from-literal=value=abc123
8+
namespaced: true

internal/controllers/applicationcredential/tests/applicationcredential-create-minimal/01-delete-secret.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ commands:
55
# We expect the deletion to hang due to the finalizer, so use --wait=false
66
- command: kubectl delete secret openstack-clouds --wait=false
77
namespaced: true
8+
- command: kubectl delete secret application-credential-secret --wait=false
9+
namespaced: true

internal/controllers/applicationcredential/tests/applicationcredential-import-error/00-create-resources.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,26 @@ metadata:
55
name: applicationcredential-import-error-external-1
66
spec:
77
cloudCredentialsRef:
8-
# TODO(scaffolding): Use openstack-admin if the resource needs admin credentials to be created
98
cloudName: openstack
109
secretName: openstack-clouds
1110
managementPolicy: managed
1211
resource:
1312
description: ApplicationCredential from "import error" test
14-
# TODO(scaffolding): add any required field
13+
userID: "token"
14+
secret:
15+
secretRef: "application-credential-secret"
1516
---
1617
apiVersion: openstack.k-orc.cloud/v1alpha1
1718
kind: ApplicationCredential
1819
metadata:
1920
name: applicationcredential-import-error-external-2
2021
spec:
2122
cloudCredentialsRef:
22-
# TODO(scaffolding): Use openstack-admin if the resource needs admin credentials to be created
2323
cloudName: openstack
2424
secretName: openstack-clouds
2525
managementPolicy: managed
2626
resource:
2727
description: ApplicationCredential from "import error" test
28-
# TODO(scaffolding): add any required field
28+
userID: "token"
29+
secret:
30+
secretRef: "application-credential-secret"

internal/controllers/applicationcredential/tests/applicationcredential-import-error/00-secret.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ kind: TestStep
44
commands:
55
- command: kubectl create secret generic openstack-clouds --from-file=clouds.yaml=${E2E_KUTTL_OSCLOUDS} ${E2E_KUTTL_CACERT_OPT}
66
namespaced: true
7+
- command: kubectl create secret generic application-credential-secret --from-literal=value=abc123
8+
namespaced: true

0 commit comments

Comments
 (0)