Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions acceptance/features/role-crds.feature
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,16 @@ Feature: Role CRDs
"""
And role "admin-role" is successfully synced
Then role "admin-role" should exist in cluster "roles"
And role "admin-role" should have members "alice" and "bob" in cluster "roles"
And role "admin-role" should have members "alice and bob" in cluster "roles"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is a bit funny, but it matches how the scenario's step definition is actually written, the regex contains a single capture group for the members string and then has this logic:

	if strings.Contains(members, " and ") {

which basically means that it's tokenizing a single quoted string around an optional and inclusion in the string itself. This should probably eventually be rewritten to not be so weird and at some point I might take a look to see if godog's step parsing logic allows you to do thing like have a +-based capture group where you can treat it like an array or something, but for now this is just to minimally get this matching what it's supposed to do.


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

@skip:gke @skip:aks @skip:eks
Scenario: Manage authorization-only roles
Expand Down
1 change: 1 addition & 0 deletions acceptance/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func getSuite(t *testing.T) *framework.Suite {

var setupSuite = sync.OnceValues(func() (*framework.Suite, error) {
return framework.SuiteBuilderFromFlags().
Strict().
RegisterProvider("eks", framework.NoopProvider).
RegisterProvider("gke", framework.NoopProvider).
RegisterProvider("aks", framework.NoopProvider).
Expand Down
11 changes: 11 additions & 0 deletions acceptance/steps/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,17 @@ func (c *clusterClients) checkSchema(ctx context.Context, schema string, exists
}
}

func (c *clusterClients) CreateTopic(ctx context.Context, topic string) {
t := framework.T(ctx)

admin := kadm.NewClient(c.Kafka(ctx))
defer admin.Close()

response, err := admin.CreateTopic(ctx, 1, 1, map[string]*string{}, topic)
require.NoError(t, err)
require.NoError(t, response.Err)
}

func (c *clusterClients) ExpectTopic(ctx context.Context, topic string) {
t := framework.T(ctx)

Expand Down
1 change: 1 addition & 0 deletions acceptance/steps/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func init() {
framework.RegisterStep(`^there is no topic "([^"]*)" in cluster "([^"]*)"$`, thereIsNoTopic)
framework.RegisterStep(`^topic "([^"]*)" is successfully synced$`, topicIsSuccessfullySynced)
framework.RegisterStep(`^I should be able to produce and consume from "([^"]*)" in cluster "([^"]*)"$`, iShouldBeAbleToProduceAndConsumeFrom)
framework.RegisterStep(`I create topic "([^"]*)" in cluster "([^"]*)"`, iCreateTopicInCluster)

// User scenario steps
framework.RegisterStep(`^user "([^"]*)" is successfully synced$`, userIsSuccessfullySynced)
Expand Down
4 changes: 4 additions & 0 deletions acceptance/steps/topics.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ func thereIsNoTopic(ctx context.Context, topic, cluster string) {
clientsForCluster(ctx, cluster).ExpectNoTopic(ctx, topic)
}

func iCreateTopicInCluster(ctx context.Context, topic, cluster string) {
clientsForCluster(ctx, cluster).CreateTopic(ctx, topic)
}

func iShouldBeAbleToProduceAndConsumeFrom(ctx context.Context, t framework.TestingT, topic, cluster string) {
payload := []byte("test")

Expand Down
6 changes: 2 additions & 4 deletions go.work.sum
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,6 @@ dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
github.com/AdaLogics/go-fuzz-headers v0.0.0-20210715213245-6c3934b029d8/go.mod h1:CzsSbkDixRphAF5hS6wbMKq0eI6ccJRb7/A0M6JBnwg=
github.com/AdaLogics/go-fuzz-headers v0.0.0-20221103172237-443f56ff4ba8/go.mod h1:i9fr2JpcEcY/IHEvzCM3qXUZYOQHgR89dt4es1CgMhc=
github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8=
github.com/AdamKorcz/go-118-fuzz-build v0.0.0-20230306123547-8075edf89bb0 h1:59MxjQVfjXsBpLy+dbd2/ELV5ofnUkUZBvWSC85sheA=
github.com/AdamKorcz/go-118-fuzz-build v0.0.0-20230306123547-8075edf89bb0/go.mod h1:OahwfttHWG6eJ0clwcfBAHoDI6X/LV/15hx/wlMZSrU=
github.com/Azure/azure-sdk-for-go v16.2.1+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=
Expand Down Expand Up @@ -1769,11 +1768,11 @@ github.com/mndrix/tap-go v0.0.0-20171203230836-629fa407e90b/go.mod h1:pzzDgJWZ34
github.com/moby/locker v1.0.1 h1:fOXqR41zeveg4fFODix+1Ch4mj/gT0NE1XJbp/epuBg=
github.com/moby/locker v1.0.1/go.mod h1:S7SDdo5zpBK84bzzVlKr2V0hz+7x9hWbYC/kq7oQppc=
github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c=
github.com/moby/sys/atomicwriter v0.1.0/go.mod h1:Ul8oqv2ZMNHOceF643P6FKPXeCmYtlQMvpizfsSoaWs=
github.com/moby/sys/mount v0.3.4/go.mod h1:KcQJMbQdJHPlq5lcYT+/CjatWM4PuxKe+XLSVS4J6Os=
github.com/moby/sys/mountinfo v0.4.0/go.mod h1:rEr8tzG/lsIZHBtN/JjGG+LMYx9eXgW2JI+6q0qou+A=
github.com/moby/sys/mountinfo v0.4.1/go.mod h1:rEr8tzG/lsIZHBtN/JjGG+LMYx9eXgW2JI+6q0qou+A=
github.com/moby/sys/mountinfo v0.5.0/go.mod h1:3bMD3Rg+zkqx8MRYPi7Pyb0Ie97QEBmdxbhnCLlSvSU=
github.com/moby/sys/mountinfo v0.7.2/go.mod h1:1YOa8w8Ih7uW0wALDUgT1dTTSBrZ+HiBLGws92L2RU4=
github.com/moby/sys/reexec v0.1.0/go.mod h1:EqjBg8F3X7iZe5pU6nRZnYCMUTXoxsjiIfHup5wYIN8=
github.com/moby/sys/sequential v0.5.0/go.mod h1:tH2cOOs5V9MlPiXcQzRC+eEyab644PWKGRYaaV5ZZlo=
github.com/moby/sys/signal v0.6.0/go.mod h1:GQ6ObYZfqacOwTtlXvcmh9A26dVRul/hbOZn88Kg8Tg=
github.com/moby/sys/signal v0.7.0 h1:25RW3d5TnQEoKvRbEKUGay6DCQ46IxAVTT9CUMgmsSI=
Expand Down Expand Up @@ -3153,7 +3152,6 @@ gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk=
gotest.tools/v3 v3.0.3/go.mod h1:Z7Lb0S5l+klDB31fvDQX8ss/FlKDxtlFlw3Oa8Ymbl8=
gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA=
helm.sh/helm/v3 v3.14.4/go.mod h1:Tje7LL4gprZpuBNTbG34d1Xn5NmRT3OWfBRwpOSer9I=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
Expand Down
5 changes: 5 additions & 0 deletions harpoon/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,11 @@ func (b *SuiteBuilder) WithCRDDirectory(directory string) *SuiteBuilder {
return b
}

func (b *SuiteBuilder) Strict() *SuiteBuilder {
b.opts.Strict = true
return b
}

func setupErrorCheck(ctx context.Context, err error, cleanupFn func(ctx context.Context)) {
if err != nil {
fmt.Printf("setting up test suite: %v\n", err)
Expand Down
Loading