Skip to content

Commit eb961c2

Browse files
committed
ApplicationCredential Tests and Config Samples
On-behalf-of: SAP nils.gondermann@sap.com
1 parent 46420f0 commit eb961c2

33 files changed

Lines changed: 107 additions & 220 deletions

config/samples/openstack_v1alpha1_applicationcredential.yaml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,19 @@ 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+
userRef: user-ref
15+
secret:
16+
secretRef: secret-ref
17+
unrestricted: False
18+
roles:
19+
- name: "role-name"
20+
accessRules:
21+
- method: "GET"
22+
service: "monitoring"
23+
expiresAt: "2022-02-02T22:22:22.000000"

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

Lines changed: 10 additions & 3 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"
@@ -29,5 +36,5 @@ resourceRefs:
2936
ref: user
3037
assertAll:
3138
- celExpr: "applicationcredential.status.id != ''"
32-
- celExpr: "applicationcredential.status.resource.userID == user.status.id"
33-
# TODO(scaffolding): Add more checks
39+
- celExpr: "applicationcredential.status.resource.roles[0].id != ''"
40+
- celExpr: "applicationcredential.status.resource.accessRules[0].id != ''"

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

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,32 @@ 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
10-
secretName: openstack-clouds
9+
secretName: openstack-admin
1110
managementPolicy: managed
12-
# TODO(scaffolding): Add the necessary fields to create the resource
13-
resource: {}
11+
resource:
12+
description: applicationcredential-user
1413
---
1514
apiVersion: openstack.k-orc.cloud/v1alpha1
1615
kind: ApplicationCredential
1716
metadata:
1817
name: applicationcredential-create-full
1918
spec:
2019
cloudCredentialsRef:
21-
# TODO(scaffolding): Use openstack-admin if the resource needs admin credentials to be created
2220
cloudName: openstack
23-
secretName: openstack-clouds
21+
secretName: openstack-admin
2422
managementPolicy: managed
2523
resource:
2624
name: applicationcredential-create-full-override
2725
description: ApplicationCredential from "create full" test
2826
userRef: applicationcredential-create-full
29-
# TODO(scaffolding): Add all fields the resource supports
27+
unrestricted: true
28+
secret:
29+
secretRef: "application-credential-secret"
30+
roles:
31+
- name: "reader"
32+
accessRules:
33+
- method: "GET"
34+
service: "compute"
35+
path: "/v2.1/servers"
36+
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 & 3 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"
@@ -28,5 +29,5 @@ resourceRefs:
2829
ref: user
2930
assertAll:
3031
- celExpr: "applicationcredential.status.id != ''"
31-
- celExpr: "applicationcredential.status.resource.userID == user.status.id"
32-
# TODO(scaffolding): Add more checks
32+
- celExpr: "applicationcredential.status.resource.projectID != ''"
33+
- celExpr: "!has(applicationcredential.status.resource.description)"

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,22 @@ 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
10-
secretName: openstack-clouds
9+
secretName: openstack-admin
1110
managementPolicy: managed
12-
# TODO(scaffolding): Add the necessary fields to create the resource
13-
resource: {}
11+
resource:
12+
description: applicationcredential-user
1413
---
1514
apiVersion: openstack.k-orc.cloud/v1alpha1
1615
kind: ApplicationCredential
1716
metadata:
1817
name: applicationcredential-create-minimal
1918
spec:
2019
cloudCredentialsRef:
21-
# TODO(scaffolding): Use openstack-admin if the resource needs admin credentials to be created
2220
cloudName: openstack
23-
secretName: openstack-clouds
21+
secretName: openstack-admin
2422
managementPolicy: managed
25-
# TODO(scaffolding): Only add the mandatory fields. It's possible the resource
26-
# doesn't have mandatory fields, in that case, leave it empty.
2723
resource:
2824
userRef: applicationcredential-create-minimal
25+
secret:
26+
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-dependency/00-create-resources-missing-deps.yaml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,34 @@ metadata:
55
name: applicationcredential-dependency
66
spec:
77
cloudCredentialsRef:
8-
# TODO(scaffolding): Use openstack-admin if the resource needs admin credentials to be created
98
cloudName: openstack
10-
secretName: openstack-clouds
9+
secretName: openstack-admin
1110
managementPolicy: managed
12-
# TODO(scaffolding): Add the necessary fields to create the resource
13-
resource: {}
11+
resource:
12+
description: applicationcredential-user
1413
---
1514
apiVersion: openstack.k-orc.cloud/v1alpha1
1615
kind: ApplicationCredential
1716
metadata:
1817
name: applicationcredential-dependency-no-user
1918
spec:
2019
cloudCredentialsRef:
21-
# TODO(scaffolding): Use openstack-admin if the resource needs admin credentials to be created
2220
cloudName: openstack
23-
secretName: openstack-clouds
21+
secretName: openstack-admin
2422
managementPolicy: managed
2523
resource:
2624
userRef: applicationcredential-dependency-pending
27-
# TODO(scaffolding): Add the necessary fields to create the resource
28-
25+
secret:
26+
secretRef: "application-credential-secret"
2927
---
3028
apiVersion: openstack.k-orc.cloud/v1alpha1
3129
kind: ApplicationCredential
3230
metadata:
3331
name: applicationcredential-dependency-no-secret
3432
spec:
3533
cloudCredentialsRef:
36-
# TODO(scaffolding): Use openstack-admin if the resource needs admin credentials to be created
3734
cloudName: openstack
3835
secretName: applicationcredential-dependency
3936
managementPolicy: managed
40-
# TODO(scaffolding): Add the necessary fields to create the resource
4137
resource:
4238
userRef: applicationcredential-dependency

internal/controllers/applicationcredential/tests/applicationcredential-dependency/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)