dpg, upgrade webpubsub to 2022-11#32125
Conversation
|
API change check APIView has identified API level changes in this PR and created following API reviews. |
...messaging-webpubsub/src/main/java/com/azure/messaging/webpubsub/WebPubSubServiceVersion.java
Show resolved
Hide resolved
| if (hub == null) { | ||
| return Mono.error(new IllegalArgumentException("Parameter hub is required and cannot be null.")); | ||
| } | ||
| if (connectionId == null) { | ||
| return Mono.error(new IllegalArgumentException("Parameter connectionId is required and cannot be null.")); | ||
| } | ||
| if (contentType == null) { |
There was a problem hiding this comment.
@srnagar Do we need this kind of validation on client side?
There was a problem hiding this comment.
contentType is an explicit param in the method, so, checking for null is okay for explicit params.
There was a problem hiding this comment.
ok, it's fine, the reason I ask this is that: I use empty string "" as content type to pass this non-null check (I have checked in LIVE test that the content-type passed in through RequestOptions appears in the real HTTP request). So would like to make sure if we really need this validation.
vicancy
left a comment
There was a problem hiding this comment.
Thanks for your efforts! The PR looks great! Added some little comments.
...ure-messaging-webpubsub/src/test/java/com/azure/messaging/webpubsub/TokenGenerationTest.java
Outdated
Show resolved
Hide resolved
...aging-webpubsub/src/test/java/com/azure/messaging/webpubsub/WebPubSubServiceClientTests.java
Show resolved
Hide resolved
| assertResponse(client.sendToAllWithResponse( | ||
| BinaryData.fromString("Hello World - Broadcast test!"), | ||
| new RequestOptions().setHeader("Content-Type", "text/plain") | ||
| .addQueryParam("filter", "userId ne 'user1'")), 202); |
There was a problem hiding this comment.
How about adding a ClientConnectionFilter helper class, as similar to what azure search does with its SearchFilter
A similar approach in c# is here https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/webpubsub/Azure.Messaging.WebPubSub/src/ClientConnectionFilter.cs
...g-webpubsub/src/samples/java/com/azure/messaging/webpubsub/BroadcastingWithFilterSample.java
Outdated
Show resolved
Hide resolved
...g-webpubsub/src/samples/java/com/azure/messaging/webpubsub/BroadcastingWithFilterSample.java
Outdated
Show resolved
Hide resolved
| ### Features Added | ||
|
|
||
| ### Breaking Changes | ||
| ## 1.2.0 (Unreleased) |
There was a problem hiding this comment.
Please update the release date too.
There was a problem hiding this comment.
sure, I will update before release. Plan to release next week (after core release finished)
| requestOptions.addQueryParam("role", options.getRoles().stream().collect(Collectors.joining(","))); | ||
| } | ||
| if (CoreUtils.isNullOrEmpty(options.getGroups())) { | ||
| requestOptions.addQueryParam("group", options.getGroups().stream().collect(Collectors.joining(","))); |
There was a problem hiding this comment.
question: what if group name contains ,, will it be escaped?
...ging-webpubsub/src/main/java/com/azure/messaging/webpubsub/implementation/WebPubSubUtil.java
Show resolved
Hide resolved
...-messaging-webpubsub/src/main/java/com/azure/messaging/webpubsub/WebPubSubServiceClient.java
Show resolved
Hide resolved
...ging-webpubsub/src/main/java/com/azure/messaging/webpubsub/implementation/WebPubSubUtil.java
Outdated
Show resolved
Hide resolved
|
|
||
| List<String> expectedRoles = Arrays.asList("a", "b"); | ||
| // test for special char case | ||
| List<String> expectedGroups = Arrays.asList("a&b", "c"); |
There was a problem hiding this comment.
Also tested when name contains &
There was a problem hiding this comment.
This test needs to use real webpubsub endpoint to generate client token in LIVE/RECORD mode and use recorded json in PLAYBACK mode. So I make TokenGenerationTest extends TestBase. But this will cause the existing parameterized tokenGeneration tests all needs playback file, otherwise it will have below error. Please let me know if you have any concern or suggestion.
java.lang.RuntimeException: Missing both new and old playback files
There was a problem hiding this comment.
After the changes, does it test the key credential mode, or the AAD credential mode?
You can always skip PLAYBACK, if you only want to have LIVE tests.
There was a problem hiding this comment.
AAD credential mode. skipping PLAYBACK still needs to extends TestBase?
9fd130c to
11d5d4e
Compare
| requestOptions.addQueryParam("minutesToExpire", String.valueOf(options.getExpiresAfter().toMinutes())); | ||
| } | ||
| if (CoreUtils.isNullOrEmpty(options.getRoles())) { | ||
| if (!CoreUtils.isNullOrEmpty(options.getRoles())) { |
There was a problem hiding this comment.
Thanks for fixing this. Can you also add some tests to ensure these cases are covered?
There was a problem hiding this comment.
Tests are added. In the test, I tested generate token from Azure AD token credential, and use the existing test data which includes setting roles and groups, and I also add data on special characters like & and ,. /cc @vicancy
| public void testTokenGenerationFromAadCredential() throws ParseException { | ||
| @ParameterizedTest | ||
| @MethodSource("getTokenOptions") | ||
| @DoNotRecord(skipInPlayback = true) |
There was a problem hiding this comment.
remember to delete the json with token.
weidongxu-microsoft
left a comment
There was a problem hiding this comment.
LGTM
good job on the fix.
Co-authored-by: Weidong Xu <[email protected]>
Description
Fix #31975.
azure-rest-api-spec: Azure/azure-rest-api-specs#20762
Implclasses under 'impl' folder are all generated.removeConnectionFromAllGroupsWithResponseinterface.groupfor/api/hubs/{hub}/:generateToken.""as content type to pass non-null check inimplclasses, I have checked in LIVE test that the content-type passed in through RequestOptions appears in the real HTTP request.WebPubSubServiceClient.getClientAccessToken()All SDK Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines