File tree Expand file tree Collapse file tree 4 files changed +53
-8
lines changed
core/Azure.Core.TestFramework/src
Azure.Extensions.AspNetCore.DataProtection.Blobs/tests Expand file tree Collapse file tree 4 files changed +53
-8
lines changed Original file line number Diff line number Diff line change @@ -127,6 +127,7 @@ tools/*.dll
127127* .pfx
128128TestConfigurations.xml
129129* .json.env
130+ * .bicep.env
130131
131132# Backup & report files from converting an old project file to a newer
132133# Visual Studio version. Backup files are not needed, because we have git ;-)
Original file line number Diff line number Diff line change @@ -60,16 +60,26 @@ protected TestEnvironment()
6060
6161 _prefix = serviceName . ToUpperInvariant ( ) + "_" ;
6262
63- var testEnvironmentFile = Path . Combine ( serviceSdkDirectory , "test-resources.json.env" ) ;
64- if ( File . Exists ( testEnvironmentFile ) )
63+ var testEnvironmentFiles = new [ ]
6564 {
66- var json = JsonDocument . Parse (
67- ProtectedData . Unprotect ( File . ReadAllBytes ( testEnvironmentFile ) , null , DataProtectionScope . CurrentUser )
68- ) ;
65+ Path . Combine ( serviceSdkDirectory , "test-resources.bicep.env" ) ,
66+ Path . Combine ( serviceSdkDirectory , "test-resources.json.env" )
67+ } ;
6968
70- foreach ( var property in json . RootElement . EnumerateObject ( ) )
69+ foreach ( var testEnvironmentFile in testEnvironmentFiles )
70+ {
71+ if ( File . Exists ( testEnvironmentFile ) )
7172 {
72- _environmentFile [ property . Name ] = property . Value . GetString ( ) ;
73+ var json = JsonDocument . Parse (
74+ ProtectedData . Unprotect ( File . ReadAllBytes ( testEnvironmentFile ) , null , DataProtectionScope . CurrentUser )
75+ ) ;
76+
77+ foreach ( var property in json . RootElement . EnumerateObject ( ) )
78+ {
79+ _environmentFile [ property . Name ] = property . Value . GetString ( ) ;
80+ }
81+
82+ break ;
7383 }
7484 }
7585 }
Original file line number Diff line number Diff line change 22// Licensed under the MIT License.
33
44using System ;
5+ using System . IO ;
6+ using System . Threading . Tasks ;
57using Azure . Core . TestFramework ;
8+ using Azure . Storage . Blobs ;
69
710namespace Azure . Extensions . AspNetCore . DataProtection . Blobs . Tests
811{
912 public class DataProtectionTestEnvironment : TestEnvironment
1013 {
1114 public Uri BlobStorageEndpoint => new ( GetVariable ( "BLOB_STORAGE_ENDPOINT" ) ) ;
15+
16+ protected override async ValueTask < bool > IsEnvironmentReadyAsync ( )
17+ {
18+ try
19+ {
20+ var client = new BlobServiceClient ( BlobStorageEndpoint , Credential ) ;
21+ var container = client . GetBlobContainerClient ( "test" ) ;
22+ await container . CreateIfNotExistsAsync ( ) ;
23+
24+ var blob = container . GetBlobClient ( "test-blob" ) ;
25+ await blob . UploadAsync ( new MemoryStream ( ) ) ;
26+ await blob . DeleteAsync ( ) ;
27+ await container . DeleteAsync ( ) ;
28+
29+ return await base . IsEnvironmentReadyAsync ( ) ;
30+ }
31+ catch ( RequestFailedException e ) when ( e is { Status : 403 } )
32+ {
33+ return false ;
34+ }
35+ }
1236 }
1337}
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ resource keyVault 'Microsoft.KeyVault/vaults@2019-09-01' = {
1616 properties : {
1717 sku : {
1818 family : 'A'
19- name : 'premium '
19+ name : 'standard '
2020 }
2121 tenantId : tenantId
2222 accessPolicies : [
@@ -93,5 +93,15 @@ resource blobAcount 'Microsoft.Storage/storageAccounts@2019-04-01' = {
9393 }
9494}
9595
96+ var blobDataContributorRole = 'ba92f5b4-2d11-453d-a403-e96b0029c9fe'
97+ resource blobContributorAssignment 'Microsoft.Authorization/roleAssignments@2018-09-01-preview' = {
98+ name : guid (resourceGroup ().id , testApplicationOid , blobDataContributorRole )
99+ scope : resourceGroup ()
100+ properties : {
101+ principalId : testApplicationOid
102+ roleDefinitionId : resourceId ('Microsoft.Authorization/roleDefinitions' , blobDataContributorRole )
103+ }
104+ }
105+
96106output AZURE_KEYVAULT_URL string = keyVault .properties .vaultUri
97107output BLOB_STORAGE_ENDPOINT string = blobAcount .properties .primaryEndpoints .blob
You can’t perform that action at this time.
0 commit comments