Skip to content
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

Register provider via policy Part Three #43424

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.azure.identity.AzurePowerShellCredentialBuilder;
import com.azure.resourcemanager.dashboard.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;

Expand All @@ -34,15 +35,16 @@ public void beforeTest() {
final TokenCredential credential = new AzurePowerShellCredentialBuilder().build();
final AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE);

dashboardManager = DashboardManager.configure()
.withLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC))
.authenticate(credential, profile);

resourceManager = ResourceManager.configure()
.withLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC))
.authenticate(credential, profile)
.withDefaultSubscription();

dashboardManager = DashboardManager.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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

package com.azure.resourcemanager.datafactory;

import com.azure.core.credential.TokenCredential;
import com.azure.core.http.policy.HttpLogDetailLevel;
import com.azure.core.http.policy.HttpLogOptions;
import com.azure.core.management.AzureEnvironment;
Expand All @@ -26,6 +27,8 @@
import com.azure.resourcemanager.datafactory.models.PipelineResource;
import com.azure.resourcemanager.datafactory.models.PipelineRun;
import com.azure.resourcemanager.datafactory.models.TextFormat;
import com.azure.resourcemanager.resources.ResourceManager;
import com.azure.resourcemanager.resources.fluentcore.policy.ProviderRegistrationPolicy;
import com.azure.resourcemanager.storage.StorageManager;
import com.azure.resourcemanager.storage.models.PublicAccess;
import com.azure.resourcemanager.storage.models.StorageAccount;
Expand All @@ -51,19 +54,29 @@ public class DataFactoryTests extends TestProxyTestBase {
@Test
@LiveOnly
public void dataFactoryTest() {
StorageManager storageManager = StorageManager.authenticate(new AzurePowerShellCredentialBuilder().build(),
new AzureProfile(AzureEnvironment.AZURE));
TokenCredential credential = new AzurePowerShellCredentialBuilder().build();
AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE);

ResourceManager resourceManager = ResourceManager.configure()
.withLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC))
.authenticate(credential, profile)
.withDefaultSubscription();

StorageManager storageManager = StorageManager.configure()
.withPolicy(new ProviderRegistrationPolicy(resourceManager))
.authenticate(credential, profile);

DataFactoryManager manager = DataFactoryManager.configure()
.withPolicy(new ProviderRegistrationPolicy(resourceManager))
.withLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC))
.authenticate(new AzurePowerShellCredentialBuilder().build(), new AzureProfile(AzureEnvironment.AZURE));
.authenticate(credential, profile);

String testResourceGroup = Configuration.getGlobalConfiguration().get("AZURE_RESOURCE_GROUP_NAME");
boolean testEnv = !CoreUtils.isNullOrEmpty(testResourceGroup);
if (testEnv) {
resourceGroup = testResourceGroup;
} else {
storageManager.resourceManager().resourceGroups().define(resourceGroup).withRegion(REGION).create();
resourceManager.resourceGroups().define(resourceGroup).withRegion(REGION).create();
}

try {
Expand Down Expand Up @@ -169,7 +182,7 @@ public void dataFactoryTest() {
storageManager.storageAccounts().deleteById(storageAccount.id());
} finally {
if (!testEnv) {
storageManager.resourceManager().resourceGroups().beginDeleteByName(resourceGroup);
resourceManager.resourceGroups().beginDeleteByName(resourceGroup);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import com.azure.resourcemanager.dataprotection.models.StorageSettingStoreTypes;
import com.azure.resourcemanager.dataprotection.models.StorageSettingTypes;
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;

Expand All @@ -58,15 +59,16 @@ public void beforeTest() {
final TokenCredential credential = getIdentityTestCredential(super.interceptorManager);
final AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE);

dataProtectionManager = DataProtectionManager.configure()
.withLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC))
.authenticate(credential, profile);

resourceManager = ResourceManager.configure()
.withLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC))
.authenticate(credential, profile)
.withDefaultSubscription();

dataProtectionManager = DataProtectionManager.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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.azure.identity.AzurePowerShellCredentialBuilder;
import com.azure.resourcemanager.deviceupdate.models.Account;
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;

Expand All @@ -35,15 +36,16 @@ public void beforeTest() {
final TokenCredential credential = new AzurePowerShellCredentialBuilder().build();
final AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE);

deviceUpdateManager = DeviceUpdateManager.configure()
.withLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC))
.authenticate(credential, profile);

resourceManager = ResourceManager.configure()
.withLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC))
.authenticate(credential, profile)
.withDefaultSubscription();

deviceUpdateManager = DeviceUpdateManager.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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.azure.identity.AzurePowerShellCredentialBuilder;
import com.azure.resourcemanager.devtestlabs.models.Lab;
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;

Expand All @@ -34,15 +35,16 @@ public void beforeTest() {
final TokenCredential credential = new AzurePowerShellCredentialBuilder().build();
final AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE);

devTestLabsManager = DevTestLabsManager.configure()
.withLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC))
.authenticate(credential, profile);

resourceManager = ResourceManager.configure()
.withLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC))
.authenticate(credential, profile)
.withDefaultSubscription();

devTestLabsManager = DevTestLabsManager.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);
Expand Down
Loading