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

Microsoft Purview Share: Migrate Test Recordings to Assets Repo #35458

Merged
merged 4 commits into from
Jun 14, 2023
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
6 changes: 6 additions & 0 deletions sdk/purview/azure-analytics-purview-sharing/assets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "java",
"TagPrefix": "java/purview/azure-analytics-purview-sharing",
"Tag": "java/purview/azure-analytics-purview-sharing_a2d7d40737"
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
import com.azure.core.http.policy.HttpLogOptions;
import com.azure.core.http.rest.RequestOptions;
import com.azure.core.http.rest.Response;
import com.azure.core.test.TestBase;
import com.azure.core.test.TestMode;
import com.azure.core.test.TestProxyTestBase;
import com.azure.core.test.utils.MockTokenCredential;
import com.azure.core.util.BinaryData;
import com.azure.core.util.Configuration;
import com.azure.core.util.polling.SyncPoller;
import com.azure.identity.DefaultAzureCredentialBuilder;

class PurviewShareTestBase extends TestBase {
class PurviewShareTestBase extends TestProxyTestBase {

protected ReceivedSharesClient receivedSharesClient;

Expand All @@ -54,11 +54,16 @@ protected void beforeTest() {
this.initializeReceivedShareClient();
this.initializeShareResourceClient();

clientId = Configuration.getGlobalConfiguration().get("AZURE_CLIENT_ID", "6a2919d0-880a-4ed8-B50d-7abe4d74291c");
targetActiveDirectoryId = Configuration.getGlobalConfiguration().get("AZURE_TENANT_ID", "4653a7b2-02ff-4155-8e55-2d0c7f3178a1");
targetObjectId = Configuration.getGlobalConfiguration().get("TARGET_OBJECT_ID", "789516ef-5d52-4d56-806d-3ab2d49b0356");
providerStorageAccountResourceId = Configuration.getGlobalConfiguration().get("PROVIDER_STORAGE_RESOURCE_ID", "/subscriptions/8af54e97-8629-48cd-A92e-24753982bf92/resourceGroups/my-resource-group/providers/Microsoft.Storage/storageAccounts/providerstorage");
consumerStorageAccountResourceId = Configuration.getGlobalConfiguration().get("CONSUMER_STORAGE_RESOURCE_ID", "/subscriptions/8af54e97-8629-48cd-A92e-24753982bf92/resourceGroups/my-resource-group/providers/Microsoft.Storage/storageAccounts/consumerstorage");
clientId = Configuration.getGlobalConfiguration().get("AZURE_CLIENT_ID",
"6a2919d0-880a-4ed8-B50d-7abe4d74291c");
targetActiveDirectoryId = Configuration.getGlobalConfiguration().get("AZURE_TENANT_ID",
"4653a7b2-02ff-4155-8e55-2d0c7f3178a1");
targetObjectId = Configuration.getGlobalConfiguration().get("TARGET_OBJECT_ID",
"789516ef-5d52-4d56-806d-3ab2d49b0356");
providerStorageAccountResourceId = Configuration.getGlobalConfiguration().get("PROVIDER_STORAGE_RESOURCE_ID",
"/subscriptions/8af54e97-8629-48cd-A92e-24753982bf92/resourceGroups/my-resource-group/providers/Microsoft.Storage/storageAccounts/providerstorage");
consumerStorageAccountResourceId = Configuration.getGlobalConfiguration().get("CONSUMER_STORAGE_RESOURCE_ID",
"/subscriptions/8af54e97-8629-48cd-A92e-24753982bf92/resourceGroups/my-resource-group/providers/Microsoft.Storage/storageAccounts/consumerstorage");
consumerEmail = Configuration.getGlobalConfiguration().get("CONSUMER_EMAIL", "[email protected]");
}

Expand Down Expand Up @@ -110,7 +115,8 @@ protected Response<BinaryData> createSentShareAndServiceInvitation(UUID sentShar

private void initializeReceivedShareClient() {
ReceivedSharesClientBuilder receivedSharesClientbuilder = new ReceivedSharesClientBuilder()
.endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "https://account.purview.azure.com/share"))
.endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT",
"https://account.purview.azure.com/share"))
.httpClient(HttpClient.createDefault())
.httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC));
if (getTestMode() == TestMode.PLAYBACK) {
Expand All @@ -128,7 +134,8 @@ private void initializeReceivedShareClient() {

private void initializeSentShareClient() {
SentSharesClientBuilder sentSharesClientbuilder = new SentSharesClientBuilder()
.endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "https://account.purview.azure.com/share"))
.endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT",
"https://account.purview.azure.com/share"))
.httpClient(HttpClient.createDefault())
.httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC));
if (getTestMode() == TestMode.PLAYBACK) {
Expand All @@ -145,18 +152,16 @@ private void initializeSentShareClient() {
}

private void initializeShareResourceClient() {
ShareResourcesClientBuilder shareResourcesClientbuilder =
new ShareResourcesClientBuilder()
.endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "https://account.purview.azure.com/share"))
.httpClient(HttpClient.createDefault())
.httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC));
ShareResourcesClientBuilder shareResourcesClientbuilder = new ShareResourcesClientBuilder()
.endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT",
"https://account.purview.azure.com/share"))
.httpClient(HttpClient.createDefault())
.httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC));
if (getTestMode() == TestMode.PLAYBACK) {
shareResourcesClientbuilder
.httpClient(interceptorManager.getPlaybackClient())
shareResourcesClientbuilder.httpClient(interceptorManager.getPlaybackClient())
.credential(new MockTokenCredential());
} else if (getTestMode() == TestMode.RECORD) {
shareResourcesClientbuilder
.addPolicy(interceptorManager.getRecordPolicy())
shareResourcesClientbuilder.addPolicy(interceptorManager.getRecordPolicy())
.credential(new DefaultAzureCredentialBuilder().build());
} else if (getTestMode() == TestMode.LIVE) {
shareResourcesClientbuilder.credential(new DefaultAzureCredentialBuilder().build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.time.OffsetDateTime;
import java.time.ZoneOffset;
import java.util.UUID;

import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -51,7 +52,7 @@ void createSentShareUserInvitation() {
UserInvitation sentShareInvitation = new UserInvitation()
.setTargetEmail(super.consumerEmail)
.setNotify(true)
.setExpirationDate(OffsetDateTime.now().plusDays(60));
.setExpirationDate(OffsetDateTime.of(2500, 1, 1, 1, 1, 1, 1, ZoneOffset.UTC));

Response<BinaryData> invitationResponse = sentSharesClient.createSentShareInvitationWithResponse(
sentShareId.toString(), sentShareInvitationId, BinaryData.fromObject(sentShareInvitation),
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading