-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unit testing #2
Unit testing #2
Conversation
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.kafka</groupId> | ||
<artifactId>kafka_2.11</artifactId> | ||
<version>1.1.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.commons</groupId> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commons not needed here
pom.xml
Outdated
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-simple</artifactId> | ||
<version>1.6.4</version> | ||
|
||
<scope>test</scope> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
slf4j-simple should be test-scoped, kafka brings its own impl
public class SpiffePrincipalBuilder implements KafkaPrincipalBuilder { | ||
private static final Logger LOG = LoggerFactory.getLogger(SpiffePrincipalBuilder.class); | ||
|
||
private static final String SPIFFE_TYPE = "SPIFFE"; | ||
|
||
public KafkaPrincipal build(AuthenticationContext context) { | ||
if (context instanceof PlaintextAuthenticationContext) { | ||
if (!(context instanceof SslAuthenticationContext)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
skip the plaintext/sasl difference
try { | ||
// Read cert | ||
ByteArrayInputStream certInputStream = | ||
new ByteArrayInputStream(IOUtils.toByteArray(classLoader.getResourceAsStream(resourcePath))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not needed
|
||
try { | ||
X509Certificate cert = getResourceAsCert("subject-only-cert.pem"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extract identical code
assertEquals(KafkaPrincipal.USER_TYPE, principal.getPrincipalType()); | ||
|
||
// Identity should be a string | ||
assertNotNull(principal.getName()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert with goldenfile
Added unitests for: