Skip to content

KAFKA-3617: Unit tests for SASL authenticator#1273

Closed
rajinisivaram wants to merge 4 commits into
apache:trunkfrom
rajinisivaram:KAFKA-3617
Closed

KAFKA-3617: Unit tests for SASL authenticator#1273
rajinisivaram wants to merge 4 commits into
apache:trunkfrom
rajinisivaram:KAFKA-3617

Conversation

@rajinisivaram
Copy link
Copy Markdown
Contributor

Unit tests for SASL authenticator, tests for SASL/PLAIN and multiple mechanisms, authorization test for SASL/PLAIN

String serverHost = InetAddress.getLocalHost().getHostAddress();
server = new SslEchoServer(sslServerConfigs, serverHost);
server = new NioEchoServer(SecurityProtocol.SSL, sslServerConfigs, serverHost);
server.start();
Copy link
Copy Markdown
Member

@ijuma ijuma Apr 28, 2016

Choose a reason for hiding this comment

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

Should we use createEchoServer here as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This one overrides the host address to test that endpoint identification can be disabled.

TestJaasConfig jaasConfig = configureMechanisms("PLAIN", Arrays.asList("PLAIN"));
jaasConfig.setPlainClientOptions("myuser", "invalidpassword");
saslClientConfigs.put(SaslConfigs.SASL_MECHANISM, "PLAIN");
saslServerConfigs.put(SaslConfigs.SASL_ENABLED_MECHANISMS, Arrays.asList("PLAIN"));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Doesn't configureMechanisms do this already?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed.

@rajinisivaram
Copy link
Copy Markdown
Contributor Author

@ijuma Thank you for the reviews. I have addressed most of them (all the easy ones :-)) and left comments for the others.

def kafkaSaslProperties(clientSaslMechanism: String, serverSaslMechanisms: Option[Seq[String]] = None) = {
val props = new Properties
props.put(SaslConfigs.SASL_MECHANISM, clientSaslMechanism)
serverSaslMechanisms match {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You can use foreach instead of pattern matching here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

@ijuma
Copy link
Copy Markdown
Member

ijuma commented Apr 28, 2016

Thank you @rajinisivaram, left some more comments. It seems like we're close.

val props = new Properties
props.put(SaslConfigs.SASL_MECHANISM, clientSaslMechanism)
serverSaslMechanisms.foreach {
case serverMechanisms =>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: case is not needed and this should be on the previous line:

serverSaslMechanisms.foreach { serverMechanism =>
  props...
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants