diff --git a/sdk/networkanalytics/azure-resourcemanager-networkanalytics/src/test/java/com/azure/resourcemanager/networkanalytics/NetworkAnalyticsManagerTests.java b/sdk/networkanalytics/azure-resourcemanager-networkanalytics/src/test/java/com/azure/resourcemanager/networkanalytics/NetworkAnalyticsManagerTests.java new file mode 100644 index 0000000000000..1509e92933314 --- /dev/null +++ b/sdk/networkanalytics/azure-resourcemanager-networkanalytics/src/test/java/com/azure/resourcemanager/networkanalytics/NetworkAnalyticsManagerTests.java @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.resourcemanager.networkanalytics; + +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; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.test.TestBase; +import com.azure.core.test.annotation.LiveOnly; +import com.azure.identity.DefaultAzureCredentialBuilder; +import org.junit.jupiter.api.Test; + +public class NetworkAnalyticsManagerTests extends TestBase { + private NetworkAnalyticsManager networkAnalyticsManager = null; + + @Override + public void beforeTest() { + final TokenCredential credential = new DefaultAzureCredentialBuilder().build(); + final AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE); + + networkAnalyticsManager = NetworkAnalyticsManager + .configure() + .withLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)) + .authenticate(credential, profile); + } + + @Test + @LiveOnly + public void testListDataProducts() { + networkAnalyticsManager.dataProducts().list(); + } +} diff --git a/sdk/networkanalytics/test-resources.bicep b/sdk/networkanalytics/test-resources.bicep new file mode 100644 index 0000000000000..2250946806c02 --- /dev/null +++ b/sdk/networkanalytics/test-resources.bicep @@ -0,0 +1,27 @@ +@description('The tenant id to which the application and resources belong.') +param tenantId string = '72f988bf-86f1-41af-91ab-2d7cd011db47' + +@description('The client id of the service principal used to run tests.') +param testApplicationId string + +@description('This is the object id of the service principal used to run tests.') +param testApplicationOid string + +@description('The application client secret used to run tests.') +param testApplicationSecret string + +var contributorRoleId = '/subscriptions/${subscription().subscriptionId}/providers/Microsoft.Authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c' + +resource contributorRoleId_name 'Microsoft.Authorization/roleAssignments@2022-04-01' = { + name: guid('contributorRoleId${resourceGroup().name}') + properties: { + roleDefinitionId: contributorRoleId + principalId: testApplicationOid + } +} + +output AZURE_TENANT_ID string = tenantId +output AZURE_CLIENT_ID string = testApplicationId +output AZURE_CLIENT_SECRET string = testApplicationSecret +output AZURE_SUBSCRIPTION_ID string = subscription().subscriptionId +output AZURE_RESOURCE_GROUP_NAME string = resourceGroup().name diff --git a/sdk/networkanalytics/tests.mgmt.yml b/sdk/networkanalytics/tests.mgmt.yml new file mode 100644 index 0000000000000..1bd91b1193f05 --- /dev/null +++ b/sdk/networkanalytics/tests.mgmt.yml @@ -0,0 +1,16 @@ +trigger: none + +pr: none + +extends: + template: /eng/pipelines/templates/stages/archetype-sdk-tests.yml + parameters: + ServiceDirectory: networkanalytics + Artifacts: + - name: azure-resourcemanager-networkanalytics + groupId: com.azure.resourcemanager + safeName: azureresourcemanagernetworkanalytics + Clouds: 'Public' + # Only run tests on Windows to save cost. + MatrixFilters: + - pool=.*(win).*