forked from Azure/azure-sdk-for-net
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BlobTestEnvironment.cs
32 lines (29 loc) · 996 Bytes
/
BlobTestEnvironment.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System;
using System.Threading.Tasks;
using Azure.Core.TestFramework;
using Azure.Storage.Test;
using Azure.Storage.Test.Shared;
namespace Azure.Storage.Blobs.Tests
{
public class BlobTestEnvironment : StorageTestEnvironment
{
protected override Task<bool> IsEnvironmentReady()
{
return DoesOAuthWork();
}
private async Task<bool> DoesOAuthWork()
{
BlobServiceClient blobServiceClient = new BlobServiceClient(new Uri(TestConfigurations.DefaultTargetOAuthTenant.BlobServiceEndpoint), OAuthCredential);
try
{
await blobServiceClient.GetPropertiesAsync();
} catch (RequestFailedException e) when (e.Status == 403 && e.ErrorCode == "AuthorizationPermissionMismatch")
{
return false;
}
return true;
}
}
}