From 067089cfc04bb27c3182e243ba272acb71e33b45 Mon Sep 17 00:00:00 2001 From: hongli750210 Date: Mon, 16 Dec 2024 17:36:29 +0800 Subject: [PATCH 1/2] Register provider via policy Part four --- .../fluidrelay/FluidRelayManagerTests.java | 10 ++++++---- .../frontdoor/FrontDoorManagerTests.java | 10 ++++++---- .../healthcareapis/HealthcareApisManagerTests.java | 10 ++++++---- .../imagebuilder/ImageBuilderManagerTests.java | 13 ++++++++----- .../resourcemanager/kusto/KustoManagerTests.java | 10 ++++++---- 5 files changed, 32 insertions(+), 21 deletions(-) diff --git a/sdk/fluidrelay/azure-resourcemanager-fluidrelay/src/test/java/com/azure/resourcemanager/fluidrelay/FluidRelayManagerTests.java b/sdk/fluidrelay/azure-resourcemanager-fluidrelay/src/test/java/com/azure/resourcemanager/fluidrelay/FluidRelayManagerTests.java index 78ba328ec3a02..c34a141c99caf 100644 --- a/sdk/fluidrelay/azure-resourcemanager-fluidrelay/src/test/java/com/azure/resourcemanager/fluidrelay/FluidRelayManagerTests.java +++ b/sdk/fluidrelay/azure-resourcemanager-fluidrelay/src/test/java/com/azure/resourcemanager/fluidrelay/FluidRelayManagerTests.java @@ -16,6 +16,7 @@ import com.azure.identity.AzurePowerShellCredentialBuilder; import com.azure.resourcemanager.fluidrelay.models.FluidRelayServer; import com.azure.resourcemanager.resources.ResourceManager; +import com.azure.resourcemanager.resources.fluentcore.policy.ProviderRegistrationPolicy; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -34,15 +35,16 @@ public void beforeTest() { final TokenCredential credential = new AzurePowerShellCredentialBuilder().build(); final AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE); - fluidRelayManager = FluidRelayManager.configure() - .withLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)) - .authenticate(credential, profile); - resourceManager = ResourceManager.configure() .withLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)) .authenticate(credential, profile) .withDefaultSubscription(); + fluidRelayManager = FluidRelayManager.configure() + .withPolicy(new ProviderRegistrationPolicy(resourceManager)) + .withLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)) + .authenticate(credential, profile); + // use AZURE_RESOURCE_GROUP_NAME if run in LIVE CI String testResourceGroup = Configuration.getGlobalConfiguration().get("AZURE_RESOURCE_GROUP_NAME"); testEnv = !CoreUtils.isNullOrEmpty(testResourceGroup); diff --git a/sdk/frontdoor/azure-resourcemanager-frontdoor/src/test/java/com/azure/resourcemanager/frontdoor/FrontDoorManagerTests.java b/sdk/frontdoor/azure-resourcemanager-frontdoor/src/test/java/com/azure/resourcemanager/frontdoor/FrontDoorManagerTests.java index 2a268993cf1e5..ec3bf55422ddf 100644 --- a/sdk/frontdoor/azure-resourcemanager-frontdoor/src/test/java/com/azure/resourcemanager/frontdoor/FrontDoorManagerTests.java +++ b/sdk/frontdoor/azure-resourcemanager-frontdoor/src/test/java/com/azure/resourcemanager/frontdoor/FrontDoorManagerTests.java @@ -16,6 +16,7 @@ import com.azure.identity.AzurePowerShellCredentialBuilder; import com.azure.resourcemanager.frontdoor.models.WebApplicationFirewallPolicy; import com.azure.resourcemanager.resources.ResourceManager; +import com.azure.resourcemanager.resources.fluentcore.policy.ProviderRegistrationPolicy; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -34,15 +35,16 @@ public void beforeTest() { final TokenCredential credential = new AzurePowerShellCredentialBuilder().build(); final AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE); - frontDoorManager = FrontDoorManager.configure() - .withLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)) - .authenticate(credential, profile); - resourceManager = ResourceManager.configure() .withLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)) .authenticate(credential, profile) .withDefaultSubscription(); + frontDoorManager = FrontDoorManager.configure() + .withPolicy(new ProviderRegistrationPolicy(resourceManager)) + .withLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)) + .authenticate(credential, profile); + // use AZURE_RESOURCE_GROUP_NAME if run in LIVE CI String testResourceGroup = Configuration.getGlobalConfiguration().get("AZURE_RESOURCE_GROUP_NAME"); testEnv = !CoreUtils.isNullOrEmpty(testResourceGroup); diff --git a/sdk/healthcareapis/azure-resourcemanager-healthcareapis/src/test/java/com/azure/resourcemanager/healthcareapis/HealthcareApisManagerTests.java b/sdk/healthcareapis/azure-resourcemanager-healthcareapis/src/test/java/com/azure/resourcemanager/healthcareapis/HealthcareApisManagerTests.java index 7e074dbbdea8c..52a90b518e779 100644 --- a/sdk/healthcareapis/azure-resourcemanager-healthcareapis/src/test/java/com/azure/resourcemanager/healthcareapis/HealthcareApisManagerTests.java +++ b/sdk/healthcareapis/azure-resourcemanager-healthcareapis/src/test/java/com/azure/resourcemanager/healthcareapis/HealthcareApisManagerTests.java @@ -16,6 +16,7 @@ import com.azure.identity.AzurePowerShellCredentialBuilder; import com.azure.resourcemanager.healthcareapis.models.*; import com.azure.resourcemanager.resources.ResourceManager; +import com.azure.resourcemanager.resources.fluentcore.policy.ProviderRegistrationPolicy; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -34,15 +35,16 @@ public void beforeTest() { final TokenCredential credential = new AzurePowerShellCredentialBuilder().build(); final AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE); - healthcareApisManager = HealthcareApisManager.configure() - .withLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)) - .authenticate(credential, profile); - resourceManager = ResourceManager.configure() .withLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)) .authenticate(credential, profile) .withDefaultSubscription(); + healthcareApisManager = HealthcareApisManager.configure() + .withPolicy(new ProviderRegistrationPolicy(resourceManager)) + .withLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)) + .authenticate(credential, profile); + // use AZURE_RESOURCE_GROUP_NAME if run in LIVE CI String testResourceGroup = Configuration.getGlobalConfiguration().get("AZURE_RESOURCE_GROUP_NAME"); testEnv = !CoreUtils.isNullOrEmpty(testResourceGroup); diff --git a/sdk/imagebuilder/azure-resourcemanager-imagebuilder/src/test/java/com/azure/resourcemanager/imagebuilder/ImageBuilderManagerTests.java b/sdk/imagebuilder/azure-resourcemanager-imagebuilder/src/test/java/com/azure/resourcemanager/imagebuilder/ImageBuilderManagerTests.java index 380dc052f0a2e..95d82fb588fdb 100644 --- a/sdk/imagebuilder/azure-resourcemanager-imagebuilder/src/test/java/com/azure/resourcemanager/imagebuilder/ImageBuilderManagerTests.java +++ b/sdk/imagebuilder/azure-resourcemanager-imagebuilder/src/test/java/com/azure/resourcemanager/imagebuilder/ImageBuilderManagerTests.java @@ -25,6 +25,7 @@ import com.azure.resourcemanager.msi.MsiManager; import com.azure.resourcemanager.msi.models.Identity; import com.azure.resourcemanager.resources.ResourceManager; +import com.azure.resourcemanager.resources.fluentcore.policy.ProviderRegistrationPolicy; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -47,19 +48,21 @@ public void beforeTest() { final TokenCredential credential = new AzurePowerShellCredentialBuilder().build(); final AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE); + resourceManager = ResourceManager.configure() + .withLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)) + .authenticate(credential, profile) + .withDefaultSubscription(); + imageBuilderManager = ImageBuilderManager.configure() + .withPolicy(new ProviderRegistrationPolicy(resourceManager)) .withLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)) .authenticate(credential, profile); msiManager = MsiManager.configure() + .withPolicy(new ProviderRegistrationPolicy(resourceManager)) .withLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)) .authenticate(credential, profile); - resourceManager = ResourceManager.configure() - .withLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)) - .authenticate(credential, profile) - .withDefaultSubscription(); - // use AZURE_RESOURCE_GROUP_NAME if run in LIVE CI String testResourceGroup = Configuration.getGlobalConfiguration().get("AZURE_RESOURCE_GROUP_NAME"); testEnv = !CoreUtils.isNullOrEmpty(testResourceGroup); diff --git a/sdk/kusto/azure-resourcemanager-kusto/src/test/java/com/azure/resourcemanager/kusto/KustoManagerTests.java b/sdk/kusto/azure-resourcemanager-kusto/src/test/java/com/azure/resourcemanager/kusto/KustoManagerTests.java index 214a7afe1697e..6457afbb1bc34 100644 --- a/sdk/kusto/azure-resourcemanager-kusto/src/test/java/com/azure/resourcemanager/kusto/KustoManagerTests.java +++ b/sdk/kusto/azure-resourcemanager-kusto/src/test/java/com/azure/resourcemanager/kusto/KustoManagerTests.java @@ -19,6 +19,7 @@ import com.azure.resourcemanager.kusto.models.AzureSkuTier; import com.azure.resourcemanager.kusto.models.Cluster; import com.azure.resourcemanager.resources.ResourceManager; +import com.azure.resourcemanager.resources.fluentcore.policy.ProviderRegistrationPolicy; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -37,15 +38,16 @@ public void beforeTest() { final TokenCredential credential = new AzurePowerShellCredentialBuilder().build(); final AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE); - kustoManager = KustoManager.configure() - .withLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)) - .authenticate(credential, profile); - resourceManager = ResourceManager.configure() .withLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)) .authenticate(credential, profile) .withDefaultSubscription(); + kustoManager = KustoManager.configure() + .withPolicy(new ProviderRegistrationPolicy(resourceManager)) + .withLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)) + .authenticate(credential, profile); + // use AZURE_RESOURCE_GROUP_NAME if run in LIVE CI String testResourceGroup = Configuration.getGlobalConfiguration().get("AZURE_RESOURCE_GROUP_NAME"); testEnv = !CoreUtils.isNullOrEmpty(testResourceGroup); From 1b9b76e9de02ac3351245ff6423357800d6fda4b Mon Sep 17 00:00:00 2001 From: hongli750210 Date: Mon, 16 Dec 2024 17:40:53 +0800 Subject: [PATCH 2/2] Register provider via policy Part four --- .../iotcentral/IotCentralManagerTests.java | 10 ++++++---- .../IoTFirmwareDefenseManagerTests.java | 10 ++++++---- .../resourcemanager/iothub/IotHubManagerTests.java | 10 ++++++---- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/sdk/iotcentral/azure-resourcemanager-iotcentral/src/test/java/com/azure/resourcemanager/iotcentral/IotCentralManagerTests.java b/sdk/iotcentral/azure-resourcemanager-iotcentral/src/test/java/com/azure/resourcemanager/iotcentral/IotCentralManagerTests.java index 5f326702fdfea..d249730ebb177 100644 --- a/sdk/iotcentral/azure-resourcemanager-iotcentral/src/test/java/com/azure/resourcemanager/iotcentral/IotCentralManagerTests.java +++ b/sdk/iotcentral/azure-resourcemanager-iotcentral/src/test/java/com/azure/resourcemanager/iotcentral/IotCentralManagerTests.java @@ -23,6 +23,7 @@ import com.azure.resourcemanager.iotcentral.models.SystemAssignedServiceIdentity; import com.azure.resourcemanager.iotcentral.models.SystemAssignedServiceIdentityType; import com.azure.resourcemanager.resources.ResourceManager; +import com.azure.resourcemanager.resources.fluentcore.policy.ProviderRegistrationPolicy; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -42,15 +43,16 @@ public void beforeTest() { final TokenCredential credential = new AzurePowerShellCredentialBuilder().build(); final AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE); - iotCentralManager = IotCentralManager.configure() - .withLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)) - .authenticate(credential, profile); - resourceManager = ResourceManager.configure() .withLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)) .authenticate(credential, profile) .withDefaultSubscription(); + iotCentralManager = IotCentralManager.configure() + .withPolicy(new ProviderRegistrationPolicy(resourceManager)) + .withLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)) + .authenticate(credential, profile); + // use AZURE_RESOURCE_GROUP_NAME if run in LIVE CI String testResourceGroup = Configuration.getGlobalConfiguration().get("AZURE_RESOURCE_GROUP_NAME"); testEnv = !CoreUtils.isNullOrEmpty(testResourceGroup); diff --git a/sdk/iotfirmwaredefense/azure-resourcemanager-iotfirmwaredefense/src/test/java/com/azure/resourcemanager/iotfirmwaredefense/IoTFirmwareDefenseManagerTests.java b/sdk/iotfirmwaredefense/azure-resourcemanager-iotfirmwaredefense/src/test/java/com/azure/resourcemanager/iotfirmwaredefense/IoTFirmwareDefenseManagerTests.java index b21f21cf34943..e6c67960f5e10 100644 --- a/sdk/iotfirmwaredefense/azure-resourcemanager-iotfirmwaredefense/src/test/java/com/azure/resourcemanager/iotfirmwaredefense/IoTFirmwareDefenseManagerTests.java +++ b/sdk/iotfirmwaredefense/azure-resourcemanager-iotfirmwaredefense/src/test/java/com/azure/resourcemanager/iotfirmwaredefense/IoTFirmwareDefenseManagerTests.java @@ -16,6 +16,7 @@ import com.azure.identity.AzurePowerShellCredentialBuilder; import com.azure.resourcemanager.iotfirmwaredefense.models.Workspace; import com.azure.resourcemanager.resources.ResourceManager; +import com.azure.resourcemanager.resources.fluentcore.policy.ProviderRegistrationPolicy; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -34,15 +35,16 @@ public void beforeTest() { final TokenCredential credential = new AzurePowerShellCredentialBuilder().build(); final AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE); - ioTFirmwareDefenseManager = IoTFirmwareDefenseManager.configure() - .withLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)) - .authenticate(credential, profile); - resourceManager = ResourceManager.configure() .withLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)) .authenticate(credential, profile) .withDefaultSubscription(); + ioTFirmwareDefenseManager = IoTFirmwareDefenseManager.configure() + .withPolicy(new ProviderRegistrationPolicy(resourceManager)) + .withLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)) + .authenticate(credential, profile); + // use AZURE_RESOURCE_GROUP_NAME if run in LIVE CI String testResourceGroup = Configuration.getGlobalConfiguration().get("AZURE_RESOURCE_GROUP_NAME"); testEnv = !CoreUtils.isNullOrEmpty(testResourceGroup); diff --git a/sdk/iothub/azure-resourcemanager-iothub/src/test/java/com/azure/resourcemanager/iothub/IotHubManagerTests.java b/sdk/iothub/azure-resourcemanager-iothub/src/test/java/com/azure/resourcemanager/iothub/IotHubManagerTests.java index bd55047f74ee5..038bf020ec195 100644 --- a/sdk/iothub/azure-resourcemanager-iothub/src/test/java/com/azure/resourcemanager/iothub/IotHubManagerTests.java +++ b/sdk/iothub/azure-resourcemanager-iothub/src/test/java/com/azure/resourcemanager/iothub/IotHubManagerTests.java @@ -30,6 +30,7 @@ import com.azure.resourcemanager.iothub.models.ResourceIdentityType; import com.azure.resourcemanager.iothub.models.StorageEndpointProperties; import com.azure.resourcemanager.resources.ResourceManager; +import com.azure.resourcemanager.resources.fluentcore.policy.ProviderRegistrationPolicy; import io.netty.util.internal.StringUtil; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -54,15 +55,16 @@ public void beforeTest() { final TokenCredential credential = new AzurePowerShellCredentialBuilder().build(); final AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE); - iotHubManager = IotHubManager.configure() - .withLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)) - .authenticate(credential, profile); - resourceManager = ResourceManager.configure() .withLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)) .authenticate(credential, profile) .withDefaultSubscription(); + iotHubManager = IotHubManager.configure() + .withPolicy(new ProviderRegistrationPolicy(resourceManager)) + .withLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)) + .authenticate(credential, profile); + // use AZURE_RESOURCE_GROUP_NAME if run in LIVE CI String testResourceGroup = Configuration.getGlobalConfiguration().get("AZURE_RESOURCE_GROUP_NAME"); testEnv = !CoreUtils.isNullOrEmpty(testResourceGroup);