Skip to content

Commit 173fcf5

Browse files
committed
Add functional and kuttl tests
Signed-off-by: Veronika Fisarova <vfisarov@redhat.com>
1 parent 99391d1 commit 173fcf5

14 files changed

Lines changed: 503 additions & 5 deletions

apis/bases/core.openstack.org_openstackcontrolplanes.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ spec:
5555
type: integer
5656
roles:
5757
default:
58-
- admin
5958
- service
6059
items:
6160
type: string

apis/core/v1beta1/openstackcontrolplane_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ type ApplicationCredentialSection struct {
880880
GracePeriodDays *int `json:"gracePeriodDays,omitempty"`
881881

882882
// +kubebuilder:validation:Optional
883-
// +kubebuilder:default={"admin","service"}
883+
// +kubebuilder:default={"service"}
884884
// +kubebuilder:validation:MinItems=1
885885
// Roles to assign to the ApplicationCredential
886886
Roles []string `json:"roles,omitempty"`

config/crd/bases/core.openstack.org_openstackcontrolplanes.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ spec:
5555
type: integer
5656
roles:
5757
default:
58-
- admin
5958
- service
6059
items:
6160
type: string
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
resources:
2+
- ../../base/openstackcontrolplane
3+
4+
patches:
5+
- target:
6+
kind: OpenStackControlPlane
7+
name: .*
8+
patch: |-
9+
- op: replace
10+
path: /metadata/name
11+
value: openstack
12+
- target:
13+
kind: OpenStackControlPlane
14+
path: patch.yaml
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: core.openstack.org/v1beta1
2+
kind: OpenStackControlPlane
3+
metadata:
4+
name: openstack
5+
spec:
6+
applicationCredential:
7+
enabled: true
8+
expirationDays: 200
9+
gracePeriodDays: 90
10+
roles:
11+
- service
12+
unrestricted: false
13+
barbican:
14+
applicationCredential:
15+
enabled: true
16+
cinder:
17+
applicationCredential:
18+
enabled: true
19+
expirationDays: 10
20+
gracePeriodDays: 5
21+
roles:
22+
- admin
23+
- service
24+
unrestricted: true

pkg/openstack/applicationcredential.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,9 @@ func ReconcileApplicationCredentials(
155155

156156
rel := &url.URL{Path: path.Join(u.Path, "auth", "tokens")}
157157
full := u.ResolveReference(rel)
158-
// full.Path guarantees to start with /
159158
acObj.Spec.AccessRules = []keystonev1.ACRule{{
160159
Service: "identity",
161-
Path: full.Path, // e.g. "/v3/auth/tokens" or "/auth/tokens"
160+
Path: full.Path, // /v3/auth/tokens or /auth/tokens
162161
Method: "POST",
163162
}}
164163

tests/functional/ctlplane/openstackoperator_controller_test.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3087,5 +3087,43 @@ var _ = Describe("OpenStackOperator controller galera and rabbitmq", func() {
30873087
})
30883088

30893089
})
3090+
})
3091+
3092+
var _ = Describe("Application Credentials are enabled in control plane", func() {
3093+
When("global application credentials are enabled", func() {
3094+
BeforeEach(func() {
3095+
spec := GetDefaultOpenStackControlPlaneSpec()
3096+
spec["applicationCredential"] = map[string]interface{}{"enabled": true}
3097+
spec["cinder"] = map[string]interface{}{
3098+
"enabled": true,
3099+
"applicationCredential": map[string]interface{}{
3100+
"enabled": true,
3101+
"expirationDays": 100,
3102+
"gracePeriodDays": 50,
3103+
"roles": []string{"custom", "role"},
3104+
"unrestricted": true,
3105+
},
3106+
}
30903107

3108+
DeferCleanup(th.DeleteInstance,
3109+
CreateOpenStackControlPlane(names.OpenStackControlplaneName, spec),
3110+
)
3111+
})
3112+
3113+
It("should fill defaults", func() {
3114+
cp := GetOpenStackControlPlane(names.OpenStackControlplaneName)
3115+
Expect(cp.Spec.ApplicationCredential.Enabled).To(BeTrue())
3116+
Expect(*cp.Spec.ApplicationCredential.ExpirationDays).To(Equal(365))
3117+
Expect(*cp.Spec.ApplicationCredential.GracePeriodDays).To(Equal(182))
3118+
Expect(cp.Spec.ApplicationCredential.Roles).To(ConsistOf("service"))
3119+
Expect(*cp.Spec.ApplicationCredential.Unrestricted).To(BeFalse())
3120+
3121+
ac := cp.Spec.Cinder.ApplicationCredential
3122+
Expect(*ac.ExpirationDays).To(Equal(100))
3123+
Expect(*ac.GracePeriodDays).To(Equal(50))
3124+
Expect(ac.Roles).To(ConsistOf("custom", "role"))
3125+
Expect(*ac.Unrestricted).To(BeTrue())
3126+
3127+
})
3128+
})
30913129
})
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: core.openstack.org/v1beta1
2+
kind: OpenStackControlPlane
3+
metadata:
4+
name: openstackcontrolplane
5+
spec:
6+
applicationCredential:
7+
enabled: true
8+
expirationDays: 200
9+
gracePeriodDays: 90
10+
roles:
11+
- service
12+
unrestricted: false
13+
barbican:
14+
applicationCredential:
15+
enabled: true
16+
cinder:
17+
applicationCredential:
18+
enabled: true
19+
expirationDays: 10
20+
gracePeriodDays: 5
21+
roles:
22+
- admin
23+
- service
24+
unrestricted: true
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../common/assert-sample-deployment.yaml
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
apiVersion: kuttl.dev/v1beta1
2+
kind: TestStep
3+
commands:
4+
- script: |
5+
oc kustomize ../../../../config/samples/base/openstackcontrolplane | oc apply -n $NAMESPACE -f -

0 commit comments

Comments
 (0)