-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[broker] Fix topic produced through REST not support Authorization #13771
[broker] Fix topic produced through REST not support Authorization #13771
Conversation
Hi , @liudezhi2098 Could you add some test for this change ? |
/pulsarbot run-failure-checks |
…_support_Authorization
/pulsarbot run-failure-checks |
2 similar comments
/pulsarbot run-failure-checks |
/pulsarbot run-failure-checks |
Hi @codelipenghui , The fix is critical to the existing community users who want to use the REST function. I suggest to add the fix as part of the release 2.9.2. |
Sorry , I mean the users that already implemented the Pulsar in their environment |
…_support_Authorization
@thomasechen Yes, we can contain it in 2.9.2 |
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.
Overall LGTM, just left a few comments about code style.
public void testProduceToNonPartitionedTopic(String token, int status) throws Exception { | ||
admin.topics().createNonPartitionedTopic("persistent://" + testTenant + "/" | ||
+ testNamespace + "/" + testTopicName); | ||
AsyncResponse asyncResponse = PowerMockito.mock(AsyncResponse.class); |
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.
The asyncResponse
is never used, we can remove it.
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.
Others asyncResponse
can be removed either.
topics = spy(new Topics()); | ||
topics.setPulsar(pulsar); |
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.
topics never used, we can remove it.
admin.topics().createNonPartitionedTopic("persistent://" + testTenant + "/" | ||
+ testNamespace + "/" + testTopicName); | ||
Schema<String> schema = StringSchema.utf8(); | ||
ProducerMessages producerMessages = new ProducerMessages(); | ||
producerMessages.setKeySchema(ObjectMapperFactory.getThreadLocal(). | ||
writeValueAsString(schema.getSchemaInfo())); | ||
producerMessages.setValueSchema(ObjectMapperFactory.getThreadLocal(). | ||
writeValueAsString(schema.getSchemaInfo())); | ||
String message = "[" + | ||
"{\"key\":\"my-key\",\"payload\":\"RestProducer:1\",\"eventTime\":1603045262772,\"sequenceId\":1}," + | ||
"{\"key\":\"my-key\",\"payload\":\"RestProducer:2\",\"eventTime\":1603045262772,\"sequenceId\":2}]"; | ||
producerMessages.setMessages(ObjectMapperFactory.getThreadLocal().readValue(message, | ||
new TypeReference<List<ProducerMessage>>() { | ||
})); | ||
|
||
WebTarget root = buildWebClient(); | ||
Response response = root.path("/topics/persistent/" + testTenant + "/" + testNamespace + "/" | ||
+ testTopicName).request(MediaType.APPLICATION_JSON) | ||
.header("Authorization", "Bearer " + token) | ||
.post(Entity.json(producerMessages)); | ||
Assert.assertEquals(response.getStatus(), status); |
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.
There are some repeated code blocks, maybe we could try to reuse the same code block. It seems that only topic names are different.
/pulsarbot run-failure-checks |
Master Issue: #13766
Motivation
fix topic produced through REST not support Authorization
Documentation
no-need-doc