From a4b9112d981c410321c5584ad2124b6640796750 Mon Sep 17 00:00:00 2001 From: Srikanta Date: Wed, 10 Nov 2021 22:51:47 -0800 Subject: [PATCH 1/4] Remove ErrorOptions --- .../src/main/java/com/azure/core/http/rest/ErrorOptions.java | 2 +- .../src/main/java/com/azure/core/http/rest/RequestOptions.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/core/azure-core/src/main/java/com/azure/core/http/rest/ErrorOptions.java b/sdk/core/azure-core/src/main/java/com/azure/core/http/rest/ErrorOptions.java index 3695c7ddc924a..22e695665f856 100644 --- a/sdk/core/azure-core/src/main/java/com/azure/core/http/rest/ErrorOptions.java +++ b/sdk/core/azure-core/src/main/java/com/azure/core/http/rest/ErrorOptions.java @@ -6,7 +6,7 @@ /** * Determines how errors are handled by requests using {@link RequestOptions}. */ -public enum ErrorOptions { +enum ErrorOptions { /** * Throw exceptions when an HTTP response with a status code indicating an error (400 or above) is received. */ diff --git a/sdk/core/azure-core/src/main/java/com/azure/core/http/rest/RequestOptions.java b/sdk/core/azure-core/src/main/java/com/azure/core/http/rest/RequestOptions.java index 1958b05fd9473..3984b24d0c1f9 100644 --- a/sdk/core/azure-core/src/main/java/com/azure/core/http/rest/RequestOptions.java +++ b/sdk/core/azure-core/src/main/java/com/azure/core/http/rest/RequestOptions.java @@ -255,7 +255,7 @@ public RequestOptions setBody(BinaryData requestBody) { * @throws IllegalArgumentException If both {@link ErrorOptions#THROW} and {@link ErrorOptions#NO_THROW} are * included in {@code errorOptions}. */ - public RequestOptions setErrorOptions(EnumSet errorOptions) { + RequestOptions setErrorOptions(EnumSet errorOptions) { Objects.requireNonNull(errorOptions, "'errorOptions' cannot be null."); if (errorOptions.contains(ErrorOptions.THROW) && errorOptions.contains(ErrorOptions.NO_THROW)) { From 5e261bcfa8531546dda781b0fa3e8079fb0771c0 Mon Sep 17 00:00:00 2001 From: Srikanta Date: Thu, 11 Nov 2021 01:57:31 -0800 Subject: [PATCH 2/4] revapi exclusion --- .../src/main/resources/revapi/revapi.json | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/eng/code-quality-reports/src/main/resources/revapi/revapi.json b/eng/code-quality-reports/src/main/resources/revapi/revapi.json index b1ed129ea5887..4c46a6aa993be 100644 --- a/eng/code-quality-reports/src/main/resources/revapi/revapi.json +++ b/eng/code-quality-reports/src/main/resources/revapi/revapi.json @@ -424,6 +424,16 @@ "code": "java.method.added", "new": "method java.lang.Class com.azure.core.util.serializer.TypeReference::getJavaClass()", "justification": "New method added to TypeReference in azure-core." + }, + { + "code": "java.method.visibilityReduced", + "new": "method com.azure.core.http.rest.RequestOptions com.azure.core.http.rest.RequestOptions::setErrorOptions(java.util.EnumSet)", + "justification": "The use case for ErrorOptions is not yet clear. It will be added later if there are enough data points to suggest this is needed." + }, + { + "code": "java.class.visibilityReduced", + "new": "enum com.azure.core.http.rest.ErrorOptions", + "justification": "The use case for ErrorOptions is not yet clear. It will be added later if there are enough data points to suggest this is needed." } ] } From 2f19841a95e5a836236d0c679774d39ac55e6012 Mon Sep 17 00:00:00 2001 From: Srikanta Date: Thu, 11 Nov 2021 17:51:16 -0800 Subject: [PATCH 3/4] fix unit tests in WPS --- .../webpubsub/WebPubSubServiceClientTests.java | 13 +++++++------ ...bSubServiceClientTests.testCheckPermission.json | 14 ++++++-------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/sdk/webpubsub/azure-messaging-webpubsub/src/test/java/com/azure/messaging/webpubsub/WebPubSubServiceClientTests.java b/sdk/webpubsub/azure-messaging-webpubsub/src/test/java/com/azure/messaging/webpubsub/WebPubSubServiceClientTests.java index cdb72e01ce51a..3f5f96932a61a 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub/src/test/java/com/azure/messaging/webpubsub/WebPubSubServiceClientTests.java +++ b/sdk/webpubsub/azure-messaging-webpubsub/src/test/java/com/azure/messaging/webpubsub/WebPubSubServiceClientTests.java @@ -6,7 +6,6 @@ import com.azure.core.http.HttpClient; import com.azure.core.http.policy.HttpLogDetailLevel; import com.azure.core.http.policy.HttpLogOptions; -import com.azure.core.http.rest.ErrorOptions; import com.azure.core.http.rest.RequestOptions; import com.azure.core.http.rest.Response; import com.azure.core.test.TestBase; @@ -25,11 +24,11 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable; import java.io.ByteArrayInputStream; import java.nio.charset.StandardCharsets; import java.text.ParseException; -import java.util.EnumSet; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; @@ -243,12 +242,14 @@ public void testAadCredential() { } @Test + @DisabledIfEnvironmentVariable(named = "AZURE_TEST_MODE", matches = "LIVE", disabledReason = "This requires real " + + "connection id that is created when a client connects to Web PubSub service. So, run this in PLAYBACK " + + "mode only.") public void testCheckPermission() { RequestOptions requestOptions = new RequestOptions() - .addQueryParam("targetName", "group_name") - .setErrorOptions(EnumSet.of(ErrorOptions.NO_THROW)); - boolean permission = client.checkPermissionWithResponse(WebPubSubPermission.JOIN_LEAVE_GROUP, "connection_id", + .addQueryParam("targetName", "java"); + boolean permission = client.checkPermissionWithResponse(WebPubSubPermission.SEND_TO_GROUP, "71xtjgThROOJ6DsVY3xbBw2ef45fd11", requestOptions).getValue(); - Assertions.assertFalse(permission); + Assertions.assertTrue(permission); } } diff --git a/sdk/webpubsub/azure-messaging-webpubsub/src/test/resources/session-records/WebPubSubServiceClientTests.testCheckPermission.json b/sdk/webpubsub/azure-messaging-webpubsub/src/test/resources/session-records/WebPubSubServiceClientTests.testCheckPermission.json index 0d37604339c70..0bdf33a68217d 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub/src/test/resources/session-records/WebPubSubServiceClientTests.testCheckPermission.json +++ b/sdk/webpubsub/azure-messaging-webpubsub/src/test/resources/session-records/WebPubSubServiceClientTests.testCheckPermission.json @@ -1,19 +1,17 @@ { "networkCallRecords" : [ { "Method" : "HEAD", - "Uri" : "https://REDACTED.webpubsub.azure.com/api/hubs/test/permissions/joinLeaveGroup/connections/connection_id?api-version=2021-10-01&targetName=group_name", + "Uri" : "https://REDACTED.webpubsub.azure.com/api/hubs/test/permissions/sendToGroup/connections/71xtjgThROOJ6DsVY3xbBw2ef45fd11?api-version=2021-10-01&targetName=java", "Headers" : { - "User-Agent" : "azsdk-java-azure-messaging-webpubsub/1.0.0-beta.6 (17; Windows 10; 10.0)" + "User-Agent" : "azsdk-java-azure-messaging-webpubsub/1.0.0-beta.6 (14.0.2; Windows 10; 10.0)" }, "Response" : { - "Server" : "nginx", + "Strict-Transport-Security" : "max-age=15724800; includeSubDomains", + "api-supported-versions" : "2021-10-01", "Connection" : "keep-alive", - "Vary" : "Accept-Encoding,Accept-Encoding", "retry-after" : "0", - "StatusCode" : "404", - "Body" : "", - "Date" : "Wed, 03 Nov 2021 18:51:07 GMT", - "Content-Type" : "text/plain; charset=utf-8" + "StatusCode" : "200", + "Date" : "Fri, 12 Nov 2021 01:49:48 GMT" }, "Exception" : null } ], From 167f1a720359c8ad8fff6e11962722e1f43ab012 Mon Sep 17 00:00:00 2001 From: Srikanta Date: Thu, 11 Nov 2021 23:15:24 -0800 Subject: [PATCH 4/4] fix checkstyle --- .../messaging/webpubsub/WebPubSubServiceClientTests.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sdk/webpubsub/azure-messaging-webpubsub/src/test/java/com/azure/messaging/webpubsub/WebPubSubServiceClientTests.java b/sdk/webpubsub/azure-messaging-webpubsub/src/test/java/com/azure/messaging/webpubsub/WebPubSubServiceClientTests.java index 3f5f96932a61a..6b19fe5771701 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub/src/test/java/com/azure/messaging/webpubsub/WebPubSubServiceClientTests.java +++ b/sdk/webpubsub/azure-messaging-webpubsub/src/test/java/com/azure/messaging/webpubsub/WebPubSubServiceClientTests.java @@ -242,9 +242,9 @@ public void testAadCredential() { } @Test - @DisabledIfEnvironmentVariable(named = "AZURE_TEST_MODE", matches = "LIVE", disabledReason = "This requires real " + - "connection id that is created when a client connects to Web PubSub service. So, run this in PLAYBACK " + - "mode only.") + @DisabledIfEnvironmentVariable(named = "AZURE_TEST_MODE", matches = "LIVE", disabledReason = "This requires real " + + "connection id that is created when a client connects to Web PubSub service. So, run this in PLAYBACK " + + "mode only.") public void testCheckPermission() { RequestOptions requestOptions = new RequestOptions() .addQueryParam("targetName", "java");