Skip to content

Commit c9dcbfc

Browse files
authored
Make scenario steps for roles match regex (#1108)
* Make scenario steps for roles match regex * Add Strict check to acceptance tests
1 parent 8d9b0bd commit c9dcbfc

File tree

6 files changed

+26
-3
lines changed

6 files changed

+26
-3
lines changed

acceptance/features/role-crds.feature

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,16 @@ Feature: Role CRDs
3131
"""
3232
And role "admin-role" is successfully synced
3333
Then role "admin-role" should exist in cluster "roles"
34-
And role "admin-role" should have members "alice" and "bob" in cluster "roles"
34+
And role "admin-role" should have members "alice and bob" in cluster "roles"
3535

3636
@skip:gke @skip:aks @skip:eks
3737
Scenario: Manage roles with authorization
3838
Given there is no role "read-only-role" in cluster "roles"
3939
And there are the following pre-existing users in cluster "roles"
4040
| name | password | mechanism |
4141
| charlie | password | SCRAM-SHA-256 |
42-
When I apply Kubernetes manifest:
42+
When I create topic "public-test" in cluster "roles"
43+
And I apply Kubernetes manifest:
4344
"""
4445
# tag::manage-roles-with-authorization[]
4546
# In this example manifest, a role called "read-only-role" is created in a cluster called "roles".
@@ -68,7 +69,7 @@ Feature: Role CRDs
6869
And role "read-only-role" is successfully synced
6970
Then role "read-only-role" should exist in cluster "roles"
7071
And role "read-only-role" should have ACLs for topic pattern "public-" in cluster "roles"
71-
And user "charlie" should be able to read from topic "public-test" in cluster "roles"
72+
And "charlie" should be able to read from topic "public-test" in cluster "roles"
7273

7374
@skip:gke @skip:aks @skip:eks
7475
Scenario: Manage authorization-only roles

acceptance/main_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ func getSuite(t *testing.T) *framework.Suite {
4444

4545
var setupSuite = sync.OnceValues(func() (*framework.Suite, error) {
4646
return framework.SuiteBuilderFromFlags().
47+
Strict().
4748
RegisterProvider("eks", framework.NoopProvider).
4849
RegisterProvider("gke", framework.NoopProvider).
4950
RegisterProvider("aks", framework.NoopProvider).

acceptance/steps/helpers.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,17 @@ func (c *clusterClients) checkSchema(ctx context.Context, schema string, exists
206206
}
207207
}
208208

209+
func (c *clusterClients) CreateTopic(ctx context.Context, topic string) {
210+
t := framework.T(ctx)
211+
212+
admin := kadm.NewClient(c.Kafka(ctx))
213+
defer admin.Close()
214+
215+
response, err := admin.CreateTopic(ctx, 1, 1, map[string]*string{}, topic)
216+
require.NoError(t, err)
217+
require.NoError(t, response.Err)
218+
}
219+
209220
func (c *clusterClients) ExpectTopic(ctx context.Context, topic string) {
210221
t := framework.T(ctx)
211222

acceptance/steps/register.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ func init() {
2929
framework.RegisterStep(`^there is no topic "([^"]*)" in cluster "([^"]*)"$`, thereIsNoTopic)
3030
framework.RegisterStep(`^topic "([^"]*)" is successfully synced$`, topicIsSuccessfullySynced)
3131
framework.RegisterStep(`^I should be able to produce and consume from "([^"]*)" in cluster "([^"]*)"$`, iShouldBeAbleToProduceAndConsumeFrom)
32+
framework.RegisterStep(`I create topic "([^"]*)" in cluster "([^"]*)"`, iCreateTopicInCluster)
3233

3334
// User scenario steps
3435
framework.RegisterStep(`^user "([^"]*)" is successfully synced$`, userIsSuccessfullySynced)

acceptance/steps/topics.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ func thereIsNoTopic(ctx context.Context, topic, cluster string) {
3939
clientsForCluster(ctx, cluster).ExpectNoTopic(ctx, topic)
4040
}
4141

42+
func iCreateTopicInCluster(ctx context.Context, topic, cluster string) {
43+
clientsForCluster(ctx, cluster).CreateTopic(ctx, topic)
44+
}
45+
4246
func iShouldBeAbleToProduceAndConsumeFrom(ctx context.Context, t framework.TestingT, topic, cluster string) {
4347
payload := []byte("test")
4448

harpoon/suite.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,11 @@ func (b *SuiteBuilder) WithCRDDirectory(directory string) *SuiteBuilder {
189189
return b
190190
}
191191

192+
func (b *SuiteBuilder) Strict() *SuiteBuilder {
193+
b.opts.Strict = true
194+
return b
195+
}
196+
192197
func setupErrorCheck(ctx context.Context, err error, cleanupFn func(ctx context.Context)) {
193198
if err != nil {
194199
fmt.Printf("setting up test suite: %v\n", err)

0 commit comments

Comments
 (0)