question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Asserting an exception in ZeroCode for Kafka ACL testing

See original GitHub issue

I am trying to test a kafka reader writer scenario where the user has permission to write to the topic, but does not have permission to read from that topic.

The java code looks like this :

@TargetEnv("kafka_servers/kafka_test_server.properties")
@RunWith(ZeroCodeUnitRunner.class)
public class KafkaConsumeJsonTest {

@Test
@Scenario('path/to/writer-can-write-but-cannot-read.json')
public void test writerWritesButCantRead(){}

}

The corresponding JSON looks like this :


{
  "scenarioName": "Writer can write to a topic but cannot read from it",
  "steps": [{
      "name": "write to test topic",
      "url": "kafka-topic:test-topic",
      "operation": "produce",
      "request": {
        "records": [{
          "key": "101",
          "value": "Hello World"
        }]
      },
      "assertions": {
        "status": "Ok",
        "recordMetadata": "$NOT.NULL"
      }
    },

    {
      "name": "onload_kafka",
      "url": "kafka-topic:test-topic",
      "operation": "unload",
      "request": {
        "consumerLocalConfigs": {
         "recordType": "JSON", 
         "maxNoOfRetryPollsOrTimeouts": 3
        }
      },
      "assertions": {
        "status": "Failed",
        "message": "Caused by: org.apache.kafka.common.errors.GroupAuthorizationException: Not authorized to access group: my-group"
      }
    }
  ]
}

When I run the test I encounter :

java.lang.RuntimeException: org.apache.kafka.common.errors.GroupAuthorizationException: Not authorized to access group: my-group.

This is a valid exception and I would to assert that in my test code to prove that the user cannot read from the topic with my-group as gorup-id. How do I assert this in the test case or in the scenario JSON?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
sparrowVcommented, Dec 20, 2021

@arpan57 Yeah example was with test suite but you can change to your needs quick easily. Glad it was helpful. Btw, you can join our Slack for more discussion etc.

0reactions
arpan57commented, Dec 21, 2021

Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Asserting an exception in ZeroCode for Kafka ACL testing
This is a valid exception and I would to assert that in my test code to prove that the user cannot read from...
Read more >
Asserting an exception in ZeroCode for Kafka ACL testing
I posted this question on zero code github and I got an answer. Solution We will need to create our own kafka client...
Read more >
Authorization using ACLs | Confluent Documentation
An authorizer is a server plugin used by Apache Kafka® to authorize operations. · To enable and use the AclAuthorizer, set its full...
Read more >
Full Archive - Baeldung
Full Archive. Sometimes it's difficult to have a birds eye view over an entire site; here's Baeldung from 10000 feet: Expand All. November...
Read more >
Change log for 4.8.43
Assert fails #98986; Condition is always 'false' because 'err' is always 'nil' in ... test for Default PodTopologySpread #95777; Return non-zero code on ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found