diff --git a/eng/versioning/external_dependencies.txt b/eng/versioning/external_dependencies.txt index 76eb25a4cae0d..984a52e60bb3b 100644 --- a/eng/versioning/external_dependencies.txt +++ b/eng/versioning/external_dependencies.txt @@ -210,6 +210,7 @@ org.junit.vintage:junit-vintage-engine;5.7.2 org.openjdk.jmh:jmh-core;1.22 org.openjdk.jmh:jmh-generator-annprocess;1.22 org.spockframework:spock-core;2.0-M4-groovy-2.5 +groovy3_org.spockframework:spock-core;2.0-groovy-3.0 org.testng:testng;7.3.0 uk.org.lidalia:slf4j-test;1.2.0 diff --git a/sdk/storage/azure-storage-blob-batch/pom.xml b/sdk/storage/azure-storage-blob-batch/pom.xml index 22ba1d7091d60..3e00e7eec9837 100644 --- a/sdk/storage/azure-storage-blob-batch/pom.xml +++ b/sdk/storage/azure-storage-blob-batch/pom.xml @@ -124,12 +124,6 @@ 1.6.5 test - - org.spockframework - spock-core - 2.0-M4-groovy-2.5 - test - cglib cglib-nodep @@ -177,6 +171,14 @@ [1.8,9) + + + org.spockframework + spock-core + 2.0-M4-groovy-2.5 + test + + @@ -219,6 +221,14 @@ [9,) + + + org.spockframework + spock-core + 2.0-groovy-3.0 + test + + diff --git a/sdk/storage/azure-storage-blob-batch/src/test/java/com/azure/storage/blob/batch/APISpec.groovy b/sdk/storage/azure-storage-blob-batch/src/test/java/com/azure/storage/blob/batch/APISpec.groovy index cd129f260d050..fee41db07b06a 100644 --- a/sdk/storage/azure-storage-blob-batch/src/test/java/com/azure/storage/blob/batch/APISpec.groovy +++ b/sdk/storage/azure-storage-blob-batch/src/test/java/com/azure/storage/blob/batch/APISpec.groovy @@ -31,23 +31,23 @@ class APISpec extends StorageSpec { BlobServiceClient versionedBlobServiceClient def setup() { - primaryBlobServiceClient = getServiceClient(env.primaryAccount) - primaryBlobServiceAsyncClient = getServiceAsyncClient(env.primaryAccount) - versionedBlobServiceClient = getServiceClient(env.versionedAccount) + primaryBlobServiceClient = getServiceClient(environment.primaryAccount) + primaryBlobServiceAsyncClient = getServiceAsyncClient(environment.primaryAccount) + versionedBlobServiceClient = getServiceClient(environment.versionedAccount) } def getOAuthServiceClient() { BlobServiceClientBuilder builder = new BlobServiceClientBuilder() - .endpoint(env.primaryAccount.blobEndpoint) + .endpoint(environment.primaryAccount.blobEndpoint) instrument(builder) - if (env.testMode != TestMode.PLAYBACK) { + if (environment.testMode != TestMode.PLAYBACK) { // AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET return builder.credential(new EnvironmentCredentialBuilder().build()).buildClient() } else { // Running in playback, we don't have access to the AAD environment variables, just use SharedKeyCredential. - return builder.credential(env.primaryAccount.credential).buildClient() + return builder.credential(environment.primaryAccount.credential).buildClient() } } diff --git a/sdk/storage/azure-storage-blob-batch/src/test/java/com/azure/storage/blob/batch/BatchAPITest.groovy b/sdk/storage/azure-storage-blob-batch/src/test/java/com/azure/storage/blob/batch/BatchAPITest.groovy index 8e23af21acc56..f0038415dd662 100644 --- a/sdk/storage/azure-storage-blob-batch/src/test/java/com/azure/storage/blob/batch/BatchAPITest.groovy +++ b/sdk/storage/azure-storage-blob-batch/src/test/java/com/azure/storage/blob/batch/BatchAPITest.groovy @@ -245,7 +245,7 @@ class BatchAPITest extends APISpec { thrown(BlobBatchStorageException) // In PLAYBACK check responses in an order invariant fashion. - if (env.testMode == TestMode.PLAYBACK) { + if (environment.testMode == TestMode.PLAYBACK) { assert (assertExpectedOrException(response1, 200) + assertExpectedOrException(response2, 200)) == 1 } else { assert response1.getStatusCode() == 200 @@ -280,7 +280,7 @@ class BatchAPITest extends APISpec { .verify(Duration.ofSeconds(30)) // In PLAYBACK check responses in an order invariant fashion. - if (env.testMode == TestMode.PLAYBACK) { + if (environment.testMode == TestMode.PLAYBACK) { assert (assertExpectedOrException(response1, 200) + assertExpectedOrException(response2, 200)) == 1 } else { assert response1.getStatusCode() == 200 @@ -313,7 +313,7 @@ class BatchAPITest extends APISpec { notThrown(BlobBatchStorageException) // In PLAYBACK check responses in an order invariant fashion. - if (env.testMode == TestMode.PLAYBACK) { + if (environment.testMode == TestMode.PLAYBACK) { assert (assertExpectedOrException(response1, 200) + assertExpectedOrException(response2, 200)) == 1 } else { assert response1.getStatusCode() == 200 @@ -435,7 +435,7 @@ class BatchAPITest extends APISpec { thrown(BlobBatchStorageException) // In PLAYBACK check responses in an order invariant fashion. - if (env.testMode == TestMode.PLAYBACK) { + if (environment.testMode == TestMode.PLAYBACK) { assert (assertExpectedOrException(response1, 202) + assertExpectedOrException(response2, 202)) == 1 } else { assert response1.getStatusCode() == 202 @@ -468,7 +468,7 @@ class BatchAPITest extends APISpec { notThrown(BlobStorageException) // In PLAYBACK check responses in an order invariant fashion. - if (env.testMode == TestMode.PLAYBACK) { + if (environment.testMode == TestMode.PLAYBACK) { assert (assertExpectedOrException(response1, 202) + assertExpectedOrException(response2, 202)) == 1 } else { assert response1.getStatusCode() == 202 diff --git a/sdk/storage/azure-storage-blob-changefeed/pom.xml b/sdk/storage/azure-storage-blob-changefeed/pom.xml index 561a7d341543e..ece8e4ec9f805 100644 --- a/sdk/storage/azure-storage-blob-changefeed/pom.xml +++ b/sdk/storage/azure-storage-blob-changefeed/pom.xml @@ -130,12 +130,6 @@ 1.6.5 test - - org.spockframework - spock-core - 2.0-M4-groovy-2.5 - test - cglib cglib-nodep @@ -189,6 +183,14 @@ [1.8,9) + + + org.spockframework + spock-core + 2.0-M4-groovy-2.5 + test + + @@ -231,6 +233,14 @@ [9,) + + + org.spockframework + spock-core + 2.0-groovy-3.0 + test + + diff --git a/sdk/storage/azure-storage-blob-changefeed/src/test/java/com/azure/storage/blob/changefeed/APISpec.groovy b/sdk/storage/azure-storage-blob-changefeed/src/test/java/com/azure/storage/blob/changefeed/APISpec.groovy index fb17e4242a963..7a8e0164665d8 100644 --- a/sdk/storage/azure-storage-blob-changefeed/src/test/java/com/azure/storage/blob/changefeed/APISpec.groovy +++ b/sdk/storage/azure-storage-blob-changefeed/src/test/java/com/azure/storage/blob/changefeed/APISpec.groovy @@ -41,18 +41,18 @@ class APISpec extends StorageSpec { } def setup() { - primaryBlobServiceClient = getServiceClient(env.primaryAccount) - primaryBlobServiceAsyncClient = getServiceAsyncClient(env.primaryAccount) + primaryBlobServiceClient = getServiceClient(environment.primaryAccount) + primaryBlobServiceAsyncClient = getServiceAsyncClient(environment.primaryAccount) containerName = generateContainerName() } def cleanup() { - if (env.testMode != TestMode.PLAYBACK) { + if (environment.testMode != TestMode.PLAYBACK) { def cleanupClient = new BlobServiceClientBuilder() .httpClient(getHttpClient()) - .credential(env.primaryAccount.credential) - .endpoint(env.primaryAccount.blobEndpoint) + .credential(environment.primaryAccount.credential) + .endpoint(environment.primaryAccount.blobEndpoint) .buildClient() def options = new ListBlobContainersOptions().setPrefix(namer.getResourcePrefix()) for (BlobContainerItem container : cleanupClient.listBlobContainers(options, Duration.ofSeconds(120))) { diff --git a/sdk/storage/azure-storage-blob-changefeed/src/test/java/com/azure/storage/blob/changefeed/ChangefeedNetworkTest.groovy b/sdk/storage/azure-storage-blob-changefeed/src/test/java/com/azure/storage/blob/changefeed/ChangefeedNetworkTest.groovy index faa4e10591822..6b9fa78632986 100644 --- a/sdk/storage/azure-storage-blob-changefeed/src/test/java/com/azure/storage/blob/changefeed/ChangefeedNetworkTest.groovy +++ b/sdk/storage/azure-storage-blob-changefeed/src/test/java/com/azure/storage/blob/changefeed/ChangefeedNetworkTest.groovy @@ -7,7 +7,6 @@ import com.azure.storage.blob.changefeed.models.BlobChangefeedEvent import com.azure.storage.common.test.shared.extensions.PlaybackOnly import spock.lang.Ignore import reactor.test.StepVerifier -import spock.lang.Requires import java.time.OffsetDateTime import java.time.ZoneOffset @@ -92,7 +91,7 @@ class ChangefeedNetworkTest extends APISpec { /* Update and uncomment after recording. */ OffsetDateTime startTime = OffsetDateTime.of(2020, 8, 11, 23, 3, 10, 987532200, ZoneOffset.UTC) - Long pollInterval = env.testMode == TestMode.PLAYBACK ? 0 : 1000 * 60 * 3 + Long pollInterval = environment.testMode == TestMode.PLAYBACK ? 0 : 1000 * 60 * 3 Set eventIds1 = new HashSet<>() Set eventIds2 = new HashSet<>() diff --git a/sdk/storage/azure-storage-blob-cryptography/pom.xml b/sdk/storage/azure-storage-blob-cryptography/pom.xml index c4be60042be50..43025232fb529 100644 --- a/sdk/storage/azure-storage-blob-cryptography/pom.xml +++ b/sdk/storage/azure-storage-blob-cryptography/pom.xml @@ -78,13 +78,6 @@ 1.7.1 test - - - org.spockframework - spock-core - 2.0-M4-groovy-2.5 - test - @@ -168,6 +161,14 @@ [1.8,9) + + + org.spockframework + spock-core + 2.0-M4-groovy-2.5 + test + + @@ -210,6 +211,14 @@ [9,) + + + org.spockframework + spock-core + 2.0-groovy-3.0 + test + + diff --git a/sdk/storage/azure-storage-blob-cryptography/src/test/java/com/azure/storage/blob/specialized/cryptography/APISpec.groovy b/sdk/storage/azure-storage-blob-cryptography/src/test/java/com/azure/storage/blob/specialized/cryptography/APISpec.groovy index bc6eb5be25747..f55f037e7ab75 100644 --- a/sdk/storage/azure-storage-blob-cryptography/src/test/java/com/azure/storage/blob/specialized/cryptography/APISpec.groovy +++ b/sdk/storage/azure-storage-blob-cryptography/src/test/java/com/azure/storage/blob/specialized/cryptography/APISpec.groovy @@ -403,7 +403,7 @@ class APISpec extends StorageSpec { * real key this way. */ static def getRandomKey(long seed = new Random().nextLong()) { - if (getEnv().getTestMode() == TestMode.LIVE) { + if (getEnvironment().getTestMode() == TestMode.LIVE) { def key = new byte[32] // 256 bit key new Random(seed).nextBytes(key) return key @@ -417,7 +417,7 @@ class APISpec extends StorageSpec { * and RECORD testing modes only. */ static def mockAesKey(EncryptedBlobAsyncClient encryptedClient) { - if (getEnv().getTestMode() != TestMode.LIVE) { + if (getEnvironment().getTestMode() != TestMode.LIVE) { def mockAesKey = new SecretKey() { @Override String getAlgorithm() { diff --git a/sdk/storage/azure-storage-blob-cryptography/src/test/java/com/azure/storage/blob/specialized/cryptography/BlobCryptographyBuilderTest.groovy b/sdk/storage/azure-storage-blob-cryptography/src/test/java/com/azure/storage/blob/specialized/cryptography/BlobCryptographyBuilderTest.groovy index db877cb691558..d1b5cfe09d507 100644 --- a/sdk/storage/azure-storage-blob-cryptography/src/test/java/com/azure/storage/blob/specialized/cryptography/BlobCryptographyBuilderTest.groovy +++ b/sdk/storage/azure-storage-blob-cryptography/src/test/java/com/azure/storage/blob/specialized/cryptography/BlobCryptographyBuilderTest.groovy @@ -20,10 +20,10 @@ class BlobCryptographyBuilderTest extends APISpec { def setup() { keyId = "keyId" - fakeKey = new FakeKey(keyId, (getEnv().getTestMode() == TestMode.LIVE) ? getRandomByteArray(256) : mockRandomData) + fakeKey = new FakeKey(keyId, (getEnvironment().getTestMode() == TestMode.LIVE) ? getRandomByteArray(256) : mockRandomData) fakeKeyResolver = new FakeKeyResolver(fakeKey) - def sc = getServiceClientBuilder(env.primaryAccount) + def sc = getServiceClientBuilder(environment.primaryAccount) .buildClient() def containerName = generateContainerName() def blobName = generateBlobName() @@ -66,7 +66,7 @@ class BlobCryptographyBuilderTest extends APISpec { def "Http pipeline"() { when: def regularClient = cc.getBlobClient(generateBlobName()) - def encryptedClient = new EncryptedBlobClient(mockAesKey(getEncryptedClientBuilder(fakeKey, null, env.primaryAccount.credential, cc.getBlobContainerUrl()) + def encryptedClient = new EncryptedBlobClient(mockAesKey(getEncryptedClientBuilder(fakeKey, null, environment.primaryAccount.credential, cc.getBlobContainerUrl()) .pipeline(regularClient.getHttpPipeline()) .blobName(regularClient.getBlobName()) .buildEncryptedBlobAsyncClient())) @@ -82,7 +82,7 @@ class BlobCryptographyBuilderTest extends APISpec { setup: cc.create() CustomerProvidedKey key = new CustomerProvidedKey(getRandomKey()) - def builder = getEncryptedClientBuilder(fakeKey, null, env.primaryAccount.credential, cc.getBlobContainerUrl()) + def builder = getEncryptedClientBuilder(fakeKey, null, environment.primaryAccount.credential, cc.getBlobContainerUrl()) .customerProvidedKey(key) .blobName(generateBlobName()) def encryptedAsyncClient = mockAesKey(builder.buildEncryptedBlobAsyncClient()) @@ -106,12 +106,12 @@ class BlobCryptographyBuilderTest extends APISpec { setup: cc.create() CustomerProvidedKey key = new CustomerProvidedKey(getRandomKey()) - def encryptedClientWithCpk = mockAesKey(getEncryptedClientBuilder(fakeKey, null, env.primaryAccount.credential, cc.getBlobContainerUrl()) + def encryptedClientWithCpk = mockAesKey(getEncryptedClientBuilder(fakeKey, null, environment.primaryAccount.credential, cc.getBlobContainerUrl()) .customerProvidedKey(key) .blobName(generateBlobName()) .buildEncryptedBlobAsyncClient()) - def encryptedClientNoCpk = new EncryptedBlobClient(mockAesKey(getEncryptedClientBuilder(fakeKey, null, env.primaryAccount.credential, encryptedClientWithCpk.getBlobUrl()) + def encryptedClientNoCpk = new EncryptedBlobClient(mockAesKey(getEncryptedClientBuilder(fakeKey, null, environment.primaryAccount.credential, encryptedClientWithCpk.getBlobUrl()) .buildEncryptedBlobAsyncClient())) when: @@ -129,7 +129,7 @@ class BlobCryptographyBuilderTest extends APISpec { setup: def scope = "testscope1" cc.create() - def builder = getEncryptedClientBuilder(fakeKey, null, env.primaryAccount.credential, cc.getBlobContainerUrl()) + def builder = getEncryptedClientBuilder(fakeKey, null, environment.primaryAccount.credential, cc.getBlobContainerUrl()) .encryptionScope(scope) .blobName(generateBlobName()) def encryptedAsyncClient = mockAesKey(builder.buildEncryptedBlobAsyncClient()) @@ -174,7 +174,7 @@ class BlobCryptographyBuilderTest extends APISpec { def "getCustomerProvidedKeyClient"() { setup: CustomerProvidedKey originalKey = new CustomerProvidedKey(getRandomKey()) - def client = getEncryptedClientBuilder(fakeKey, null, env.primaryAccount.credential, cc.getBlobContainerUrl()) + def client = getEncryptedClientBuilder(fakeKey, null, environment.primaryAccount.credential, cc.getBlobContainerUrl()) .customerProvidedKey(originalKey) .blobName(generateBlobName()) .buildEncryptedBlobClient() @@ -191,7 +191,7 @@ class BlobCryptographyBuilderTest extends APISpec { def "getEncryptionScopeClient"() { setup: def originalScope = "testscope1" - def client = getEncryptedClientBuilder(fakeKey, null, env.primaryAccount.credential, cc.getBlobContainerUrl()) + def client = getEncryptedClientBuilder(fakeKey, null, environment.primaryAccount.credential, cc.getBlobContainerUrl()) .encryptionScope(originalScope) .blobName(generateBlobName()) .buildEncryptedBlobClient() diff --git a/sdk/storage/azure-storage-blob-cryptography/src/test/java/com/azure/storage/blob/specialized/cryptography/EncryptedBlobOutputStreamTest.groovy b/sdk/storage/azure-storage-blob-cryptography/src/test/java/com/azure/storage/blob/specialized/cryptography/EncryptedBlobOutputStreamTest.groovy index e278b256d55c5..0d39e71b232c5 100644 --- a/sdk/storage/azure-storage-blob-cryptography/src/test/java/com/azure/storage/blob/specialized/cryptography/EncryptedBlobOutputStreamTest.groovy +++ b/sdk/storage/azure-storage-blob-cryptography/src/test/java/com/azure/storage/blob/specialized/cryptography/EncryptedBlobOutputStreamTest.groovy @@ -22,19 +22,19 @@ class EncryptedBlobOutputStreamTest extends APISpec { fakeKey = new FakeKey(keyId, getRandomByteArray(256)) fakeKeyResolver = new FakeKeyResolver(fakeKey) - cc = getServiceClientBuilder(env.primaryAccount) + cc = getServiceClientBuilder(environment.primaryAccount) .buildClient() .getBlobContainerClient(generateContainerName()) cc.create() def blobName = generateBlobName() - beac = getEncryptedClientBuilder(fakeKey, null, env.primaryAccount.credential, + beac = getEncryptedClientBuilder(fakeKey, null, environment.primaryAccount.credential, cc.getBlobContainerUrl()) .blobName(blobName) .buildEncryptedBlobAsyncClient() - bec = getEncryptedClientBuilder(fakeKey, null, env.primaryAccount.credential, + bec = getEncryptedClientBuilder(fakeKey, null, environment.primaryAccount.credential, cc.getBlobContainerUrl().toString()) .blobName(blobName) .buildEncryptedBlobClient() diff --git a/sdk/storage/azure-storage-blob-cryptography/src/test/java/com/azure/storage/blob/specialized/cryptography/EncyptedBlockBlobAPITest.groovy b/sdk/storage/azure-storage-blob-cryptography/src/test/java/com/azure/storage/blob/specialized/cryptography/EncyptedBlockBlobAPITest.groovy index 4545e5a2d02e5..5efb9eaa2c88a 100644 --- a/sdk/storage/azure-storage-blob-cryptography/src/test/java/com/azure/storage/blob/specialized/cryptography/EncyptedBlockBlobAPITest.groovy +++ b/sdk/storage/azure-storage-blob-cryptography/src/test/java/com/azure/storage/blob/specialized/cryptography/EncyptedBlockBlobAPITest.groovy @@ -64,27 +64,27 @@ class EncyptedBlockBlobAPITest extends APISpec { def setup() { keyId = "keyId" - fakeKey = new FakeKey(keyId, (getEnv().getTestMode() == TestMode.LIVE) ? getRandomByteArray(256) : mockRandomData) + fakeKey = new FakeKey(keyId, (getEnvironment().getTestMode() == TestMode.LIVE) ? getRandomByteArray(256) : mockRandomData) fakeKeyResolver = new FakeKeyResolver(fakeKey) - cc = getServiceClientBuilder(env.primaryAccount) + cc = getServiceClientBuilder(environment.primaryAccount) .buildClient() .getBlobContainerClient(generateContainerName()) cc.create() - beac = mockAesKey(getEncryptedClientBuilder(fakeKey, null, env.primaryAccount.credential, + beac = mockAesKey(getEncryptedClientBuilder(fakeKey, null, environment.primaryAccount.credential, cc.getBlobContainerUrl()) .blobName(generateBlobName()) .buildEncryptedBlobAsyncClient()) - bec = new EncryptedBlobClient(mockAesKey(getEncryptedClientBuilder(fakeKey, null, env.primaryAccount.credential, + bec = new EncryptedBlobClient(mockAesKey(getEncryptedClientBuilder(fakeKey, null, environment.primaryAccount.credential, cc.getBlobContainerUrl().toString()) .blobName(generateBlobName()) .buildEncryptedBlobAsyncClient())) def blobName = generateBlobName() - def builder = getEncryptedClientBuilder(fakeKey, null, env.primaryAccount.credential, + def builder = getEncryptedClientBuilder(fakeKey, null, environment.primaryAccount.credential, cc.getBlobContainerUrl().toString()) .blobName(blobName) @@ -100,7 +100,7 @@ class EncyptedBlockBlobAPITest extends APISpec { // Key and key resolver null def "Create encryption client fails"() { when: - beac = getEncryptedClientBuilder(null, null, env.primaryAccount.credential, + beac = getEncryptedClientBuilder(null, null, environment.primaryAccount.credential, cc.getBlobContainerUrl()) .blobName(generateBlobName()) .buildEncryptedBlobAsyncClient() @@ -109,7 +109,7 @@ class EncyptedBlockBlobAPITest extends APISpec { thrown(IllegalArgumentException) when: - bec = getEncryptedClientBuilder(null, null, env.primaryAccount.credential, + bec = getEncryptedClientBuilder(null, null, environment.primaryAccount.credential, cc.getBlobContainerUrl()) .blobName(generateBlobName()) .buildEncryptedBlobClient() @@ -134,7 +134,7 @@ class EncyptedBlockBlobAPITest extends APISpec { } else { keyResolver = null } - beac = getEncryptedClientBuilder(key, keyResolver, env.primaryAccount.credential, + beac = getEncryptedClientBuilder(key, keyResolver, environment.primaryAccount.credential, cc.getBlobContainerUrl()) .blobName(generateBlobName()) .buildEncryptedBlobAsyncClient() @@ -143,7 +143,7 @@ class EncyptedBlockBlobAPITest extends APISpec { notThrown(IllegalArgumentException) when: - bec = getEncryptedClientBuilder(key, keyResolver, env.primaryAccount.credential, + bec = getEncryptedClientBuilder(key, keyResolver, environment.primaryAccount.credential, cc.getBlobContainerUrl()) .blobName(generateBlobName()) .buildEncryptedBlobClient() @@ -420,7 +420,7 @@ class EncyptedBlockBlobAPITest extends APISpec { def "Download unencrypted data"() { setup: // Create an async client - BlobContainerClient cac = getServiceClientBuilder(env.primaryAccount) + BlobContainerClient cac = getServiceClientBuilder(environment.primaryAccount) .buildClient() .getBlobContainerClient(generateContainerName()) @@ -431,7 +431,7 @@ class EncyptedBlockBlobAPITest extends APISpec { // Uses builder method that takes in regular blob clients EncryptedBlobClient client = new EncryptedBlobClient(mockAesKey(getEncryptedClientBuilder(fakeKey as AsyncKeyEncryptionKey, null, - env.primaryAccount.credential, cac.getBlobContainerUrl()) + environment.primaryAccount.credential, cac.getBlobContainerUrl()) .blobName(blobName) .buildEncryptedBlobAsyncClient())) @@ -489,13 +489,13 @@ class EncyptedBlockBlobAPITest extends APISpec { def blobName = generateBlobName() EncryptedBlobAsyncClient decryptResolverClient = - mockAesKey(getEncryptedClientBuilder(null, fakeKeyResolver as AsyncKeyEncryptionKeyResolver, env.primaryAccount.credential, + mockAesKey(getEncryptedClientBuilder(null, fakeKeyResolver as AsyncKeyEncryptionKeyResolver, environment.primaryAccount.credential, cc.getBlobContainerUrl()) .blobName(blobName) .buildEncryptedBlobAsyncClient()) EncryptedBlobAsyncClient encryptClient = - mockAesKey(getEncryptedClientBuilder(fakeKey as AsyncKeyEncryptionKey, null, env.primaryAccount.credential, cc.getBlobContainerUrl()) + mockAesKey(getEncryptedClientBuilder(fakeKey as AsyncKeyEncryptionKey, null, environment.primaryAccount.credential, cc.getBlobContainerUrl()) .blobName(blobName) .buildEncryptedBlobAsyncClient()) @@ -525,7 +525,7 @@ class EncyptedBlockBlobAPITest extends APISpec { def blobName = generateBlobName() def containerName = cc.getBlobContainerName() - CloudStorageAccount v8Account = CloudStorageAccount.parse(env.primaryAccount.connectionString) + CloudStorageAccount v8Account = CloudStorageAccount.parse(environment.primaryAccount.connectionString) CloudBlobClient blobClient = v8Account.createCloudBlobClient() CloudBlobContainer container = blobClient.getContainerReference(containerName) CloudBlockBlob v8EncryptBlob = container.getBlockBlobReference(blobName) @@ -534,7 +534,7 @@ class EncyptedBlockBlobAPITest extends APISpec { uploadOptions.setEncryptionPolicy(uploadPolicy) EncryptedBlobClient decryptClient = - getEncryptedClientBuilder(fakeKey as AsyncKeyEncryptionKey, null, env.primaryAccount.credential, cc.getBlobContainerUrl()) + getEncryptedClientBuilder(fakeKey as AsyncKeyEncryptionKey, null, environment.primaryAccount.credential, cc.getBlobContainerUrl()) .blobName(blobName) .buildEncryptedBlobClient() @@ -561,12 +561,12 @@ class EncyptedBlockBlobAPITest extends APISpec { def containerName = cc.getBlobContainerName() EncryptedBlobAsyncClient encryptClient = - getEncryptedClientBuilder(fakeKey as AsyncKeyEncryptionKey, null, env.primaryAccount.credential, + getEncryptedClientBuilder(fakeKey as AsyncKeyEncryptionKey, null, environment.primaryAccount.credential, cc.getBlobContainerUrl()) .blobName(blobName) .buildEncryptedBlobAsyncClient() - CloudStorageAccount v8Account = CloudStorageAccount.parse(env.primaryAccount.connectionString) + CloudStorageAccount v8Account = CloudStorageAccount.parse(environment.primaryAccount.connectionString) CloudBlobClient blobClient = v8Account.createCloudBlobClient() CloudBlobContainer container = blobClient.getContainerReference(containerName) container.createIfNotExists() @@ -716,7 +716,7 @@ class EncyptedBlockBlobAPITest extends APISpec { constructed in BlobClient.download(). */ setup: - def builder = getEncryptedClientBuilder(fakeKey, null, env.primaryAccount.credential, + def builder = getEncryptedClientBuilder(fakeKey, null, environment.primaryAccount.credential, ebc.getBlobUrl(), new MockRetryRangeResponsePolicy()) ebc = new EncryptedBlobClient(mockAesKey(builder.buildEncryptedBlobAsyncClient())) @@ -985,8 +985,8 @@ class EncyptedBlockBlobAPITest extends APISpec { setup: def containerName = generateContainerName() def blobServiceClient = new BlobServiceClientBuilder() - .endpoint(env.primaryAccount.blobEndpoint) - .credential(env.primaryAccount.credential) + .endpoint(environment.primaryAccount.blobEndpoint) + .credential(environment.primaryAccount.credential) .buildClient() def encryptedBlobClient = new EncryptedBlobClientBuilder() @@ -1032,8 +1032,8 @@ class EncyptedBlockBlobAPITest extends APISpec { setup: def containerName = generateContainerName() def blobServiceAsyncClient = new BlobServiceClientBuilder() - .endpoint(env.primaryAccount.blobEndpoint) - .credential(env.primaryAccount.credential) + .endpoint(environment.primaryAccount.blobEndpoint) + .credential(environment.primaryAccount.credential) .buildAsyncClient() def encryptedBlobAsyncClient = new EncryptedBlobClientBuilder() @@ -1242,11 +1242,11 @@ class EncyptedBlockBlobAPITest extends APISpec { def counter = new AtomicInteger() expect: - def bacUploading = getEncryptedClientBuilder(fakeKey, null, env.primaryAccount.credential, + def bacUploading = getEncryptedClientBuilder(fakeKey, null, environment.primaryAccount.credential, ebc.getBlobUrl().toString()) .buildEncryptedBlobAsyncClient() - def bacDownloading = getEncryptedClientBuilder(fakeKey, null, env.primaryAccount.credential, + def bacDownloading = getEncryptedClientBuilder(fakeKey, null, environment.primaryAccount.credential, ebc.getBlobUrl().toString()) .addPolicy({ context, next -> return next.process() @@ -1367,14 +1367,14 @@ class EncyptedBlockBlobAPITest extends APISpec { def "Download requiresEncryption"() { setup: def blobName = bec.getBlobName() - def bc = getBlobClientBuilder(env.primaryAccount.credential, cc.getBlobContainerUrl().toString()) + def bc = getBlobClientBuilder(environment.primaryAccount.credential, cc.getBlobContainerUrl().toString()) .blobName(blobName) .buildClient() bc.upload(data.defaultInputStream, data.defaultDataSize) when: "Sync min" - bec = getEncryptedClientBuilder(fakeKey, null, env.primaryAccount.credential, + bec = getEncryptedClientBuilder(fakeKey, null, environment.primaryAccount.credential, cc.getBlobContainerUrl().toString()) .blobName(blobName) .requiresEncryption(true) @@ -1391,7 +1391,7 @@ class EncyptedBlockBlobAPITest extends APISpec { thrown(IllegalStateException) when: "Async min" - beac = getEncryptedClientBuilder(fakeKey, null, env.primaryAccount.credential, + beac = getEncryptedClientBuilder(fakeKey, null, environment.primaryAccount.credential, cc.getBlobContainerUrl().toString()) .blobName(blobName) .requiresEncryption(true) @@ -1504,10 +1504,10 @@ class EncyptedBlockBlobAPITest extends APISpec { } } - @IgnoreIf( { getEnv().serviceVersion != null } ) + @IgnoreIf( { getEnvironment().serviceVersion != null } ) // This tests the policy is in the right place because if it were added per retry, it would be after the credentials and auth would fail because we changed a signed header. def "Per call policy"() { - def client = new EncryptedBlobClient(mockAesKey(getEncryptedClientBuilder(fakeKey, fakeKeyResolver, env.primaryAccount.credential, bec.getBlobUrl(), getPerCallVersionPolicy()) + def client = new EncryptedBlobClient(mockAesKey(getEncryptedClientBuilder(fakeKey, fakeKeyResolver, environment.primaryAccount.credential, bec.getBlobUrl(), getPerCallVersionPolicy()) .buildEncryptedBlobAsyncClient())) client.upload(new ByteArrayInputStream(new byte[0]), 0) diff --git a/sdk/storage/azure-storage-blob-cryptography/src/test/java/com/azure/storage/blob/specialized/cryptography/KeyvaultKeyTest.groovy b/sdk/storage/azure-storage-blob-cryptography/src/test/java/com/azure/storage/blob/specialized/cryptography/KeyvaultKeyTest.groovy index 488eb3efcaef4..efbe49cf3d61b 100644 --- a/sdk/storage/azure-storage-blob-cryptography/src/test/java/com/azure/storage/blob/specialized/cryptography/KeyvaultKeyTest.groovy +++ b/sdk/storage/azure-storage-blob-cryptography/src/test/java/com/azure/storage/blob/specialized/cryptography/KeyvaultKeyTest.groovy @@ -40,7 +40,7 @@ class KeyvaultKeyTest extends APISpec { def setup() { def keyVaultUrl = "https://azstoragesdkvault.vault.azure.net/" - if (env.testMode != TestMode.PLAYBACK) { + if (environment.testMode != TestMode.PLAYBACK) { keyVaultUrl = Configuration.getGlobalConfiguration().get("KEYVAULT_URL") } @@ -64,12 +64,12 @@ class KeyvaultKeyTest extends APISpec { .buildAsyncKeyEncryptionKey(keyVaultKey.getId()) .block() - cc = getServiceClientBuilder(env.primaryAccount) + cc = getServiceClientBuilder(environment.primaryAccount) .buildClient() .getBlobContainerClient(generateContainerName()) cc.create() - bec = getEncryptedClientBuilder(akek, null, env.primaryAccount.credential, + bec = getEncryptedClientBuilder(akek, null, environment.primaryAccount.credential, cc.getBlobContainerUrl().toString()) .blobName(generateBlobName()) .buildEncryptedBlobClient() @@ -111,7 +111,7 @@ class KeyvaultKeyTest extends APISpec { HttpPipeline getHttpPipeline(KeyServiceVersion serviceVersion) { TokenCredential credential = null - if (env.testMode != TestMode.PLAYBACK) { + if (environment.testMode != TestMode.PLAYBACK) { String clientId = System.getenv("AZURE_CLIENT_ID") String clientKey = System.getenv("AZURE_CLIENT_SECRET") String tenantId = System.getenv("AZURE_TENANT_ID") diff --git a/sdk/storage/azure-storage-blob-cryptography/src/test/java/com/azure/storage/blob/specialized/cryptography/LocalKeyTest.groovy b/sdk/storage/azure-storage-blob-cryptography/src/test/java/com/azure/storage/blob/specialized/cryptography/LocalKeyTest.groovy index 4c6c8c8d46b55..52fedebc249d8 100644 --- a/sdk/storage/azure-storage-blob-cryptography/src/test/java/com/azure/storage/blob/specialized/cryptography/LocalKeyTest.groovy +++ b/sdk/storage/azure-storage-blob-cryptography/src/test/java/com/azure/storage/blob/specialized/cryptography/LocalKeyTest.groovy @@ -28,12 +28,12 @@ class LocalKeyTest extends APISpec { .buildAsyncKeyEncryptionKey(localKey) .block() - cc = getServiceClientBuilder(env.primaryAccount) + cc = getServiceClientBuilder(environment.primaryAccount) .buildClient() .getBlobContainerClient(generateContainerName()) cc.create() - bec = getEncryptedClientBuilder(akek, null, env.primaryAccount.credential, + bec = getEncryptedClientBuilder(akek, null, environment.primaryAccount.credential, cc.getBlobContainerUrl().toString()) .blobName(generateBlobName()) .buildEncryptedBlobClient() diff --git a/sdk/storage/azure-storage-blob-nio/pom.xml b/sdk/storage/azure-storage-blob-nio/pom.xml index fb7c8d746af49..298717f6b048e 100644 --- a/sdk/storage/azure-storage-blob-nio/pom.xml +++ b/sdk/storage/azure-storage-blob-nio/pom.xml @@ -101,12 +101,6 @@ 3.4.9 test - - org.spockframework - spock-core - 2.0-M4-groovy-2.5 - test - cglib cglib-nodep @@ -154,6 +148,14 @@ [1.8,9) + + + org.spockframework + spock-core + 2.0-M4-groovy-2.5 + test + + @@ -196,6 +198,14 @@ [9,) + + + org.spockframework + spock-core + 2.0-groovy-3.0 + test + + diff --git a/sdk/storage/azure-storage-blob-nio/src/test/java/com/azure/storage/blob/nio/APISpec.groovy b/sdk/storage/azure-storage-blob-nio/src/test/java/com/azure/storage/blob/nio/APISpec.groovy index 2c82ca519310a..4c41d6f59aba3 100644 --- a/sdk/storage/azure-storage-blob-nio/src/test/java/com/azure/storage/blob/nio/APISpec.groovy +++ b/sdk/storage/azure-storage-blob-nio/src/test/java/com/azure/storage/blob/nio/APISpec.groovy @@ -24,14 +24,12 @@ import com.azure.storage.common.test.shared.TestAccount import spock.lang.Timeout import java.nio.ByteBuffer -import java.nio.charset.StandardCharsets import java.nio.file.FileSystem import java.nio.file.Path import java.nio.file.attribute.FileAttribute import java.time.Duration import java.time.OffsetDateTime import java.util.concurrent.TimeUnit -import java.util.function.Supplier @Timeout(value = 5, unit = TimeUnit.MINUTES) class APISpec extends StorageSpec { @@ -67,9 +65,9 @@ class APISpec extends StorageSpec { } def setup() { - primaryBlobServiceClient = getServiceClient(env.primaryAccount) - primaryBlobServiceAsyncClient = getServiceAsyncClient(env.primaryAccount) - alternateBlobServiceClient = getServiceClient(env.secondaryAccount) + primaryBlobServiceClient = getServiceClient(environment.primaryAccount) + primaryBlobServiceAsyncClient = getServiceAsyncClient(environment.primaryAccount) + alternateBlobServiceClient = getServiceClient(environment.secondaryAccount) containerName = generateContainerName() cc = primaryBlobServiceClient.getBlobContainerClient(containerName) @@ -77,11 +75,11 @@ class APISpec extends StorageSpec { } def cleanup() { - if (env.testMode != TestMode.PLAYBACK) { + if (environment.testMode != TestMode.PLAYBACK) { def cleanupClient = new BlobServiceClientBuilder() .httpClient(getHttpClient()) - .credential(env.primaryAccount.credential) - .endpoint(env.primaryAccount.blobEndpoint) + .credential(environment.primaryAccount.credential) + .endpoint(environment.primaryAccount.blobEndpoint) .buildClient() def options = new ListBlobContainersOptions().setPrefix(namer.getResourcePrefix()) for (BlobContainerItem container : cleanupClient.listBlobContainers(options, Duration.ofSeconds(120))) { @@ -161,7 +159,7 @@ class APISpec extends StorageSpec { } def getFileSystemUri() { - return new URI("azb://?endpoint=" + env.primaryAccount.blobEndpoint) + return new URI("azb://?endpoint=" + environment.primaryAccount.blobEndpoint) } def generateContainerName() { @@ -178,9 +176,9 @@ class APISpec extends StorageSpec { def createFS(Map config) { config[AzureFileSystem.AZURE_STORAGE_FILE_STORES] = generateContainerName() + "," + generateContainerName() - config[AzureFileSystem.AZURE_STORAGE_SHARED_KEY_CREDENTIAL] = env.primaryAccount.credential + config[AzureFileSystem.AZURE_STORAGE_SHARED_KEY_CREDENTIAL] = environment.primaryAccount.credential - return new AzureFileSystem(new AzureFileSystemProvider(), env.primaryAccount.blobEndpoint, config) + return new AzureFileSystem(new AzureFileSystemProvider(), environment.primaryAccount.blobEndpoint, config) } byte[] getRandomByteArray(int size) { @@ -268,7 +266,7 @@ class APISpec extends StorageSpec { // Only sleep if test is running in live mode def sleepIfRecord(long milliseconds) { - if (env.testMode != TestMode.PLAYBACK) { + if (environment.testMode != TestMode.PLAYBACK) { sleep(milliseconds) } } diff --git a/sdk/storage/azure-storage-blob-nio/src/test/java/com/azure/storage/blob/nio/AzureDirectoryStreamTest.groovy b/sdk/storage/azure-storage-blob-nio/src/test/java/com/azure/storage/blob/nio/AzureDirectoryStreamTest.groovy index c5370b8c8aea5..817e9d87c2314 100644 --- a/sdk/storage/azure-storage-blob-nio/src/test/java/com/azure/storage/blob/nio/AzureDirectoryStreamTest.groovy +++ b/sdk/storage/azure-storage-blob-nio/src/test/java/com/azure/storage/blob/nio/AzureDirectoryStreamTest.groovy @@ -20,7 +20,7 @@ class AzureDirectoryStreamTest extends APISpec { @Unroll def "List files"() { setup: - if (numFiles > 50 && env.testMode != TestMode.LIVE) { + if (numFiles > 50 && environment.testMode != TestMode.LIVE) { return // Skip large data set in record and playback } def rootName = absolute ? getNonDefaultRootDir(fs) : "" diff --git a/sdk/storage/azure-storage-blob-nio/src/test/java/com/azure/storage/blob/nio/AzureFileStoreTest.groovy b/sdk/storage/azure-storage-blob-nio/src/test/java/com/azure/storage/blob/nio/AzureFileStoreTest.groovy index 68a755286a94e..3336eceebf277 100644 --- a/sdk/storage/azure-storage-blob-nio/src/test/java/com/azure/storage/blob/nio/AzureFileStoreTest.groovy +++ b/sdk/storage/azure-storage-blob-nio/src/test/java/com/azure/storage/blob/nio/AzureFileStoreTest.groovy @@ -3,7 +3,7 @@ package com.azure.storage.blob.nio -import spock.lang.Shared + import spock.lang.Unroll import java.nio.file.attribute.BasicFileAttributeView @@ -16,9 +16,9 @@ class AzureFileStoreTest extends APISpec { // Just need one fs instance for creating the stores. def setup() { def config = initializeConfigMap() - config[AzureFileSystem.AZURE_STORAGE_SHARED_KEY_CREDENTIAL] = env.primaryAccount.credential + config[AzureFileSystem.AZURE_STORAGE_SHARED_KEY_CREDENTIAL] = environment.primaryAccount.credential config[AzureFileSystem.AZURE_STORAGE_FILE_STORES] = generateContainerName() + "," + generateContainerName() - fs = new AzureFileSystem(new AzureFileSystemProvider(), env.primaryAccount.blobEndpoint, config) + fs = new AzureFileSystem(new AzureFileSystemProvider(), environment.primaryAccount.blobEndpoint, config) } // The constructor is implicitly tested by creating a file system. diff --git a/sdk/storage/azure-storage-blob-nio/src/test/java/com/azure/storage/blob/nio/AzureFileSystemProviderTest.groovy b/sdk/storage/azure-storage-blob-nio/src/test/java/com/azure/storage/blob/nio/AzureFileSystemProviderTest.groovy index 300dca8b4f734..fbbc4e6a4f06d 100644 --- a/sdk/storage/azure-storage-blob-nio/src/test/java/com/azure/storage/blob/nio/AzureFileSystemProviderTest.groovy +++ b/sdk/storage/azure-storage-blob-nio/src/test/java/com/azure/storage/blob/nio/AzureFileSystemProviderTest.groovy @@ -20,7 +20,6 @@ import com.azure.storage.common.StorageSharedKeyCredential import com.azure.storage.common.test.shared.extensions.LiveOnly import reactor.core.publisher.Flux import reactor.core.publisher.Mono -import spock.lang.Requires import spock.lang.Unroll import java.nio.ByteBuffer @@ -61,7 +60,7 @@ class AzureFileSystemProviderTest extends APISpec { def "CreateFileSystem"() { setup: - config[AzureFileSystem.AZURE_STORAGE_SHARED_KEY_CREDENTIAL] = env.primaryAccount.credential + config[AzureFileSystem.AZURE_STORAGE_SHARED_KEY_CREDENTIAL] = environment.primaryAccount.credential config[AzureFileSystem.AZURE_STORAGE_FILE_STORES] = generateContainerName() def uri = getFileSystemUri() @@ -92,7 +91,7 @@ class AzureFileSystemProviderTest extends APISpec { def "CreateFileSystem duplicate"() { setup: config[AzureFileSystem.AZURE_STORAGE_FILE_STORES] = generateContainerName() - config[AzureFileSystem.AZURE_STORAGE_SHARED_KEY_CREDENTIAL] = env.primaryAccount.credential + config[AzureFileSystem.AZURE_STORAGE_SHARED_KEY_CREDENTIAL] = environment.primaryAccount.credential provider.newFileSystem(getFileSystemUri(), config) when: @@ -105,10 +104,10 @@ class AzureFileSystemProviderTest extends APISpec { def "CreateFileSystem initial check fail"() { when: config[AzureFileSystem.AZURE_STORAGE_FILE_STORES] = generateContainerName() - def badKey = env.primaryAccount.key.getBytes() + def badKey = environment.primaryAccount.key.getBytes() badKey[0]++ config[AzureFileSystem.AZURE_STORAGE_SHARED_KEY_CREDENTIAL] = - new StorageSharedKeyCredential(env.primaryAccount.name, new String(badKey)) + new StorageSharedKeyCredential(environment.primaryAccount.name, new String(badKey)) provider.newFileSystem(getFileSystemUri(), config) then: diff --git a/sdk/storage/azure-storage-blob-nio/src/test/java/com/azure/storage/blob/nio/AzureFileSystemTest.groovy b/sdk/storage/azure-storage-blob-nio/src/test/java/com/azure/storage/blob/nio/AzureFileSystemTest.groovy index bdf461fdaf9b7..935e9ea607036 100644 --- a/sdk/storage/azure-storage-blob-nio/src/test/java/com/azure/storage/blob/nio/AzureFileSystemTest.groovy +++ b/sdk/storage/azure-storage-blob-nio/src/test/java/com/azure/storage/blob/nio/AzureFileSystemTest.groovy @@ -32,7 +32,7 @@ class AzureFileSystemTest extends APISpec { .toIterable() config[AzureFileSystem.AZURE_STORAGE_FILE_STORES] = String.join(",", containerNames) if (!sasToken) { - config[AzureFileSystem.AZURE_STORAGE_SHARED_KEY_CREDENTIAL] = env.primaryAccount.credential + config[AzureFileSystem.AZURE_STORAGE_SHARED_KEY_CREDENTIAL] = environment.primaryAccount.credential } else { config[AzureFileSystem.AZURE_STORAGE_SAS_TOKEN_CREDENTIAL] = new AzureSasCredential( primaryBlobServiceClient.generateAccountSas( @@ -42,7 +42,7 @@ class AzureFileSystemTest extends APISpec { } when: - def fileSystem = new AzureFileSystem(new AzureFileSystemProvider(), env.primaryAccount.blobEndpoint, + def fileSystem = new AzureFileSystem(new AzureFileSystemProvider(), environment.primaryAccount.blobEndpoint, config) then: @@ -69,11 +69,11 @@ class AzureFileSystemTest extends APISpec { config[AzureFileSystem.AZURE_STORAGE_FILE_STORES] = generateContainerName() } if (credential) { - config[AzureFileSystem.AZURE_STORAGE_SHARED_KEY_CREDENTIAL] = env.primaryAccount.key + config[AzureFileSystem.AZURE_STORAGE_SHARED_KEY_CREDENTIAL] = environment.primaryAccount.key } when: - new AzureFileSystem(new AzureFileSystemProvider(), env.primaryAccount.name, config) + new AzureFileSystem(new AzureFileSystemProvider(), environment.primaryAccount.name, config) then: thrown(IllegalArgumentException) @@ -94,7 +94,7 @@ class AzureFileSystemTest extends APISpec { config[AzureFileSystem.AZURE_STORAGE_FILE_STORES] = generateContainerName() when: - new AzureFileSystem(new AzureFileSystemProvider(), env.primaryAccount.blobEndpoint, config) + new AzureFileSystem(new AzureFileSystemProvider(), environment.primaryAccount.blobEndpoint, config) then: thrown(IOException) @@ -105,7 +105,7 @@ class AzureFileSystemTest extends APISpec { def provider = new AzureFileSystemProvider() def uri = getFileSystemUri() config[AzureFileSystem.AZURE_STORAGE_FILE_STORES] = generateContainerName() - config[AzureFileSystem.AZURE_STORAGE_SHARED_KEY_CREDENTIAL] = env.primaryAccount.credential + config[AzureFileSystem.AZURE_STORAGE_SHARED_KEY_CREDENTIAL] = environment.primaryAccount.credential def fileSystem = provider.newFileSystem(uri, config) when: diff --git a/sdk/storage/azure-storage-blob-nio/src/test/java/com/azure/storage/blob/nio/AzurePathTest.groovy b/sdk/storage/azure-storage-blob-nio/src/test/java/com/azure/storage/blob/nio/AzurePathTest.groovy index 0892815653ad8..9003ece6d25d4 100644 --- a/sdk/storage/azure-storage-blob-nio/src/test/java/com/azure/storage/blob/nio/AzurePathTest.groovy +++ b/sdk/storage/azure-storage-blob-nio/src/test/java/com/azure/storage/blob/nio/AzurePathTest.groovy @@ -15,9 +15,9 @@ class AzurePathTest extends APISpec { // Just need one fs instance for creating the paths. def setup() { def config = initializeConfigMap() - config[AzureFileSystem.AZURE_STORAGE_SHARED_KEY_CREDENTIAL] = env.primaryAccount.credential + config[AzureFileSystem.AZURE_STORAGE_SHARED_KEY_CREDENTIAL] = environment.primaryAccount.credential config[AzureFileSystem.AZURE_STORAGE_FILE_STORES] = "jtcazurepath1,jtcazurepath2" - fs = new AzureFileSystem(new AzureFileSystemProvider(), env.primaryAccount.blobEndpoint, config) + fs = new AzureFileSystem(new AzureFileSystemProvider(), environment.primaryAccount.blobEndpoint, config) } def "GetFileSystem"() { diff --git a/sdk/storage/azure-storage-blob/pom.xml b/sdk/storage/azure-storage-blob/pom.xml index 38263733e4989..34c6457141d8a 100644 --- a/sdk/storage/azure-storage-blob/pom.xml +++ b/sdk/storage/azure-storage-blob/pom.xml @@ -134,12 +134,6 @@ 1.6.5 test - - org.spockframework - spock-core - 2.0-M4-groovy-2.5 - test - cglib cglib-nodep @@ -229,6 +223,14 @@ [1.8,9) + + + org.spockframework + spock-core + 2.0-M4-groovy-2.5 + test + + @@ -271,6 +273,14 @@ [9,) + + + org.spockframework + spock-core + 2.0-groovy-3.0 + test + + diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/APISpec.groovy b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/APISpec.groovy index a7eee78d2cc7d..a355ed124c008 100644 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/APISpec.groovy +++ b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/APISpec.groovy @@ -96,12 +96,12 @@ class APISpec extends StorageSpec { } def setup() { - primaryBlobServiceClient = getServiceClient(env.primaryAccount) - primaryBlobServiceAsyncClient = getServiceAsyncClient(env.primaryAccount) - alternateBlobServiceClient = getServiceClient(env.secondaryAccount) - premiumBlobServiceClient = getServiceClient(env.premiumAccount) - versionedBlobServiceClient = getServiceClient(env.versionedAccount) - softDeleteServiceClient = getServiceClient(env.softDeleteAccount) + primaryBlobServiceClient = getServiceClient(environment.primaryAccount) + primaryBlobServiceAsyncClient = getServiceAsyncClient(environment.primaryAccount) + alternateBlobServiceClient = getServiceClient(environment.secondaryAccount) + premiumBlobServiceClient = getServiceClient(environment.premiumAccount) + versionedBlobServiceClient = getServiceClient(environment.versionedAccount) + softDeleteServiceClient = getServiceClient(environment.softDeleteAccount) containerName = generateContainerName() cc = primaryBlobServiceClient.getBlobContainerClient(containerName) @@ -110,11 +110,11 @@ class APISpec extends StorageSpec { } def cleanup() { - if (env.testMode != TestMode.PLAYBACK) { + if (environment.testMode != TestMode.PLAYBACK) { def cleanupClient = new BlobServiceClientBuilder() .httpClient(getHttpClient()) - .credential(env.primaryAccount.credential) - .endpoint(env.primaryAccount.blobEndpoint) + .credential(environment.primaryAccount.credential) + .endpoint(environment.primaryAccount.blobEndpoint) .buildClient() def options = new ListBlobContainersOptions().setPrefix(namer.getResourcePrefix()) @@ -136,7 +136,7 @@ class APISpec extends StorageSpec { def getOAuthServiceClient() { BlobServiceClientBuilder builder = new BlobServiceClientBuilder() - .endpoint(env.primaryAccount.blobEndpoint) + .endpoint(environment.primaryAccount.blobEndpoint) instrument(builder) @@ -144,12 +144,12 @@ class APISpec extends StorageSpec { } def setOauthCredentials(BlobServiceClientBuilder builder) { - if (env.testMode != TestMode.PLAYBACK) { + if (environment.testMode != TestMode.PLAYBACK) { // AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET return builder.credential(new EnvironmentCredentialBuilder().build()) } else { // Running in playback, we don't have access to the AAD environment variables, just use SharedKeyCredential. - return builder.credential(env.primaryAccount.credential) + return builder.credential(environment.primaryAccount.credential) } } @@ -221,8 +221,8 @@ class APISpec extends StorageSpec { BlobServiceAsyncClient getPrimaryServiceClientForWrites(long perRequestDataSize) { int retryTimeout = Math.toIntExact((long) (perRequestDataSize / Constants.MB) * 20) retryTimeout = Math.max(60, retryTimeout) - return getServiceClientBuilder(env.primaryAccount.credential, - env.primaryAccount.blobEndpoint) + return getServiceClientBuilder(environment.primaryAccount.credential, + environment.primaryAccount.blobEndpoint) .retryOptions(new RequestRetryOptions(null, null, retryTimeout, null, null, null)) .buildAsyncClient() } @@ -667,7 +667,7 @@ class APISpec extends StorageSpec { // Only sleep if test is running in live mode def sleepIfRecord(long milliseconds) { - if (env.testMode != TestMode.PLAYBACK) { + if (environment.testMode != TestMode.PLAYBACK) { sleep(milliseconds) } } @@ -718,7 +718,7 @@ class APISpec extends StorageSpec { } def getPollingDuration(long liveTestDurationInMillis) { - return (env.testMode == TestMode.PLAYBACK) ? Duration.ofMillis(1) : Duration.ofMillis(liveTestDurationInMillis) + return (environment.testMode == TestMode.PLAYBACK) ? Duration.ofMillis(1) : Duration.ofMillis(liveTestDurationInMillis) } def getPerCallVersionPolicy() { diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobAPITest.groovy b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobAPITest.groovy index 051bc9c32e2f5..caa5efa8ca749 100644 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobAPITest.groovy +++ b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobAPITest.groovy @@ -240,7 +240,7 @@ class BlobAPITest extends APISpec { def "Upload successful retry"() { given: def clientWithFailure = getBlobClient( - env.primaryAccount.credential, + environment.primaryAccount.credential, bc.getBlobUrl(), new TransientFailureInjectingHttpPipelinePolicy()) @@ -413,7 +413,7 @@ class BlobAPITest extends APISpec { constructed in BlobClient.download(). */ setup: - def bu2 = getBlobClient(env.primaryAccount.credential, bc.getBlobUrl(), new MockRetryRangeResponsePolicy("bytes=2-6")) + def bu2 = getBlobClient(environment.primaryAccount.credential, bc.getBlobUrl(), new MockRetryRangeResponsePolicy("bytes=2-6")) when: def range = new BlobRange(2, 5L) @@ -683,7 +683,7 @@ class BlobAPITest extends APISpec { def "Download retry default"() { setup: - def failureBlobClient = getBlobClient(env.primaryAccount.credential, bc.getBlobUrl(), new MockFailureResponsePolicy(5)) + def failureBlobClient = getBlobClient(environment.primaryAccount.credential, bc.getBlobUrl(), new MockFailureResponsePolicy(5)) when: def outStream = new ByteArrayOutputStream() @@ -893,8 +893,8 @@ class BlobAPITest extends APISpec { setup: def containerName = generateContainerName() def blobServiceClient = new BlobServiceClientBuilder() - .endpoint(env.primaryAccount.blobEndpoint) - .credential(env.primaryAccount.credential) + .endpoint(environment.primaryAccount.blobEndpoint) + .credential(environment.primaryAccount.credential) .buildClient() def blobClient = blobServiceClient.createBlobContainer(containerName) @@ -940,8 +940,8 @@ class BlobAPITest extends APISpec { setup: def containerName = generateContainerName() def blobServiceAsyncClient = new BlobServiceClientBuilder() - .endpoint(env.primaryAccount.blobEndpoint) - .credential(env.primaryAccount.credential) + .endpoint(environment.primaryAccount.blobEndpoint) + .credential(environment.primaryAccount.credential) .buildAsyncClient() def blobAsyncClient = blobServiceAsyncClient.createBlobContainer(containerName).block() @@ -1148,7 +1148,7 @@ class BlobAPITest extends APISpec { expect: def bacUploading = instrument(new BlobClientBuilder() .endpoint(bc.getBlobUrl()) - .credential(env.primaryAccount.credential)) + .credential(environment.primaryAccount.credential)) .buildAsyncClient() .getBlockBlobAsyncClient() @@ -1168,7 +1168,7 @@ class BlobAPITest extends APISpec { }) }) .endpoint(bc.getBlobUrl()) - .credential(env.primaryAccount.credential)) + .credential(environment.primaryAccount.credential)) .buildAsyncClient() .getBlockBlobAsyncClient() @@ -3045,7 +3045,7 @@ class BlobAPITest extends APISpec { .setPermissions(new BlobSasPermission().setReadPermission(true)) .setContainerName(cc.getBlobContainerName()) .setBlobName(blobName) - .generateSasQueryParameters(env.primaryAccount.credential) + .generateSasQueryParameters(environment.primaryAccount.credential) .encode() bcCopy.copyFromUrlWithResponse(bc.getBlobUrl().toString() + "?" + sas, null, tier2, null, null, null, null) @@ -3164,10 +3164,10 @@ class BlobAPITest extends APISpec { thrown(IllegalArgumentException) } - @IgnoreIf({ getEnv().serviceVersion != null }) + @IgnoreIf({ getEnvironment().serviceVersion != null }) // This tests the policy is in the right place because if it were added per retry, it would be after the credentials and auth would fail because we changed a signed header. def "Per call policy"() { - bc = getBlobClient(env.primaryAccount.credential, bc.getBlobUrl(), getPerCallVersionPolicy()) + bc = getBlobClient(environment.primaryAccount.credential, bc.getBlobUrl(), getPerCallVersionPolicy()) when: def response = bc.getPropertiesWithResponse(null, null, null) diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/CPKNTest.groovy b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/CPKNTest.groovy index 5d8ecaac774a1..f43b6f265600f 100644 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/CPKNTest.groovy +++ b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/CPKNTest.groovy @@ -37,7 +37,7 @@ class CPKNTest extends APISpec { ces = new BlobContainerEncryptionScope().setDefaultEncryptionScope(scope2).setEncryptionScopeOverridePrevented(true) builder = getContainerClientBuilder(cc.getBlobContainerUrl()) - .credential(env.primaryAccount.credential) + .credential(environment.primaryAccount.credential) cpknContainer = builder.encryptionScope(es).buildClient() @@ -152,7 +152,7 @@ class CPKNTest extends APISpec { .setPermissions(new BlobSasPermission().setReadPermission(true)) .setContainerName(cc.getBlobContainerName()) .setBlobName(blobName) - .generateSasQueryParameters(env.primaryAccount.credential) + .generateSasQueryParameters(environment.primaryAccount.credential) .encode() def response = cpknAppendBlob.appendBlockFromUrlWithResponse(sourceBlob.getBlobUrl().toString() + "?" + sas, null, null, null, null, null, null) @@ -203,7 +203,7 @@ class CPKNTest extends APISpec { .setPermissions(new BlobSasPermission().setReadPermission(true)) .setContainerName(cc.getBlobContainerName()) .setBlobName(blobName) - .generateSasQueryParameters(env.primaryAccount.credential) + .generateSasQueryParameters(environment.primaryAccount.credential) .encode() def response = cpknPageBlob.uploadPagesFromUrlWithResponse(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/CPKTest.groovy b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/CPKTest.groovy index 0f09274be4219..a8195284ab61e 100644 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/CPKTest.groovy +++ b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/CPKTest.groovy @@ -29,7 +29,7 @@ class CPKTest extends APISpec { def builder = instrument(new BlobContainerClientBuilder() .endpoint(cc.getBlobContainerUrl().toString()) .customerProvidedKey(key) - .credential(env.primaryAccount.credential)) + .credential(environment.primaryAccount.credential)) cpkContainer = builder.buildClient() cpkBlockBlob = cpkContainer.getBlobClient(generateBlobName()).getBlockBlobClient() @@ -97,7 +97,7 @@ class CPKTest extends APISpec { .setPermissions(new BlobSasPermission().setReadPermission(true)) .setContainerName(cc.getBlobContainerName()) .setBlobName(blobName) - .generateSasQueryParameters(env.primaryAccount.credential) + .generateSasQueryParameters(environment.primaryAccount.credential) .encode() def response = cpkBlockBlob.stageBlockFromUrlWithResponse(getBlockID(), sourceBlob.getBlobUrl().toString() + "?" + sas, @@ -154,7 +154,7 @@ class CPKTest extends APISpec { .setPermissions(new BlobSasPermission().setReadPermission(true)) .setContainerName(cc.getBlobContainerName()) .setBlobName(blobName) - .generateSasQueryParameters(env.primaryAccount.credential) + .generateSasQueryParameters(environment.primaryAccount.credential) .encode() def response = cpkPageBlob.uploadPagesFromUrlWithResponse(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), @@ -208,7 +208,7 @@ class CPKTest extends APISpec { .setPermissions(new BlobSasPermission().setReadPermission(true)) .setContainerName(cc.getBlobContainerName()) .setBlobName(blobName) - .generateSasQueryParameters(env.primaryAccount.credential) + .generateSasQueryParameters(environment.primaryAccount.credential) .encode() def response = cpkAppendBlob.appendBlockFromUrlWithResponse(sourceBlob.getBlobUrl().toString() + "?" + sas, null, null, null, null, null, null) diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ContainerAPITest.groovy b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ContainerAPITest.groovy index 82f09422a9599..784a7c57c8993 100644 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ContainerAPITest.groovy +++ b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ContainerAPITest.groovy @@ -1668,8 +1668,8 @@ class ContainerAPITest extends APISpec { } AppendBlobClient bc = instrument(new BlobClientBuilder() - .credential(env.primaryAccount.credential) - .endpoint(env.primaryAccount.blobEndpoint) + .credential(environment.primaryAccount.credential) + .endpoint(environment.primaryAccount.blobEndpoint) .blobName("rootblob")) .buildClient().getAppendBlobClient() @@ -1694,8 +1694,8 @@ class ContainerAPITest extends APISpec { when: cc = instrument(new BlobContainerClientBuilder() - .credential(env.primaryAccount.credential) - .endpoint(env.primaryAccount.blobEndpoint) + .credential(environment.primaryAccount.credential) + .endpoint(environment.primaryAccount.blobEndpoint) .containerName(null)) .buildClient() @@ -1798,7 +1798,7 @@ class ContainerAPITest extends APISpec { def "Per call policy"() { setup: def cc = getContainerClientBuilder(cc.getBlobContainerUrl()) - .credential(env.primaryAccount.credential) + .credential(environment.primaryAccount.credential) .addPolicy(getPerCallVersionPolicy()) .buildClient() diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ImmutableStorageWithVersioningTest.groovy b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ImmutableStorageWithVersioningTest.groovy index 341e7f8376b08..dd65d2e97d705 100644 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ImmutableStorageWithVersioningTest.groovy +++ b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ImmutableStorageWithVersioningTest.groovy @@ -56,11 +56,11 @@ class ImmutableStorageWithVersioningTest extends APISpec { @Shared private String vlwContainerName @Shared - private String accountName = env.versionedAccount.name + private String accountName = environment.versionedAccount.name @Shared - private String resourceGroupName = env.resourceGroupName + private String resourceGroupName = environment.resourceGroupName @Shared - private String subscriptionId = env.subscriptionId + private String subscriptionId = environment.subscriptionId @Shared private String apiVersion = "2021-04-01" @Shared @@ -72,7 +72,7 @@ class ImmutableStorageWithVersioningTest extends APISpec { private BlobClient vlwBlob def setupSpec() { - if (env.testMode != TestMode.PLAYBACK) { + if (environment.testMode != TestMode.PLAYBACK) { vlwContainerName = UUID.randomUUID().toString() String url = String.format("https://management.azure.com/subscriptions/%s/resourceGroups/%s/providers/" @@ -127,15 +127,15 @@ class ImmutableStorageWithVersioningTest extends APISpec { } def cleanupSpec() { - if (env.testMode != TestMode.PLAYBACK) { + if (environment.testMode != TestMode.PLAYBACK) { HttpPipeline httpPipeline = new HttpPipelineBuilder() .policies(credentialPolicy) .httpClient(getHttpClient()) .build() def cleanupClient = new BlobServiceClientBuilder() .httpClient(getHttpClient()) - .credential(env.versionedAccount.credential) - .endpoint(env.versionedAccount.blobEndpoint) + .credential(environment.versionedAccount.credential) + .endpoint(environment.versionedAccount.blobEndpoint) .buildClient() def containerClient = cleanupClient.getBlobContainerClient(vlwContainerName) diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/OAuthCopySourceTests.groovy b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/OAuthCopySourceTests.groovy index 960b24861799b..bb90619ac4d41 100644 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/OAuthCopySourceTests.groovy +++ b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/OAuthCopySourceTests.groovy @@ -41,7 +41,7 @@ class OAuthCopySourceTests extends APISpec { } // RBAC replication lag - @Retry(count = 5, delay = 30, condition = { env.testMode == TestMode.LIVE }) + @Retry(count = 5, delay = 30, condition = { environment.testMode == TestMode.LIVE }) def "Append blob append block from URL source oauth"() { setup: def sourceBlob = cc.getBlobClient(generateBlobName()) @@ -75,7 +75,7 @@ class OAuthCopySourceTests extends APISpec { } // RBAC replication lag - @Retry(count = 5, delay = 30, condition = { env.testMode == TestMode.LIVE }) + @Retry(count = 5, delay = 30, condition = { environment.testMode == TestMode.LIVE }) def "Block blob upload from URL source oauth"() { setup: def oauthHeader = getAuthToken() @@ -107,7 +107,7 @@ class OAuthCopySourceTests extends APISpec { } // RBAC replication lag - @Retry(count = 5, delay = 30, condition = { env.testMode == TestMode.LIVE }) + @Retry(count = 5, delay = 30, condition = { environment.testMode == TestMode.LIVE }) def "Block blob stage block from URL source oauth"() { setup: def oauthHeader = getAuthToken() @@ -142,7 +142,7 @@ class OAuthCopySourceTests extends APISpec { } // RBAC replication lag - @Retry(count = 5, delay = 30, condition = { env.testMode == TestMode.LIVE }) + @Retry(count = 5, delay = 30, condition = { environment.testMode == TestMode.LIVE }) def "Upload pages from URL source oauth"() { setup: def pageRange = new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1) diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ProgressReporterTest.groovy b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ProgressReporterTest.groovy index 457920d60ae21..8776649d6d7d9 100644 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ProgressReporterTest.groovy +++ b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ProgressReporterTest.groovy @@ -6,7 +6,6 @@ package com.azure.storage.blob import com.azure.storage.blob.specialized.BlockBlobAsyncClient import com.azure.storage.common.test.shared.extensions.LiveOnly import reactor.core.publisher.Flux -import spock.lang.Requires import java.nio.ByteBuffer import java.util.concurrent.atomic.AtomicLong @@ -45,7 +44,7 @@ class ProgressReporterTest extends APISpec { Flux data = ProgressReporter.addProgressReporting(Flux.just(buffer), mockReceiver) when: - BlockBlobAsyncClient bu = getBlobAsyncClient(env.primaryAccount.credential, cc.getBlobContainerUrl(), generateBlobName()) + BlockBlobAsyncClient bu = getBlobAsyncClient(environment.primaryAccount.credential, cc.getBlobContainerUrl(), generateBlobName()) .getBlockBlobAsyncClient() bu.upload(data, buffer.remaining()).block() diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/SasClientTests.groovy b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/SasClientTests.groovy index ef9b293ee332c..4d0cbc082c2a9 100644 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/SasClientTests.groovy +++ b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/SasClientTests.groovy @@ -43,7 +43,7 @@ class SasClientTests extends APISpec { def setup() { blobName = generateBlobName() - sasClient = getBlobClient(env.primaryAccount.credential, cc.getBlobContainerUrl(), blobName).getBlockBlobClient() + sasClient = getBlobClient(environment.primaryAccount.credential, cc.getBlobContainerUrl(), blobName).getBlockBlobClient() sasClient.upload(data.defaultInputStream, data.defaultDataSize) } @@ -120,7 +120,7 @@ class SasClientTests extends APISpec { } // RBAC replication lag - @Retry(count = 5, delay = 30, condition = { env.testMode == TestMode.LIVE }) + @Retry(count = 5, delay = 30, condition = { environment.testMode == TestMode.LIVE }) def "blob sas user delegation"() { setup: def permissions = new BlobSasPermission() @@ -193,7 +193,7 @@ class SasClientTests extends APISpec { } // RBAC replication lag - @Retry(count = 5, delay = 30, condition = { env.testMode == TestMode.LIVE }) + @Retry(count = 5, delay = 30, condition = { environment.testMode == TestMode.LIVE }) def "blob sas snapshot user delegation"() { setup: def snapshotBlob = new SpecializedBlobClientBuilder().blobClient(sasClient.createSnapshot()).buildBlockBlobClient() @@ -232,7 +232,7 @@ class SasClientTests extends APISpec { } // RBAC replication lag - @Retry(count = 5, delay = 30, condition = { env.testMode == TestMode.LIVE }) + @Retry(count = 5, delay = 30, condition = { environment.testMode == TestMode.LIVE }) def "container sas user delegation"() { setup: def permissions = new BlobContainerSasPermission() @@ -358,7 +358,7 @@ class SasClientTests extends APISpec { } // RBAC replication lag - @Retry(count = 5, delay = 30, condition = { env.testMode == TestMode.LIVE }) + @Retry(count = 5, delay = 30, condition = { environment.testMode == TestMode.LIVE }) def "blob user delegation saoid"() { setup: def permissions = new BlobSasPermission() @@ -390,7 +390,7 @@ class SasClientTests extends APISpec { } // RBAC replication lag - @Retry(count = 5, delay = 30, condition = { env.testMode == TestMode.LIVE }) + @Retry(count = 5, delay = 30, condition = { environment.testMode == TestMode.LIVE }) def "container user delegation correlation id"() { setup: def permissions = new BlobContainerSasPermission() @@ -683,7 +683,7 @@ class SasClientTests extends APISpec { notThrown(BlobStorageException) when: - def bc = getBlobClient(env.primaryAccount.credential, primaryBlobServiceClient.getAccountUrl() + "/" + containerName + "/" + blobName + "?" + sas) + def bc = getBlobClient(environment.primaryAccount.credential, primaryBlobServiceClient.getAccountUrl() + "/" + containerName + "/" + blobName + "?" + sas) def file = getRandomFile(256) bc.uploadFromFile(file.toPath().toString(), true) @@ -871,7 +871,7 @@ class SasClientTests extends APISpec { p.setReadPermission(true) def v = new BlobServiceSasSignatureValues(e, p) - def expected = String.format(expectedStringToSign, env.primaryAccount.name) + def expected = String.format(expectedStringToSign, environment.primaryAccount.name) v.setStartTime(startTime) @@ -890,12 +890,12 @@ class SasClientTests extends APISpec { def implUtil = new BlobSasImplUtil(v, "containerName", "blobName", snapId, versionId) - def sasToken = implUtil.generateSas(env.primaryAccount.credential, Context.NONE) + def sasToken = implUtil.generateSas(environment.primaryAccount.credential, Context.NONE) def token = BlobUrlParts.parse(cc.getBlobContainerUrl() + "?" + sasToken).getCommonSasQueryParameters() then: - token.getSignature() == env.primaryAccount.credential.computeHmac256(expected) + token.getSignature() == environment.primaryAccount.credential.computeHmac256(expected) /* We don't test the blob or containerName properties because canonicalized resource is always added as at least @@ -926,7 +926,7 @@ class SasClientTests extends APISpec { def p = new BlobSasPermission().setReadPermission(true) def v = new BlobServiceSasSignatureValues(e, p) - def expected = String.format(expectedStringToSign, env.primaryAccount.name) + def expected = String.format(expectedStringToSign, environment.primaryAccount.name) v.setStartTime(startTime) @@ -954,7 +954,7 @@ class SasClientTests extends APISpec { def implUtil = new BlobSasImplUtil(v, "containerName", "blobName", snapId, versionId) - def sasToken = implUtil.generateUserDelegationSas(key, env.primaryAccount.name, Context.NONE) + def sasToken = implUtil.generateUserDelegationSas(key, environment.primaryAccount.name, Context.NONE) def token = BlobUrlParts.parse(cc.getBlobContainerUrl() + "?" + sasToken).getCommonSasQueryParameters() @@ -995,15 +995,15 @@ class SasClientTests extends APISpec { expectedStringToSign = String.format(expectedStringToSign, Constants.ISO_8601_UTC_DATE_FORMATTER.format(expiryTime), - env.primaryAccount.name) + environment.primaryAccount.name) when: - String token = implUtil.generateSas(env.primaryAccount.credential, Context.NONE) + String token = implUtil.generateSas(environment.primaryAccount.credential, Context.NONE) def queryParams = new CommonSasQueryParameters(SasImplUtils.parseQueryString(token), true) then: - queryParams.getSignature() == env.primaryAccount.credential.computeHmac256(expectedStringToSign) + queryParams.getSignature() == environment.primaryAccount.credential.computeHmac256(expectedStringToSign) queryParams.getResource() == expectedResource where: @@ -1033,12 +1033,12 @@ class SasClientTests extends APISpec { def implUtil = new AccountSasImplUtil(v) - def sasToken = implUtil.generateSas(env.primaryAccount.credential, Context.NONE) + def sasToken = implUtil.generateSas(environment.primaryAccount.credential, Context.NONE) def token = BlobUrlParts.parse(cc.getBlobContainerUrl() + "?" + sasToken).getCommonSasQueryParameters() then: - token.getSignature() == env.primaryAccount.credential.computeHmac256(String.format(expectedStringToSign, env.primaryAccount.name)) + token.getSignature() == environment.primaryAccount.credential.computeHmac256(String.format(expectedStringToSign, environment.primaryAccount.name)) where: startTime | ipRange | protocol || expectedStringToSign @@ -1059,7 +1059,7 @@ class SasClientTests extends APISpec { values.setBlobName(sasClient.blobName) when: - def deprecatedStringToSign = values.generateSasQueryParameters(env.primaryAccount.credential).encode() + def deprecatedStringToSign = values.generateSasQueryParameters(environment.primaryAccount.credential).encode() def stringToSign = client.generateSas(values) then: diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ServiceAPITest.groovy b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ServiceAPITest.groovy index ec8ab1b960c82..f6f5da81a7d3a 100644 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ServiceAPITest.groovy +++ b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ServiceAPITest.groovy @@ -55,7 +55,7 @@ class ServiceAPITest extends APISpec { setup: // We shouldnt be getting to the network layer anyway anonymousClient = new BlobServiceClientBuilder() - .endpoint(env.primaryAccount.blobEndpoint) + .endpoint(environment.primaryAccount.blobEndpoint) .buildClient() def disabled = new BlobRetentionPolicy().setEnabled(false) primaryBlobServiceClient.setProperties(new BlobServiceProperties() @@ -644,7 +644,7 @@ class ServiceAPITest extends APISpec { def "Set props error"() { when: - getServiceClient(env.primaryAccount.credential, "https://error.blob.core.windows.net") + getServiceClient(environment.primaryAccount.credential, "https://error.blob.core.windows.net") .setProperties(new BlobServiceProperties()) then: @@ -666,7 +666,7 @@ class ServiceAPITest extends APISpec { def "Get props error"() { when: - getServiceClient(env.primaryAccount.credential, "https://error.blob.core.windows.net") + getServiceClient(environment.primaryAccount.credential, "https://error.blob.core.windows.net") .getProperties() then: @@ -733,7 +733,7 @@ class ServiceAPITest extends APISpec { def "Get stats"() { setup: - def serviceClient = getServiceClient(env.primaryAccount.credential, env.primaryAccount.blobEndpointSecondary) + def serviceClient = getServiceClient(environment.primaryAccount.credential, environment.primaryAccount.blobEndpointSecondary) def response = serviceClient.getStatisticsWithResponse(null, null) expect: @@ -746,7 +746,7 @@ class ServiceAPITest extends APISpec { def "Get stats min"() { setup: - def serviceClient = getServiceClient(env.primaryAccount.credential, env.primaryAccount.blobEndpointSecondary) + def serviceClient = getServiceClient(environment.primaryAccount.credential, environment.primaryAccount.blobEndpointSecondary) expect: serviceClient.getStatisticsWithResponse(null, null).getStatusCode() == 200 @@ -789,7 +789,7 @@ class ServiceAPITest extends APISpec { def "Invalid account name"() { setup: def badURL = new URL("http://fake.blobfake.core.windows.net") - def client = getServiceClientBuilder(env.primaryAccount.credential, badURL.toString()) + def client = getServiceClientBuilder(environment.primaryAccount.credential, badURL.toString()) .retryOptions(new RequestRetryOptions(RetryPolicyType.FIXED, 2, 60, 100, 1000, null)) .buildClient() @@ -938,7 +938,7 @@ class ServiceAPITest extends APISpec { given: def cc1 = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(generateContainerName()) def blobName = generateBlobName() - def delay = env.testMode == TestMode.PLAYBACK ? 0L : 30000L + def delay = environment.testMode == TestMode.PLAYBACK ? 0L : 30000L def blobContainerItemMono = cc1.create() .then(cc1.getBlobAsyncClient(blobName).upload(data.defaultFlux, new ParallelTransferOptions())) @@ -969,7 +969,7 @@ class ServiceAPITest extends APISpec { given: def cc1 = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(generateContainerName()) def blobName = generateBlobName() - def delay = env.testMode == TestMode.PLAYBACK ? 0L : 30000L + def delay = environment.testMode == TestMode.PLAYBACK ? 0L : 30000L def blobContainerItemMono = cc1.create() .then(cc1.getBlobAsyncClient(blobName).upload(data.defaultFlux, new ParallelTransferOptions())) @@ -1035,7 +1035,7 @@ class ServiceAPITest extends APISpec { def "OAuth on secondary"() { setup: - def serviceClient = setOauthCredentials(getServiceClientBuilder(null, env.primaryAccount.blobEndpointSecondary)).buildClient() + def serviceClient = setOauthCredentials(getServiceClientBuilder(null, environment.primaryAccount.blobEndpointSecondary)).buildClient() when: serviceClient.getProperties() @@ -1069,10 +1069,10 @@ class ServiceAPITest extends APISpec { /* Note: the check is on the blob builder as well but I can't test it this way since we encode all blob names - so it will not be invalid. */ } - @IgnoreIf( { getEnv().serviceVersion != null } ) + @IgnoreIf( { getEnvironment().serviceVersion != null } ) // This tests the policy is in the right place because if it were added per retry, it would be after the credentials and auth would fail because we changed a signed header. def "Per call policy"() { - def sc = getServiceClientBuilder(env.primaryAccount.credential, primaryBlobServiceClient.getAccountUrl(), getPerCallVersionPolicy()).buildClient() + def sc = getServiceClientBuilder(environment.primaryAccount.credential, primaryBlobServiceClient.getAccountUrl(), getPerCallVersionPolicy()).buildClient() when: def response = sc.getPropertiesWithResponse(null, null) diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/AppendBlobAPITest.groovy b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/AppendBlobAPITest.groovy index 0f58aebada291..bf6b739b2066d 100644 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/AppendBlobAPITest.groovy +++ b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/AppendBlobAPITest.groovy @@ -354,7 +354,7 @@ class AppendBlobAPITest extends APISpec { def "Append block retry on transient failure"() { setup: def clientWithFailure = getBlobClient( - env.primaryAccount.credential, + environment.primaryAccount.credential, bc.getBlobUrl(), new TransientFailureInjectingHttpPipelinePolicy() ).getAppendBlobClient() @@ -696,11 +696,11 @@ class AppendBlobAPITest extends APISpec { null | null | null | null | null | 1 } - @IgnoreIf( { getEnv().serviceVersion != null } ) + @IgnoreIf( { getEnvironment().serviceVersion != null } ) // This tests the policy is in the right place because if it were added per retry, it would be after the credentials and auth would fail because we changed a signed header. def "Per call policy"() { setup: - def specialBlob = getSpecializedBuilder(env.primaryAccount.credential, bc.getBlobUrl(), getPerCallVersionPolicy()) + def specialBlob = getSpecializedBuilder(environment.primaryAccount.credential, bc.getBlobUrl(), getPerCallVersionPolicy()) .buildAppendBlobClient() when: diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/BlobBaseAPITest.groovy b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/BlobBaseAPITest.groovy index 7930906ab58a5..f7420c89030d8 100644 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/BlobBaseAPITest.groovy +++ b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/BlobBaseAPITest.groovy @@ -10,10 +10,8 @@ import com.azure.storage.common.implementation.Constants import com.azure.storage.common.test.shared.extensions.LiveOnly import com.azure.storage.common.test.shared.extensions.RequiredServiceVersion import reactor.core.Exceptions -import spock.lang.Requires import spock.lang.Retry import spock.lang.Unroll -import spock.lang.Ignore import java.util.function.Consumer @@ -93,7 +91,7 @@ class BlobBaseAPITest extends APISpec { @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "V2019_12_12") @Unroll - @Retry(count = 5, delay = 5, condition = { env.testMode == TestMode.LIVE }) + @Retry(count = 5, delay = 5, condition = { environment.testMode == TestMode.LIVE }) def "Query min"() { setup: BlobQueryDelimitedSerialization ser = new BlobQueryDelimitedSerialization() @@ -140,7 +138,7 @@ class BlobBaseAPITest extends APISpec { @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "V2019_12_12") @Unroll - @Retry(count = 5, delay = 5, condition = { env.testMode == TestMode.LIVE }) + @Retry(count = 5, delay = 5, condition = { environment.testMode == TestMode.LIVE }) def "Query csv serialization separator"() { setup: BlobQueryDelimitedSerialization serIn = new BlobQueryDelimitedSerialization() @@ -224,7 +222,7 @@ class BlobBaseAPITest extends APISpec { @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "V2019_12_12") @Unroll - @Retry(count = 5, delay = 5, condition = { env.testMode == TestMode.LIVE }) + @Retry(count = 5, delay = 5, condition = { environment.testMode == TestMode.LIVE }) def "Query csv serialization escape and field quote"() { setup: BlobQueryDelimitedSerialization ser = new BlobQueryDelimitedSerialization() @@ -266,7 +264,7 @@ class BlobBaseAPITest extends APISpec { /* Note: Input delimited tested everywhere */ @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "V2019_12_12") @Unroll - @Retry(count = 5, delay = 5, condition = { env.testMode == TestMode.LIVE }) + @Retry(count = 5, delay = 5, condition = { environment.testMode == TestMode.LIVE }) def "Query Input json"() { setup: BlobQueryJsonSerialization ser = new BlobQueryJsonSerialization() @@ -309,7 +307,7 @@ class BlobBaseAPITest extends APISpec { } @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "V2020_10_02") - @Retry(count = 5, delay = 5, condition = { env.testMode == TestMode.LIVE }) + @Retry(count = 5, delay = 5, condition = { environment.testMode == TestMode.LIVE }) def "Query Input parquet"() { setup: String fileName = "parquet.parquet" @@ -345,7 +343,7 @@ class BlobBaseAPITest extends APISpec { } @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "V2019_12_12") - @Retry(count = 5, delay = 5, condition = { env.testMode == TestMode.LIVE }) + @Retry(count = 5, delay = 5, condition = { environment.testMode == TestMode.LIVE }) def "Query Input csv Output json"() { setup: BlobQueryDelimitedSerialization inSer = new BlobQueryDelimitedSerialization() @@ -386,7 +384,7 @@ class BlobBaseAPITest extends APISpec { } @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "V2019_12_12") - @Retry(count = 5, delay = 5, condition = { env.testMode == TestMode.LIVE }) + @Retry(count = 5, delay = 5, condition = { environment.testMode == TestMode.LIVE }) def "Query Input json Output csv"() { setup: BlobQueryJsonSerialization inSer = new BlobQueryJsonSerialization() @@ -427,7 +425,7 @@ class BlobBaseAPITest extends APISpec { } @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "V2019_12_12") - @Retry(count = 5, delay = 5, condition = { env.testMode == TestMode.LIVE }) + @Retry(count = 5, delay = 5, condition = { environment.testMode == TestMode.LIVE }) def "Query Input csv Output arrow"() { setup: BlobQueryDelimitedSerialization inSer = new BlobQueryDelimitedSerialization() @@ -465,7 +463,7 @@ class BlobBaseAPITest extends APISpec { } @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "V2019_12_12") - @Retry(count = 5, delay = 5, condition = { env.testMode == TestMode.LIVE }) + @Retry(count = 5, delay = 5, condition = { environment.testMode == TestMode.LIVE }) def "Query non fatal error"() { setup: BlobQueryDelimitedSerialization base = new BlobQueryDelimitedSerialization() @@ -505,7 +503,7 @@ class BlobBaseAPITest extends APISpec { } @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "V2019_12_12") - @Retry(count = 5, delay = 5, condition = { env.testMode == TestMode.LIVE }) + @Retry(count = 5, delay = 5, condition = { environment.testMode == TestMode.LIVE }) def "Query fatal error"() { setup: BlobQueryDelimitedSerialization base = new BlobQueryDelimitedSerialization() @@ -535,7 +533,7 @@ class BlobBaseAPITest extends APISpec { } @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "V2019_12_12") - @Retry(count = 5, delay = 5, condition = { env.testMode == TestMode.LIVE }) + @Retry(count = 5, delay = 5, condition = { environment.testMode == TestMode.LIVE }) def "Query progress receiver"() { setup: BlobQueryDelimitedSerialization base = new BlobQueryDelimitedSerialization() @@ -580,7 +578,7 @@ class BlobBaseAPITest extends APISpec { @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "V2019_12_12") @LiveOnly // Large amount of data. - @Retry(count = 5, delay = 5, condition = { env.testMode == TestMode.LIVE }) + @Retry(count = 5, delay = 5, condition = { environment.testMode == TestMode.LIVE }) def "Query multiple records with progress receiver"() { setup: BlobQueryDelimitedSerialization ser = new BlobQueryDelimitedSerialization() @@ -632,7 +630,7 @@ class BlobBaseAPITest extends APISpec { } @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "V2019_12_12") - @Retry(count = 5, delay = 5, condition = { env.testMode == TestMode.LIVE }) + @Retry(count = 5, delay = 5, condition = { environment.testMode == TestMode.LIVE }) def "Query snapshot"() { setup: BlobQueryDelimitedSerialization ser = new BlobQueryDelimitedSerialization() @@ -674,7 +672,7 @@ class BlobBaseAPITest extends APISpec { @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "V2019_12_12") @Unroll - @Retry(count = 5, delay = 5, condition = { env.testMode == TestMode.LIVE }) + @Retry(count = 5, delay = 5, condition = { environment.testMode == TestMode.LIVE }) def "Query input output IA"() { setup: /* Mock random impl of QQ Serialization*/ @@ -705,7 +703,7 @@ class BlobBaseAPITest extends APISpec { } @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "V2019_12_12") - @Retry(count = 5, delay = 5, condition = { env.testMode == TestMode.LIVE }) + @Retry(count = 5, delay = 5, condition = { environment.testMode == TestMode.LIVE }) def "Query arrow input IA"() { setup: def inSer = new BlobQueryArrowSerialization() @@ -729,7 +727,7 @@ class BlobBaseAPITest extends APISpec { } @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "V2020_10_02") - @Retry(count = 5, delay = 5, condition = { env.testMode == TestMode.LIVE }) + @Retry(count = 5, delay = 5, condition = { environment.testMode == TestMode.LIVE }) def "Query parquet output IA"() { setup: def outSer = new BlobQueryParquetSerialization() @@ -753,7 +751,7 @@ class BlobBaseAPITest extends APISpec { } @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "V2019_12_12") - @Retry(count = 5, delay = 5, condition = { env.testMode == TestMode.LIVE }) + @Retry(count = 5, delay = 5, condition = { environment.testMode == TestMode.LIVE }) def "Query error"() { setup: bc = cc.getBlobClient(generateBlobName()) @@ -773,7 +771,7 @@ class BlobBaseAPITest extends APISpec { @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "V2019_12_12") @Unroll - @Retry(count = 5, delay = 5, condition = { env.testMode == TestMode.LIVE }) + @Retry(count = 5, delay = 5, condition = { environment.testMode == TestMode.LIVE }) def "Query AC"() { setup: def t = new HashMap() diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/BlockBlobAPITest.groovy b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/BlockBlobAPITest.groovy index d212d67cc725f..08a77580e035c 100644 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/BlockBlobAPITest.groovy +++ b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/BlockBlobAPITest.groovy @@ -181,7 +181,7 @@ class BlockBlobAPITest extends APISpec { def "Stage block retry on transient failure"() { setup: def clientWithFailure = getBlobClient( - env.primaryAccount.credential, + environment.primaryAccount.credential, blobClient.getBlobUrl(), new TransientFailureInjectingHttpPipelinePolicy() ).getBlockBlobClient() @@ -1161,7 +1161,7 @@ class BlockBlobAPITest extends APISpec { def "Upload retry on transient failure"() { setup: def clientWithFailure = getBlobClient( - env.primaryAccount.credential, + environment.primaryAccount.credential, blobClient.getBlobUrl(), new TransientFailureInjectingHttpPipelinePolicy() ).getBlockBlobClient() @@ -1449,7 +1449,7 @@ class BlockBlobAPITest extends APISpec { def "Buffered upload handle pathing hot flux with transient failure"() { setup: def clientWithFailure = getBlobAsyncClient( - env.primaryAccount.credential, + environment.primaryAccount.credential, blobAsyncClient.getBlobUrl(), new TransientFailureInjectingHttpPipelinePolicy() ) @@ -1485,7 +1485,7 @@ class BlockBlobAPITest extends APISpec { */ setup: def clientWithFailure = getBlobClient( - env.primaryAccount.credential, + environment.primaryAccount.credential, blobClient.getBlobUrl(), new TransientFailureInjectingHttpPipelinePolicy() ) @@ -1800,8 +1800,8 @@ class BlockBlobAPITest extends APISpec { // Build the pipeline blobAsyncClient = new BlobServiceClientBuilder() - .credential(env.primaryAccount.credential) - .endpoint(env.primaryAccount.blobEndpoint) + .credential(environment.primaryAccount.credential) + .endpoint(environment.primaryAccount.blobEndpoint) .retryOptions(new RequestRetryOptions(null, 3, null, 500, 1500, null)) .addPolicy(mockPolicy).buildAsyncClient() .getBlobContainerAsyncClient(generateContainerName()).getBlobAsyncClient(generateBlobName()) @@ -1944,11 +1944,11 @@ class BlockBlobAPITest extends APISpec { thrown(IllegalArgumentException) } - @IgnoreIf( { getEnv().serviceVersion != null } ) + @IgnoreIf( { getEnvironment().serviceVersion != null } ) // This tests the policy is in the right place because if it were added per retry, it would be after the credentials and auth would fail because we changed a signed header. def "Per call policy"() { setup: - def specialBlob = getSpecializedBuilder(env.primaryAccount.credential, blockBlobClient.getBlobUrl(), getPerCallVersionPolicy()) + def specialBlob = getSpecializedBuilder(environment.primaryAccount.credential, blockBlobClient.getBlobUrl(), getPerCallVersionPolicy()) .buildBlockBlobClient() when: diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/DownloadResponseTest.groovy b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/DownloadResponseTest.groovy index 4ee065002eb1c..72c11b106cdf6 100644 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/DownloadResponseTest.groovy +++ b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/DownloadResponseTest.groovy @@ -11,9 +11,7 @@ import com.azure.core.http.HttpResponse import com.azure.core.http.policy.HttpPipelinePolicy import com.azure.core.util.FluxUtil import com.azure.storage.blob.APISpec -import com.azure.storage.blob.HttpGetterInfo import com.azure.storage.blob.models.BlobRange -import com.azure.storage.blob.models.BlobRequestConditions import com.azure.storage.blob.models.BlobStorageException import com.azure.storage.blob.models.DownloadRetryOptions import reactor.core.Exceptions @@ -60,7 +58,7 @@ class DownloadResponseTest extends APISpec { }) } } - def bsc = getServiceClientBuilder(env.primaryAccount.credential, primaryBlobServiceClient.getAccountUrl(), removeEtagPolicy).buildClient() + def bsc = getServiceClientBuilder(environment.primaryAccount.credential, primaryBlobServiceClient.getAccountUrl(), removeEtagPolicy).buildClient() def cc = bsc.getBlobContainerClient(containerName) def bu = cc.getBlobClient(bu.getBlobName()).getBlockBlobClient() @@ -77,7 +75,7 @@ class DownloadResponseTest extends APISpec { DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(5) - def bsc = getServiceClientBuilder(env.primaryAccount.credential, primaryBlobServiceClient.getAccountUrl(), flux.asPolicy()).buildAsyncClient() + def bsc = getServiceClientBuilder(environment.primaryAccount.credential, primaryBlobServiceClient.getAccountUrl(), flux.asPolicy()).buildAsyncClient() def cc = bsc.getBlobContainerAsyncClient(containerName) def bu = cc.getBlobAsyncClient(bu.getBlobName()).getBlockBlobAsyncClient() BlobRange range = setCount ? new BlobRange(0, flux.getScenarioData().remaining()) : new BlobRange(0); @@ -106,7 +104,7 @@ class DownloadResponseTest extends APISpec { DownloadResponseMockFlux flux = new DownloadResponseMockFlux(scenario, this) DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(5) - def bsc = getServiceClientBuilder(env.primaryAccount.credential, primaryBlobServiceClient.getAccountUrl(), flux.asPolicy()).buildAsyncClient() + def bsc = getServiceClientBuilder(environment.primaryAccount.credential, primaryBlobServiceClient.getAccountUrl(), flux.asPolicy()).buildAsyncClient() def cc = bsc.getBlobContainerAsyncClient(containerName) def bu = cc.getBlobAsyncClient(bu.getBlobName()).getBlockBlobAsyncClient() @@ -136,7 +134,7 @@ class DownloadResponseTest extends APISpec { this) DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(retryCount) - def bsc = getServiceClientBuilder(env.primaryAccount.credential, primaryBlobServiceClient.getAccountUrl(), flux.asPolicy()).buildAsyncClient() + def bsc = getServiceClientBuilder(environment.primaryAccount.credential, primaryBlobServiceClient.getAccountUrl(), flux.asPolicy()).buildAsyncClient() def cc = bsc.getBlobContainerAsyncClient(containerName) def bu = cc.getBlobAsyncClient(bu.getBlobName()).getBlockBlobAsyncClient() diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/HelperTest.groovy b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/HelperTest.groovy index 827d709dd9b34..0f88e49e687d0 100644 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/HelperTest.groovy +++ b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/HelperTest.groovy @@ -103,7 +103,7 @@ class HelperTest extends APISpec { def sasValues = new BlobServiceSasSignatureValues(e, p) def implUtil = new BlobSasImplUtil(sasValues, "containerName", "blobName", "snapshot", null) - def sas = implUtil.generateSas(env.primaryAccount.credential, Context.NONE) + def sas = implUtil.generateSas(environment.primaryAccount.credential, Context.NONE) parts.setCommonSasQueryParameters(new CommonSasQueryParameters(SasImplUtils.parseQueryString(sas), true)) diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/PageBlobAPITest.groovy b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/PageBlobAPITest.groovy index fd8a838cb0d99..b53dd3a410ede 100644 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/PageBlobAPITest.groovy +++ b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/PageBlobAPITest.groovy @@ -362,7 +362,7 @@ class PageBlobAPITest extends APISpec { def "Upload page retry on transient failure"() { setup: def clientWithFailure = getBlobClient( - env.primaryAccount.credential, + environment.primaryAccount.credential, bc.getBlobUrl(), new TransientFailureInjectingHttpPipelinePolicy() ).getPageBlobClient() @@ -969,7 +969,7 @@ class PageBlobAPITest extends APISpec { @Ignore def "Get page ranges diff prev snapshot url"() { setup: - BlobServiceClient managedDiskServiceClient = getServiceClient(env.managedDiskAccount) + BlobServiceClient managedDiskServiceClient = getServiceClient(environment.managedDiskAccount) BlobContainerClient managedDiskContainer = managedDiskServiceClient.getBlobContainerClient(generateContainerName()) managedDiskContainer.create() PageBlobClient managedDiskBlob = managedDiskContainer.getBlobClient(generateBlobName()).getPageBlobClient() @@ -1358,11 +1358,11 @@ class PageBlobAPITest extends APISpec { notThrown(Throwable) } - @IgnoreIf( { getEnv().serviceVersion != null } ) + @IgnoreIf( { getEnvironment().serviceVersion != null } ) // This tests the policy is in the right place because if it were added per retry, it would be after the credentials and auth would fail because we changed a signed header. def "Per call policy"() { setup: - def specialBlob = getSpecializedBuilder(env.primaryAccount.credential, bc.getBlobUrl(), getPerCallVersionPolicy()) + def specialBlob = getSpecializedBuilder(environment.primaryAccount.credential, bc.getBlobUrl(), getPerCallVersionPolicy()) .buildPageBlobClient() when: diff --git a/sdk/storage/azure-storage-common/pom.xml b/sdk/storage/azure-storage-common/pom.xml index 8fc4f2d2750fd..e9a0314416d2f 100644 --- a/sdk/storage/azure-storage-common/pom.xml +++ b/sdk/storage/azure-storage-common/pom.xml @@ -89,12 +89,6 @@ 3.4.9 test - - org.spockframework - spock-core - 2.0-M4-groovy-2.5 - test - org.apache.logging.log4j log4j-slf4j-impl @@ -181,6 +175,14 @@ [1.8,9) + + + org.spockframework + spock-core + 2.0-M4-groovy-2.5 + test + + @@ -223,6 +225,14 @@ [9,) + + + org.spockframework + spock-core + 2.0-groovy-3.0 + test + + diff --git a/sdk/storage/azure-storage-common/src/test-shared/java/com/azure/storage/common/test/shared/StorageSpec.groovy b/sdk/storage/azure-storage-common/src/test-shared/java/com/azure/storage/common/test/shared/StorageSpec.groovy index 035a55a4b7424..be76a5ebc6184 100644 --- a/sdk/storage/azure-storage-common/src/test-shared/java/com/azure/storage/common/test/shared/StorageSpec.groovy +++ b/sdk/storage/azure-storage-common/src/test-shared/java/com/azure/storage/common/test/shared/StorageSpec.groovy @@ -48,7 +48,7 @@ class StorageSpec extends Specification { interceptorManager.close() } - protected static TestEnvironment getEnv() { + protected static TestEnvironment getEnvironment() { return ENVIRONMENT } @@ -107,7 +107,7 @@ class StorageSpec extends Specification { } private static String getAuthToken() { - if (env.testMode == TestMode.PLAYBACK) { + if (environment.testMode == TestMode.PLAYBACK) { // we just need some string to satisfy SDK for playback mode. Recording framework handles this fine. return "recordingBearerToken" } diff --git a/sdk/storage/azure-storage-file-datalake/pom.xml b/sdk/storage/azure-storage-file-datalake/pom.xml index a38991c10a941..3c07d9faa2e7c 100644 --- a/sdk/storage/azure-storage-file-datalake/pom.xml +++ b/sdk/storage/azure-storage-file-datalake/pom.xml @@ -126,12 +126,6 @@ 3.4.9 test - - org.spockframework - spock-core - 2.0-M4-groovy-2.5 - test - cglib cglib-nodep @@ -231,6 +225,14 @@ [1.8,9) + + + org.spockframework + spock-core + 2.0-M4-groovy-2.5 + test + + @@ -273,6 +275,14 @@ [9,) + + + org.spockframework + spock-core + 2.0-groovy-3.0 + test + + diff --git a/sdk/storage/azure-storage-file-datalake/src/test/java/com/azure/storage/file/datalake/APISpec.groovy b/sdk/storage/azure-storage-file-datalake/src/test/java/com/azure/storage/file/datalake/APISpec.groovy index 59b62a4b26319..c6485af2634cc 100644 --- a/sdk/storage/azure-storage-file-datalake/src/test/java/com/azure/storage/file/datalake/APISpec.groovy +++ b/sdk/storage/azure-storage-file-datalake/src/test/java/com/azure/storage/file/datalake/APISpec.groovy @@ -18,7 +18,6 @@ import com.azure.storage.common.implementation.Constants import com.azure.storage.common.policy.RequestRetryOptions import com.azure.storage.common.test.shared.StorageSpec import com.azure.storage.common.test.shared.TestAccount -import com.azure.storage.common.test.shared.policy.MockDownloadHttpResponse import com.azure.storage.file.datalake.models.LeaseStateType import com.azure.storage.file.datalake.models.ListFileSystemsOptions import com.azure.storage.file.datalake.models.PathAccessControlEntry @@ -72,8 +71,8 @@ class APISpec extends StorageSpec { def fileSystemName def setup() { - primaryDataLakeServiceClient = getServiceClient(env.dataLakeAccount) - primaryDataLakeServiceAsyncClient = getServiceAsyncClient(env.dataLakeAccount) + primaryDataLakeServiceClient = getServiceClient(environment.dataLakeAccount) + primaryDataLakeServiceAsyncClient = getServiceAsyncClient(environment.dataLakeAccount) fileSystemName = generateFileSystemName() fsc = primaryDataLakeServiceClient.getFileSystemClient(fileSystemName) @@ -82,11 +81,11 @@ class APISpec extends StorageSpec { } def cleanup() { - if (env.testMode != TestMode.PLAYBACK) { + if (environment.testMode != TestMode.PLAYBACK) { def cleanupClient = new DataLakeServiceClientBuilder() .httpClient(getHttpClient()) - .credential(env.dataLakeAccount.credential) - .endpoint(env.dataLakeAccount.dataLakeEndpoint) + .credential(environment.dataLakeAccount.credential) + .endpoint(environment.dataLakeAccount.dataLakeEndpoint) .buildClient() def options = new ListFileSystemsOptions().setPrefix(namer.getResourcePrefix()) @@ -109,16 +108,16 @@ class APISpec extends StorageSpec { def getOAuthServiceClient() { DataLakeServiceClientBuilder builder = new DataLakeServiceClientBuilder() - .endpoint(env.dataLakeAccount.dataLakeEndpoint) + .endpoint(environment.dataLakeAccount.dataLakeEndpoint) instrument(builder) - if (env.testMode != TestMode.PLAYBACK) { + if (environment.testMode != TestMode.PLAYBACK) { // AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET return builder.credential(new EnvironmentCredentialBuilder().build()).buildClient() } else { // Running in playback, we don't have access to the AAD environment variables, just use SharedKeyCredential. - return builder.credential(env.dataLakeAccount.credential).buildClient() + return builder.credential(environment.dataLakeAccount.credential).buildClient() } } @@ -168,7 +167,7 @@ class APISpec extends StorageSpec { DataLakeServiceAsyncClient getPrimaryServiceClientForWrites(long perRequestDataSize) { int retryTimeout = Math.toIntExact((long) (perRequestDataSize / Constants.MB) * 20) retryTimeout = Math.max(60, retryTimeout) - return getServiceClientBuilder(env.dataLakeAccount) + return getServiceClientBuilder(environment.dataLakeAccount) .retryOptions(new RequestRetryOptions(null, null, retryTimeout, null, null, null)) .buildAsyncClient() } @@ -495,7 +494,7 @@ class APISpec extends StorageSpec { // Only sleep if test is running in live mode def sleepIfRecord(long milliseconds) { - if (env.testMode != TestMode.PLAYBACK) { + if (environment.testMode != TestMode.PLAYBACK) { sleep(milliseconds) } } @@ -526,7 +525,7 @@ class APISpec extends StorageSpec { } def sleepIfLive(long milliseconds) { - if (env.testMode == TestMode.PLAYBACK) { + if (environment.testMode == TestMode.PLAYBACK) { return } sleep(milliseconds) diff --git a/sdk/storage/azure-storage-file-datalake/src/test/java/com/azure/storage/file/datalake/AsyncErrorMappingTest.groovy b/sdk/storage/azure-storage-file-datalake/src/test/java/com/azure/storage/file/datalake/AsyncErrorMappingTest.groovy index 218792194a9a4..facba332cd282 100644 --- a/sdk/storage/azure-storage-file-datalake/src/test/java/com/azure/storage/file/datalake/AsyncErrorMappingTest.groovy +++ b/sdk/storage/azure-storage-file-datalake/src/test/java/com/azure/storage/file/datalake/AsyncErrorMappingTest.groovy @@ -12,7 +12,7 @@ class AsyncErrorMappingTest extends APISpec { def setup() { fileSystemName = generateFileSystemName() - fsac = getServiceAsyncClient(env.dataLakeAccount).createFileSystem(fileSystemName).block() + fsac = getServiceAsyncClient(environment.dataLakeAccount).createFileSystem(fileSystemName).block() } def "Read file"() { @@ -80,7 +80,7 @@ class AsyncErrorMappingTest extends APISpec { def "Create file system"() { when: - def fsac = getServiceAsyncClient(env.dataLakeAccount).getFileSystemAsyncClient(fileSystemName) + def fsac = getServiceAsyncClient(environment.dataLakeAccount).getFileSystemAsyncClient(fileSystemName) def createVerifier = StepVerifier.create(fsac.createWithResponse(null, null)) then: createVerifier.verifyError(DataLakeStorageException) @@ -89,7 +89,7 @@ class AsyncErrorMappingTest extends APISpec { def "Get file system properties"() { when: def fileSystemName = generateFileSystemName() - def fsac = getServiceAsyncClient(env.dataLakeAccount).getFileSystemAsyncClient(fileSystemName) + def fsac = getServiceAsyncClient(environment.dataLakeAccount).getFileSystemAsyncClient(fileSystemName) def getPropertiesVerifier = StepVerifier.create(fsac.getPropertiesWithResponse(null)) then: getPropertiesVerifier.verifyError(DataLakeStorageException) @@ -98,7 +98,7 @@ class AsyncErrorMappingTest extends APISpec { def "Set file system metadata"() { when: def fileSystemName = generateFileSystemName() - def fsac = getServiceAsyncClient(env.dataLakeAccount).getFileSystemAsyncClient(fileSystemName) + def fsac = getServiceAsyncClient(environment.dataLakeAccount).getFileSystemAsyncClient(fileSystemName) def setMetadataVerifier = StepVerifier.create(fsac.setMetadataWithResponse(null, null)) then: setMetadataVerifier.verifyError(DataLakeStorageException) @@ -107,7 +107,7 @@ class AsyncErrorMappingTest extends APISpec { def "Delete file system"() { when: def fileSystemName = generateFileSystemName() - def fsac = getServiceAsyncClient(env.dataLakeAccount).getFileSystemAsyncClient(fileSystemName) + def fsac = getServiceAsyncClient(environment.dataLakeAccount).getFileSystemAsyncClient(fileSystemName) def setMetadataVerifier = StepVerifier.create(fsac.deleteWithResponse(null)) then: setMetadataVerifier.verifyError(DataLakeStorageException) @@ -116,7 +116,7 @@ class AsyncErrorMappingTest extends APISpec { def "Get file system access policy"() { when: def fileSystemName = generateFileSystemName() - def fsac = getServiceAsyncClient(env.dataLakeAccount).getFileSystemAsyncClient(fileSystemName) + def fsac = getServiceAsyncClient(environment.dataLakeAccount).getFileSystemAsyncClient(fileSystemName) def getAccessPolicyVerifier = StepVerifier.create(fsac.getAccessPolicyWithResponse(null)) then: getAccessPolicyVerifier.verifyError(DataLakeStorageException) @@ -125,7 +125,7 @@ class AsyncErrorMappingTest extends APISpec { def "Set file system access policy"() { when: def fileSystemName = generateFileSystemName() - def fsac = getServiceAsyncClient(env.dataLakeAccount).getFileSystemAsyncClient(fileSystemName) + def fsac = getServiceAsyncClient(environment.dataLakeAccount).getFileSystemAsyncClient(fileSystemName) def setAccessPolicyVerifier = StepVerifier.create(fsac.setAccessPolicyWithResponse(null, null, null)) then: setAccessPolicyVerifier.verifyError(DataLakeStorageException) @@ -134,7 +134,7 @@ class AsyncErrorMappingTest extends APISpec { def "List file systems"() { when: - PagedFlux items = getServiceAsyncClient(env.dataLakeAccount).listFileSystems() + PagedFlux items = getServiceAsyncClient(environment.dataLakeAccount).listFileSystems() def listFileSystemsVerifier = StepVerifier.create(items.byPage("garbage continuation token").count()) then: listFileSystemsVerifier.verifyError(DataLakeStorageException) diff --git a/sdk/storage/azure-storage-file-datalake/src/test/java/com/azure/storage/file/datalake/DirectoryAPITest.groovy b/sdk/storage/azure-storage-file-datalake/src/test/java/com/azure/storage/file/datalake/DirectoryAPITest.groovy index 13670fcc838b4..8dd5cb9d84fb0 100644 --- a/sdk/storage/azure-storage-file-datalake/src/test/java/com/azure/storage/file/datalake/DirectoryAPITest.groovy +++ b/sdk/storage/azure-storage-file-datalake/src/test/java/com/azure/storage/file/datalake/DirectoryAPITest.groovy @@ -858,7 +858,7 @@ class DirectoryAPITest extends APISpec { return context.getHttpRequest().getUrl().toString().contains("continuation") ? Mono.error(error) : next.process() } - dc = getDirectoryClient(env.dataLakeAccount.credential, dc.getDirectoryUrl(), dc.getObjectPath(), mockPolicy) + dc = getDirectoryClient(environment.dataLakeAccount.credential, dc.getDirectoryUrl(), dc.getObjectPath(), mockPolicy) when: def result = dc.setAccessControlRecursiveWithResponse(options, null, null).getValue() @@ -1265,7 +1265,7 @@ class DirectoryAPITest extends APISpec { return context.getHttpRequest().getUrl().toString().contains("continuation") ? Mono.error(error) : next.process() } - dc = getDirectoryClient(env.dataLakeAccount.credential, dc.getDirectoryUrl(), dc.getObjectPath(), mockPolicy) + dc = getDirectoryClient(environment.dataLakeAccount.credential, dc.getDirectoryUrl(), dc.getObjectPath(), mockPolicy) when: def result = dc.updateAccessControlRecursiveWithResponse(options, null, null).getValue() @@ -1671,7 +1671,7 @@ class DirectoryAPITest extends APISpec { return context.getHttpRequest().getUrl().toString().contains("continuation") ? Mono.error(error) : next.process() } - dc = getDirectoryClient(env.dataLakeAccount.credential, dc.getDirectoryUrl(), dc.getObjectPath(), mockPolicy) + dc = getDirectoryClient(environment.dataLakeAccount.credential, dc.getDirectoryUrl(), dc.getObjectPath(), mockPolicy) when: def result = dc.removeAccessControlRecursiveWithResponse(options, null, null).getValue() @@ -2911,11 +2911,11 @@ class DirectoryAPITest extends APISpec { notThrown(DataLakeStorageException) } - @IgnoreIf( { getEnv().serviceVersion != null } ) + @IgnoreIf( { getEnvironment().serviceVersion != null } ) // This tests the policy is in the right place because if it were added per retry, it would be after the credentials and auth would fail because we changed a signed header. def "Per call policy"() { setup: - def directoryClient = getDirectoryClient(env.dataLakeAccount.credential, fsc.getFileSystemUrl(), dc.getObjectPath(), getPerCallVersionPolicy()) + def directoryClient = getDirectoryClient(environment.dataLakeAccount.credential, fsc.getFileSystemUrl(), dc.getObjectPath(), getPerCallVersionPolicy()) when: "blob endpoint" def response = directoryClient.getPropertiesWithResponse(null, null, null) diff --git a/sdk/storage/azure-storage-file-datalake/src/test/java/com/azure/storage/file/datalake/FileAPITest.groovy b/sdk/storage/azure-storage-file-datalake/src/test/java/com/azure/storage/file/datalake/FileAPITest.groovy index 0364606bd58d8..2e12ae98a7926 100644 --- a/sdk/storage/azure-storage-file-datalake/src/test/java/com/azure/storage/file/datalake/FileAPITest.groovy +++ b/sdk/storage/azure-storage-file-datalake/src/test/java/com/azure/storage/file/datalake/FileAPITest.groovy @@ -978,7 +978,7 @@ class FileAPITest extends APISpec { constructed in BlobClient.download(). */ setup: - def fileClient = getFileClient(env.dataLakeAccount.credential, fc.getPathUrl(), new MockRetryRangeResponsePolicy("bytes=2-6")) + def fileClient = getFileClient(environment.dataLakeAccount.credential, fc.getPathUrl(), new MockRetryRangeResponsePolicy("bytes=2-6")) fc.append(new ByteArrayInputStream(data.defaultBytes), 0, data.defaultDataSize) fc.flush(data.defaultDataSize) @@ -1105,7 +1105,7 @@ class FileAPITest extends APISpec { setup: fc.append(new ByteArrayInputStream(data.defaultBytes), 0, data.defaultDataSize) fc.flush(data.defaultDataSize) - def failureFileClient = getFileClient(env.dataLakeAccount.credential, fc.getFileUrl(), new MockFailureResponsePolicy(5)) + def failureFileClient = getFileClient(environment.dataLakeAccount.credential, fc.getFileUrl(), new MockFailureResponsePolicy(5)) when: def outStream = new ByteArrayOutputStream() @@ -1271,8 +1271,8 @@ class FileAPITest extends APISpec { setup: def fileSystemName = generateFileSystemName() def datalakeServiceClient = new DataLakeServiceClientBuilder() - .endpoint(env.dataLakeAccount.dataLakeEndpoint) - .credential(env.dataLakeAccount.credential) + .endpoint(environment.dataLakeAccount.dataLakeEndpoint) + .credential(environment.dataLakeAccount.credential) .buildClient() def fileClient = datalakeServiceClient.createFileSystem(fileSystemName) @@ -1313,8 +1313,8 @@ class FileAPITest extends APISpec { setup: def fileSystemName = generateFileSystemName() def datalakeServiceAsyncClient = new DataLakeServiceClientBuilder() - .endpoint(env.dataLakeAccount.dataLakeEndpoint) - .credential(env.dataLakeAccount.credential) + .endpoint(environment.dataLakeAccount.dataLakeEndpoint) + .credential(environment.dataLakeAccount.credential) .buildAsyncClient() def fileAsyncClient = datalakeServiceAsyncClient.createFileSystem(fileSystemName).block() @@ -1512,7 +1512,7 @@ class FileAPITest extends APISpec { def facUploading = instrument(new DataLakePathClientBuilder() .endpoint(fc.getPathUrl()) - .credential(env.dataLakeAccount.credential)) + .credential(environment.dataLakeAccount.credential)) .buildFileAsyncClient() def facDownloading = instrument(new DataLakePathClientBuilder() @@ -1531,7 +1531,7 @@ class FileAPITest extends APISpec { }) }) .endpoint(fc.getPathUrl()) - .credential(env.dataLakeAccount.credential)) + .credential(environment.dataLakeAccount.credential)) .buildFileAsyncClient() /* @@ -1931,7 +1931,7 @@ class FileAPITest extends APISpec { def "Append data retry on transient failure"() { setup: def clientWithFailure = getFileClient( - env.dataLakeAccount.credential, + environment.dataLakeAccount.credential, fc.getFileUrl(), new TransientFailureInjectingHttpPipelinePolicy() ) @@ -2528,7 +2528,7 @@ class FileAPITest extends APISpec { def "Buffered upload handle pathing hot flux with transient failure"() { setup: def clientWithFailure = getFileAsyncClient( - env.dataLakeAccount.credential, + environment.dataLakeAccount.credential, fc.getFileUrl(), new TransientFailureInjectingHttpPipelinePolicy() ) @@ -2540,7 +2540,7 @@ class FileAPITest extends APISpec { new ParallelTransferOptions().setMaxSingleUploadSizeLong(4 * Constants.MB), true) then: - def fcAsync = getFileAsyncClient(env.dataLakeAccount.credential, fc.getFileUrl()) + def fcAsync = getFileAsyncClient(environment.dataLakeAccount.credential, fc.getFileUrl()) StepVerifier.create(uploadOperation.then(collectBytesInBuffer(fcAsync.read()))) .assertNext({ assert compareListToBuffer(dataList, it) }) .verifyComplete() @@ -2561,7 +2561,7 @@ class FileAPITest extends APISpec { */ setup: def clientWithFailure = getFileClient( - env.dataLakeAccount.credential, + environment.dataLakeAccount.credential, fc.getFileUrl(), new TransientFailureInjectingHttpPipelinePolicy() ) @@ -2949,7 +2949,7 @@ class FileAPITest extends APISpec { def "Upload successful retry"() { given: def clientWithFailure = getFileClient( - env.dataLakeAccount.credential, + environment.dataLakeAccount.credential, fc.getFileUrl(), new TransientFailureInjectingHttpPipelinePolicy()) @@ -3032,7 +3032,7 @@ class FileAPITest extends APISpec { @RequiredServiceVersion(clazz = DataLakeServiceVersion.class, min = "V2019_12_12") @Unroll - @Retry(count = 5, delay = 5, condition = { env.testMode == TestMode.LIVE }) + @Retry(count = 5, delay = 5, condition = { environment.testMode == TestMode.LIVE }) def "Query min"() { setup: FileQueryDelimitedSerialization ser = new FileQueryDelimitedSerialization() @@ -3079,7 +3079,7 @@ class FileAPITest extends APISpec { @RequiredServiceVersion(clazz = DataLakeServiceVersion.class, min = "V2019_12_12") @Unroll - @Retry(count = 5, delay = 5, condition = { env.testMode == TestMode.LIVE }) + @Retry(count = 5, delay = 5, condition = { environment.testMode == TestMode.LIVE }) def "Query csv serialization separator"() { setup: FileQueryDelimitedSerialization serIn = new FileQueryDelimitedSerialization() @@ -3163,7 +3163,7 @@ class FileAPITest extends APISpec { @RequiredServiceVersion(clazz = DataLakeServiceVersion.class, min = "V2019_12_12") @Unroll - @Retry(count = 5, delay = 5, condition = { env.testMode == TestMode.LIVE }) + @Retry(count = 5, delay = 5, condition = { environment.testMode == TestMode.LIVE }) def "Query csv serialization escape and field quote"() { setup: FileQueryDelimitedSerialization ser = new FileQueryDelimitedSerialization() @@ -3205,7 +3205,7 @@ class FileAPITest extends APISpec { /* Note: Input delimited tested everywhere else. */ @RequiredServiceVersion(clazz = DataLakeServiceVersion.class, min = "V2019_12_12") @Unroll - @Retry(count = 5, delay = 5, condition = { env.testMode == TestMode.LIVE }) + @Retry(count = 5, delay = 5, condition = { environment.testMode == TestMode.LIVE }) def "Query Input json"() { setup: FileQueryJsonSerialization ser = new FileQueryJsonSerialization() @@ -3248,7 +3248,7 @@ class FileAPITest extends APISpec { } @RequiredServiceVersion(clazz = DataLakeServiceVersion.class, min = "V2020_10_02") - @Retry(count = 5, delay = 5, condition = { env.testMode == TestMode.LIVE }) + @Retry(count = 5, delay = 5, condition = { environment.testMode == TestMode.LIVE }) def "Query Input parquet"() { setup: String fileName = "parquet.parquet" @@ -3284,7 +3284,7 @@ class FileAPITest extends APISpec { } @RequiredServiceVersion(clazz = DataLakeServiceVersion.class, min = "V2019_12_12") - @Retry(count = 5, delay = 5, condition = { env.testMode == TestMode.LIVE }) + @Retry(count = 5, delay = 5, condition = { environment.testMode == TestMode.LIVE }) def "Query Input csv Output json"() { setup: FileQueryDelimitedSerialization inSer = new FileQueryDelimitedSerialization() @@ -3326,7 +3326,7 @@ class FileAPITest extends APISpec { } @RequiredServiceVersion(clazz = DataLakeServiceVersion.class, min = "V2019_12_12") - @Retry(count = 5, delay = 5, condition = { env.testMode == TestMode.LIVE }) + @Retry(count = 5, delay = 5, condition = { environment.testMode == TestMode.LIVE }) def "Query Input json Output csv"() { setup: FileQueryJsonSerialization inSer = new FileQueryJsonSerialization() @@ -3368,7 +3368,7 @@ class FileAPITest extends APISpec { } @RequiredServiceVersion(clazz = DataLakeServiceVersion.class, min = "V2019_12_12") - @Retry(count = 5, delay = 5, condition = { env.testMode == TestMode.LIVE }) + @Retry(count = 5, delay = 5, condition = { environment.testMode == TestMode.LIVE }) def "Query Input csv Output arrow"() { setup: FileQueryDelimitedSerialization inSer = new FileQueryDelimitedSerialization() @@ -3406,7 +3406,7 @@ class FileAPITest extends APISpec { } @RequiredServiceVersion(clazz = DataLakeServiceVersion.class, min = "V2019_12_12") - @Retry(count = 5, delay = 5, condition = { env.testMode == TestMode.LIVE }) + @Retry(count = 5, delay = 5, condition = { environment.testMode == TestMode.LIVE }) def "Query non fatal error"() { setup: FileQueryDelimitedSerialization base = new FileQueryDelimitedSerialization() @@ -3446,7 +3446,7 @@ class FileAPITest extends APISpec { } @RequiredServiceVersion(clazz = DataLakeServiceVersion.class, min = "V2019_12_12") - @Retry(count = 5, delay = 5, condition = { env.testMode == TestMode.LIVE }) + @Retry(count = 5, delay = 5, condition = { environment.testMode == TestMode.LIVE }) def "Query fatal error"() { setup: FileQueryDelimitedSerialization base = new FileQueryDelimitedSerialization() @@ -3478,7 +3478,7 @@ class FileAPITest extends APISpec { } @RequiredServiceVersion(clazz = DataLakeServiceVersion.class, min = "V2019_12_12") - @Retry(count = 5, delay = 5, condition = { env.testMode == TestMode.LIVE }) + @Retry(count = 5, delay = 5, condition = { environment.testMode == TestMode.LIVE }) def "Query progress receiver"() { setup: FileQueryDelimitedSerialization base = new FileQueryDelimitedSerialization() @@ -3523,7 +3523,7 @@ class FileAPITest extends APISpec { @RequiredServiceVersion(clazz = DataLakeServiceVersion.class, min = "V2019_12_12") @LiveOnly // Large amount of data. - @Retry(count = 5, delay = 5, condition = { env.testMode == TestMode.LIVE }) + @Retry(count = 5, delay = 5, condition = { environment.testMode == TestMode.LIVE }) def "Query multiple records with progress receiver"() { setup: FileQueryDelimitedSerialization ser = new FileQueryDelimitedSerialization() @@ -3576,7 +3576,7 @@ class FileAPITest extends APISpec { @RequiredServiceVersion(clazz = DataLakeServiceVersion.class, min = "V2019_12_12") @Unroll - @Retry(count = 5, delay = 5, condition = { env.testMode == TestMode.LIVE }) + @Retry(count = 5, delay = 5, condition = { environment.testMode == TestMode.LIVE }) def "Query input output IA"() { setup: /* Mock random impl of QQ Serialization*/ @@ -3611,7 +3611,7 @@ class FileAPITest extends APISpec { } @RequiredServiceVersion(clazz = DataLakeServiceVersion.class, min = "V2019_12_12") - @Retry(count = 5, delay = 5, condition = { env.testMode == TestMode.LIVE }) + @Retry(count = 5, delay = 5, condition = { environment.testMode == TestMode.LIVE }) def "Query arrow input IA"() { setup: def inSer = new FileQueryArrowSerialization() @@ -3635,7 +3635,7 @@ class FileAPITest extends APISpec { } @RequiredServiceVersion(clazz = DataLakeServiceVersion.class, min = "V2020_10_02") - @Retry(count = 5, delay = 5, condition = { env.testMode == TestMode.LIVE }) + @Retry(count = 5, delay = 5, condition = { environment.testMode == TestMode.LIVE }) def "Query parquet output IA"() { setup: def outSer = new FileQueryParquetSerialization() @@ -3659,7 +3659,7 @@ class FileAPITest extends APISpec { } @RequiredServiceVersion(clazz = DataLakeServiceVersion.class, min = "V2019_12_12") - @Retry(count = 5, delay = 5, condition = { env.testMode == TestMode.LIVE }) + @Retry(count = 5, delay = 5, condition = { environment.testMode == TestMode.LIVE }) def "Query error"() { setup: fc = fsc.getFileClient(generatePathName()) @@ -3679,7 +3679,7 @@ class FileAPITest extends APISpec { @RequiredServiceVersion(clazz = DataLakeServiceVersion.class, min = "V2019_12_12") @Unroll - @Retry(count = 5, delay = 5, condition = { env.testMode == TestMode.LIVE }) + @Retry(count = 5, delay = 5, condition = { environment.testMode == TestMode.LIVE }) def "Query AC"() { setup: match = setupPathMatchCondition(fc, match) @@ -3968,11 +3968,11 @@ class FileAPITest extends APISpec { thrown(IllegalStateException) } - @IgnoreIf( { getEnv().serviceVersion != null } ) + @IgnoreIf( { getEnvironment().serviceVersion != null } ) // This tests the policy is in the right place because if it were added per retry, it would be after the credentials and auth would fail because we changed a signed header. def "Per call policy"() { setup: - def fileClient = getFileClient(env.dataLakeAccount.credential, fc.getFileUrl(), getPerCallVersionPolicy()) + def fileClient = getFileClient(environment.dataLakeAccount.credential, fc.getFileUrl(), getPerCallVersionPolicy()) when: "blob endpoint" def response = fileClient.getPropertiesWithResponse(null, null, null) diff --git a/sdk/storage/azure-storage-file-datalake/src/test/java/com/azure/storage/file/datalake/FileSystemAPITest.groovy b/sdk/storage/azure-storage-file-datalake/src/test/java/com/azure/storage/file/datalake/FileSystemAPITest.groovy index 923dd215e4967..ce17751c2168b 100644 --- a/sdk/storage/azure-storage-file-datalake/src/test/java/com/azure/storage/file/datalake/FileSystemAPITest.groovy +++ b/sdk/storage/azure-storage-file-datalake/src/test/java/com/azure/storage/file/datalake/FileSystemAPITest.groovy @@ -13,17 +13,14 @@ import com.azure.storage.file.datalake.models.LeaseStateType import com.azure.storage.file.datalake.models.LeaseStatusType import com.azure.storage.file.datalake.models.ListPathsOptions import com.azure.storage.file.datalake.models.PathAccessControlEntry -import com.azure.storage.file.datalake.models.PathDeletedItem import com.azure.storage.file.datalake.models.PathHttpHeaders import com.azure.storage.file.datalake.models.PathItem import com.azure.storage.file.datalake.models.PublicAccessType -import spock.lang.ResourceLock import spock.lang.Unroll import java.time.OffsetDateTime import java.time.ZoneId import java.time.temporal.ChronoUnit -import java.util.stream.Collectors class FileSystemAPITest extends APISpec { @@ -1246,7 +1243,7 @@ class FileSystemAPITest extends APISpec { // This tests the policy is in the right place because if it were added per retry, it would be after the credentials and auth would fail because we changed a signed header. def "Per call policy"() { setup: - def fsc = getFileSystemClientBuilder(fsc.getFileSystemUrl()).addPolicy(getPerCallVersionPolicy()).credential(env.dataLakeAccount.credential).buildClient() + def fsc = getFileSystemClientBuilder(fsc.getFileSystemUrl()).addPolicy(getPerCallVersionPolicy()).credential(environment.dataLakeAccount.credential).buildClient() when: "blob endpoint" def response = fsc.getPropertiesWithResponse(null, null, null) diff --git a/sdk/storage/azure-storage-file-datalake/src/test/java/com/azure/storage/file/datalake/LargeFileTest.groovy b/sdk/storage/azure-storage-file-datalake/src/test/java/com/azure/storage/file/datalake/LargeFileTest.groovy index 6ddc16ae2fb89..e39d527664db4 100644 --- a/sdk/storage/azure-storage-file-datalake/src/test/java/com/azure/storage/file/datalake/LargeFileTest.groovy +++ b/sdk/storage/azure-storage-file-datalake/src/test/java/com/azure/storage/file/datalake/LargeFileTest.groovy @@ -42,12 +42,12 @@ class LargeFileTest extends APISpec{ fileName = generatePathName() def fileClient = fsc.getFileClient(fileName) fc = getFileClient( - env.dataLakeAccount.credential, + environment.dataLakeAccount.credential, fileClient.getFileUrl(), new CountingPolicy() ) fcAsync = getFileAsyncClient( - env.dataLakeAccount.credential, + environment.dataLakeAccount.credential, fileClient.getFileUrl(), new CountingPolicy() ) diff --git a/sdk/storage/azure-storage-file-datalake/src/test/java/com/azure/storage/file/datalake/SASTest.groovy b/sdk/storage/azure-storage-file-datalake/src/test/java/com/azure/storage/file/datalake/SASTest.groovy index 8c7ba4d04dc04..7c637f029d521 100644 --- a/sdk/storage/azure-storage-file-datalake/src/test/java/com/azure/storage/file/datalake/SASTest.groovy +++ b/sdk/storage/azure-storage-file-datalake/src/test/java/com/azure/storage/file/datalake/SASTest.groovy @@ -38,7 +38,7 @@ class SASTest extends APISpec { def setup() { pathName = generatePathName() - sasClient = getFileClient(env.dataLakeAccount.credential, fsc.getFileSystemUrl(), pathName) + sasClient = getFileClient(environment.dataLakeAccount.credential, fsc.getFileSystemUrl(), pathName) sasClient.create() sasClient.append(data.defaultInputStream, 0, data.defaultDataSize) sasClient.flush(data.defaultDataSize) @@ -110,7 +110,7 @@ class SASTest extends APISpec { def "directory sas permission"() { setup: def pathName = generatePathName() - DataLakeDirectoryClient sasClient = getDirectoryClient(env.dataLakeAccount.credential, fsc.getFileSystemUrl(), pathName) + DataLakeDirectoryClient sasClient = getDirectoryClient(environment.dataLakeAccount.credential, fsc.getFileSystemUrl(), pathName) sasClient.create() def permissions = new PathSasPermission() .setReadPermission(true) @@ -148,7 +148,7 @@ class SASTest extends APISpec { def "directory sas permission fail"() { setup: def pathName = generatePathName() - DataLakeDirectoryClient sasClient = getDirectoryClient(env.dataLakeAccount.credential, fsc.getFileSystemUrl(), pathName) + DataLakeDirectoryClient sasClient = getDirectoryClient(environment.dataLakeAccount.credential, fsc.getFileSystemUrl(), pathName) sasClient.create() def permissions = new PathSasPermission() /* No read permission. */ .setWritePermission(true) @@ -251,7 +251,7 @@ class SASTest extends APISpec { def "directory user delegation"() { setup: def pathName = generatePathName() - DataLakeDirectoryClient sasClient = getDirectoryClient(env.dataLakeAccount.credential, fsc.getFileSystemUrl(), pathName) + DataLakeDirectoryClient sasClient = getDirectoryClient(environment.dataLakeAccount.credential, fsc.getFileSystemUrl(), pathName) sasClient.create() def permissions = new PathSasPermission() .setReadPermission(true) @@ -358,7 +358,7 @@ class SASTest extends APISpec { when: /* Grant userOID on root folder. */ - def rootClient = getDirectoryClient(env.dataLakeAccount.credential, fsc.getFileSystemUrl(), "") + def rootClient = getDirectoryClient(environment.dataLakeAccount.credential, fsc.getFileSystemUrl(), "") ArrayList acl = new ArrayList<>(); PathAccessControlEntry ace = new PathAccessControlEntry() .setAccessControlType(AccessControlType.USER) @@ -382,7 +382,7 @@ class SASTest extends APISpec { sasWithPermissions.contains("saoid=" + saoid) when: - client = getFileClient(env.dataLakeAccount.credential, fsc.getFileSystemUrl(), pathName) + client = getFileClient(environment.dataLakeAccount.credential, fsc.getFileSystemUrl(), pathName) def accessControl = client.getAccessControl() then: @@ -431,7 +431,7 @@ class SASTest extends APISpec { when: "User is now authorized." /* Grant userOID on root folder. */ - def rootClient = getDirectoryClient(env.dataLakeAccount.credential, fsc.getFileSystemUrl(), "") + def rootClient = getDirectoryClient(environment.dataLakeAccount.credential, fsc.getFileSystemUrl(), "") ArrayList acl = new ArrayList<>(); PathAccessControlEntry ace = new PathAccessControlEntry() .setAccessControlType(AccessControlType.USER) @@ -450,7 +450,7 @@ class SASTest extends APISpec { client.append(data.defaultInputStream, 0, data.defaultDataSize) client.flush(data.defaultDataSize) - client = getFileClient(env.dataLakeAccount.credential, fsc.getFileSystemUrl(), pathName) + client = getFileClient(environment.dataLakeAccount.credential, fsc.getFileSystemUrl(), pathName) then: notThrown(DataLakeStorageException) @@ -657,7 +657,7 @@ class SASTest extends APISpec { def fsc = getFileSystemClientBuilder(primaryDataLakeServiceClient.getAccountUrl() + "/" + fileSystemName + "?" + sas).buildClient() fsc.listPaths() - def fc = getFileClient(env.dataLakeAccount.credential, primaryDataLakeServiceClient.getAccountUrl() + "/" + fileSystemName + "/" + pathName + "?" + sas) + def fc = getFileClient(environment.dataLakeAccount.credential, primaryDataLakeServiceClient.getAccountUrl() + "/" + fileSystemName + "/" + pathName + "?" + sas) fc.create() @@ -685,7 +685,7 @@ class SASTest extends APISpec { } else { v = new DataLakeServiceSasSignatureValues(e, p) } - def expected = String.format(expectedStringToSign, env.dataLakeAccount.name) + def expected = String.format(expectedStringToSign, environment.dataLakeAccount.name) v.setPermissions(p) @@ -707,7 +707,7 @@ class SASTest extends APISpec { def util = new DataLakeSasImplUtil(v, "fileSystemName", "pathName", false) util.ensureState() - def sasToken = util.stringToSign(util.getCanonicalName(env.dataLakeAccount.name)) + def sasToken = util.stringToSign(util.getCanonicalName(environment.dataLakeAccount.name)) then: sasToken == expected @@ -741,7 +741,7 @@ class SASTest extends APISpec { p.setReadPermission(true) def v = new DataLakeServiceSasSignatureValues(e, p) - def expected = String.format(expectedStringToSign, env.dataLakeAccount.name) + def expected = String.format(expectedStringToSign, environment.dataLakeAccount.name) p.setReadPermission(true) v.setPermissions(p) @@ -775,7 +775,7 @@ class SASTest extends APISpec { def util = new DataLakeSasImplUtil(v, "fileSystemName", "pathName", false) util.ensureState() - def sasToken = util.stringToSign(key, util.getCanonicalName(env.dataLakeAccount.name)) + def sasToken = util.stringToSign(key, util.getCanonicalName(environment.dataLakeAccount.name)) then: sasToken == expected diff --git a/sdk/storage/azure-storage-file-datalake/src/test/java/com/azure/storage/file/datalake/ServiceAPITest.groovy b/sdk/storage/azure-storage-file-datalake/src/test/java/com/azure/storage/file/datalake/ServiceAPITest.groovy index a0e9978ce9594..d937436bf2fc9 100644 --- a/sdk/storage/azure-storage-file-datalake/src/test/java/com/azure/storage/file/datalake/ServiceAPITest.groovy +++ b/sdk/storage/azure-storage-file-datalake/src/test/java/com/azure/storage/file/datalake/ServiceAPITest.groovy @@ -191,7 +191,7 @@ class ServiceAPITest extends APISpec { @ResourceLock("ServiceProperties") def "Set props error"() { when: - getServiceClient(env.dataLakeAccount.credential, "https://error.blob.core.windows.net") + getServiceClient(environment.dataLakeAccount.credential, "https://error.blob.core.windows.net") .setProperties(new DataLakeServiceProperties()) then: @@ -207,7 +207,7 @@ class ServiceAPITest extends APISpec { @ResourceLock("ServiceProperties") def "Get props error"() { when: - getServiceClient(env.dataLakeAccount.credential, "https://error.blob.core.windows.net") + getServiceClient(environment.dataLakeAccount.credential, "https://error.blob.core.windows.net") .getProperties() then: @@ -402,10 +402,10 @@ class ServiceAPITest extends APISpec { thrown(IllegalArgumentException) } - @IgnoreIf( { getEnv().serviceVersion != null } ) + @IgnoreIf( { getEnvironment().serviceVersion != null } ) // This tests the policy is in the right place because if it were added per retry, it would be after the credentials and auth would fail because we changed a signed header. def "Per call policy"() { - def serviceClient = getServiceClient(env.dataLakeAccount.credential, primaryDataLakeServiceClient.getAccountUrl(), getPerCallVersionPolicy()) + def serviceClient = getServiceClient(environment.dataLakeAccount.credential, primaryDataLakeServiceClient.getAccountUrl(), getPerCallVersionPolicy()) when: "blob endpoint" def response = serviceClient.createFileSystemWithResponse(generateFileSystemName(), null, null, null) @@ -505,7 +505,7 @@ class ServiceAPITest extends APISpec { given: def cc1 = primaryDataLakeServiceAsyncClient.getFileSystemAsyncClient(generateFileSystemName()) def blobName = generatePathName() - def delay = env.testMode == TestMode.PLAYBACK ? 0L : 30000L + def delay = environment.testMode == TestMode.PLAYBACK ? 0L : 30000L def blobContainerItemMono = cc1.create() .then(cc1.getFileAsyncClient(blobName).upload(data.defaultFlux, new ParallelTransferOptions())) @@ -536,7 +536,7 @@ class ServiceAPITest extends APISpec { given: def cc1 = primaryDataLakeServiceAsyncClient.getFileSystemAsyncClient(generateFileSystemName()) def blobName = generatePathName() - def delay = env.testMode == TestMode.PLAYBACK ? 0L : 30000L + def delay = environment.testMode == TestMode.PLAYBACK ? 0L : 30000L def blobContainerItemMono = cc1.create() .then(cc1.getFileAsyncClient(blobName).upload(data.defaultFlux, new ParallelTransferOptions())) diff --git a/sdk/storage/azure-storage-file-datalake/src/test/java/com/azure/storage/file/datalake/SoftDeleteTest.groovy b/sdk/storage/azure-storage-file-datalake/src/test/java/com/azure/storage/file/datalake/SoftDeleteTest.groovy index f027441f8c88a..443e030304cd1 100644 --- a/sdk/storage/azure-storage-file-datalake/src/test/java/com/azure/storage/file/datalake/SoftDeleteTest.groovy +++ b/sdk/storage/azure-storage-file-datalake/src/test/java/com/azure/storage/file/datalake/SoftDeleteTest.groovy @@ -20,11 +20,11 @@ class SoftDeleteTest extends APISpec{ DataLakeFileSystemClient fileSystemClient def setupSpec() { - if (env.testMode != TestMode.PLAYBACK) { + if (environment.testMode != TestMode.PLAYBACK) { // This is to enable soft delete until better way is found. No need for recording. def setupClient = new DataLakeServiceClientBuilder() - .endpoint(env.dataLakeSoftDeleteAccount.dataLakeEndpoint) - .credential(env.dataLakeSoftDeleteAccount.credential) + .endpoint(environment.dataLakeSoftDeleteAccount.dataLakeEndpoint) + .credential(environment.dataLakeSoftDeleteAccount.credential) .buildClient() setupClient.setProperties(new DataLakeServiceProperties() .setDeleteRetentionPolicy(new DataLakeRetentionPolicy().setEnabled(true).setDays(2))) @@ -34,7 +34,7 @@ class SoftDeleteTest extends APISpec{ } def setup() { - softDeleteDataLakeServiceClient = getServiceClient(env.dataLakeSoftDeleteAccount) + softDeleteDataLakeServiceClient = getServiceClient(environment.dataLakeSoftDeleteAccount) fileSystemClient = softDeleteDataLakeServiceClient.getFileSystemClient(generateFileSystemName()) fileSystemClient.create() } diff --git a/sdk/storage/azure-storage-file-datalake/src/test/java/com/azure/storage/file/datalake/specialized/LeaseAsyncErrorMappingTest.groovy b/sdk/storage/azure-storage-file-datalake/src/test/java/com/azure/storage/file/datalake/specialized/LeaseAsyncErrorMappingTest.groovy index a5cb70a4ca8eb..d2a8a29c77947 100644 --- a/sdk/storage/azure-storage-file-datalake/src/test/java/com/azure/storage/file/datalake/specialized/LeaseAsyncErrorMappingTest.groovy +++ b/sdk/storage/azure-storage-file-datalake/src/test/java/com/azure/storage/file/datalake/specialized/LeaseAsyncErrorMappingTest.groovy @@ -7,7 +7,7 @@ import reactor.test.StepVerifier class LeaseAsyncErrorMappingTest extends APISpec { private DataLakeFileAsyncClient createPathAsyncClient() { - def fac = getServiceAsyncClient(env.dataLakeAccount) + def fac = getServiceAsyncClient(environment.dataLakeAccount) .createFileSystem(generateFileSystemName()).block() .getFileAsyncClient(generatePathName()) return fac diff --git a/sdk/storage/azure-storage-file-share/pom.xml b/sdk/storage/azure-storage-file-share/pom.xml index bcc198ed9dc31..45dee2c8e4a7f 100644 --- a/sdk/storage/azure-storage-file-share/pom.xml +++ b/sdk/storage/azure-storage-file-share/pom.xml @@ -101,12 +101,6 @@ 3.4.9 test - - org.spockframework - spock-core - 2.0-M4-groovy-2.5 - test - com.azure azure-identity @@ -190,6 +184,14 @@ [1.8,9) + + + org.spockframework + spock-core + 2.0-M4-groovy-2.5 + test + + @@ -232,6 +234,14 @@ [9,) + + + org.spockframework + spock-core + 2.0-groovy-3.0 + test + + diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/APISpec.groovy b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/APISpec.groovy index 88e786b5bc9b2..c685ed3ffddcc 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/APISpec.groovy +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/APISpec.groovy @@ -3,8 +3,7 @@ package com.azure.storage.file.share -import com.azure.core.credential.AccessToken -import com.azure.core.credential.TokenRequestContext + import com.azure.core.http.HttpHeaders import com.azure.core.http.HttpPipelineCallContext import com.azure.core.http.HttpPipelineNextPolicy @@ -13,11 +12,6 @@ import com.azure.core.http.HttpResponse import com.azure.core.http.policy.HttpPipelinePolicy import com.azure.core.test.TestMode import com.azure.core.util.Context -import com.azure.identity.EnvironmentCredential -import com.azure.identity.EnvironmentCredentialBuilder -import com.azure.identity.implementation.IdentityClientOptions -import com.azure.storage.blob.BlobServiceClient -import com.azure.storage.blob.BlobServiceClientBuilder import com.azure.storage.common.StorageSharedKeyCredential import com.azure.storage.common.test.shared.StorageSpec import com.azure.storage.common.test.shared.TestAccount @@ -63,20 +57,20 @@ class APISpec extends StorageSpec { * Setup the File service clients commonly used for the API tests. */ def setup() { - primaryFileServiceClient = getServiceClient(env.primaryAccount) - primaryFileServiceAsyncClient = getServiceAsyncClient(env.primaryAccount) + primaryFileServiceClient = getServiceClient(environment.primaryAccount) + primaryFileServiceAsyncClient = getServiceAsyncClient(environment.primaryAccount) - premiumFileServiceClient = getServiceClient(env.premiumFileAccount) - premiumFileServiceAsyncClient = getServiceAsyncClient(env.premiumFileAccount) + premiumFileServiceClient = getServiceClient(environment.premiumFileAccount) + premiumFileServiceAsyncClient = getServiceAsyncClient(environment.premiumFileAccount) } /** * Clean up the test shares, directories and files for the account. */ def cleanup() { - if (env.testMode != TestMode.PLAYBACK) { + if (environment.testMode != TestMode.PLAYBACK) { def cleanupFileServiceClient = new ShareServiceClientBuilder() - .connectionString(env.primaryAccount.connectionString) + .connectionString(environment.primaryAccount.connectionString) .buildClient() for (def share : cleanupFileServiceClient.listShares(new ListSharesOptions().setPrefix(namer.getResourcePrefix()), null, Context.NONE)) { def shareClient = cleanupFileServiceClient.getShareClient(share.getName()) @@ -123,7 +117,7 @@ class APISpec extends StorageSpec { def fileServiceBuilderHelper() { ShareServiceClientBuilder shareServiceClientBuilder = instrument(new ShareServiceClientBuilder()) return shareServiceClientBuilder - .connectionString(env.primaryAccount.connectionString) + .connectionString(environment.primaryAccount.connectionString) } ShareServiceClientBuilder getServiceClientBuilder(StorageSharedKeyCredential credential, String endpoint, @@ -159,14 +153,14 @@ class APISpec extends StorageSpec { def shareBuilderHelper(final String shareName, final String snapshot) { ShareClientBuilder builder = instrument(new ShareClientBuilder()) - return builder.connectionString(env.primaryAccount.connectionString) + return builder.connectionString(environment.primaryAccount.connectionString) .shareName(shareName) .snapshot(snapshot) } def directoryBuilderHelper(final String shareName, final String directoryPath) { ShareFileClientBuilder builder = instrument(new ShareFileClientBuilder()) - return builder.connectionString(env.primaryAccount.connectionString) + return builder.connectionString(environment.primaryAccount.connectionString) .shareName(shareName) .resourcePath(directoryPath) } @@ -191,7 +185,7 @@ class APISpec extends StorageSpec { def fileBuilderHelper(final String shareName, final String filePath) { ShareFileClientBuilder builder = instrument(new ShareFileClientBuilder()) return builder - .connectionString(env.primaryAccount.connectionString) + .connectionString(environment.primaryAccount.connectionString) .shareName(shareName) .resourcePath(filePath) } @@ -288,7 +282,7 @@ class APISpec extends StorageSpec { } void sleepIfLive(long milliseconds) { - if (env.testMode == TestMode.PLAYBACK) { + if (environment.testMode == TestMode.PLAYBACK) { return } @@ -297,13 +291,13 @@ class APISpec extends StorageSpec { // Only sleep if test is running in live or record mode def sleepIfRecord(long milliseconds) { - if (env.testMode != TestMode.PLAYBACK) { + if (environment.testMode != TestMode.PLAYBACK) { sleep(milliseconds) } } def getPollingDuration(long liveTestDurationInMillis) { - return (env.testMode == TestMode.PLAYBACK) ? Duration.ofMillis(10) : Duration.ofMillis(liveTestDurationInMillis) + return (environment.testMode == TestMode.PLAYBACK) ? Duration.ofMillis(10) : Duration.ofMillis(liveTestDurationInMillis) } /** diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAPITests.groovy b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAPITests.groovy index 390f1ae1c404a..d5926cbf85951 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAPITests.groovy +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAPITests.groovy @@ -42,7 +42,7 @@ class DirectoryAPITests extends APISpec { def "Get directory URL"() { given: - def accountName = StorageSharedKeyCredential.fromConnectionString(env.primaryAccount.connectionString).getAccountName() + def accountName = StorageSharedKeyCredential.fromConnectionString(environment.primaryAccount.connectionString).getAccountName() def expectURL = String.format("https://%s.file.core.windows.net/%s/%s", accountName, shareName, directoryPath) when: @@ -54,7 +54,7 @@ class DirectoryAPITests extends APISpec { def "Get share snapshot URL"() { given: - def accountName = StorageSharedKeyCredential.fromConnectionString(env.primaryAccount.connectionString).getAccountName() + def accountName = StorageSharedKeyCredential.fromConnectionString(environment.primaryAccount.connectionString).getAccountName() def expectURL = String.format("https://%s.file.core.windows.net/%s/%s", accountName, shareName, directoryPath) when: @@ -69,7 +69,7 @@ class DirectoryAPITests extends APISpec { when: def snapshotEndpoint = String.format("https://%s.file.core.windows.net/%s/%s?sharesnapshot=%s", accountName, shareName, directoryPath, shareSnapshotInfo.getSnapshot()) - ShareDirectoryClient client = getDirectoryClient(StorageSharedKeyCredential.fromConnectionString(env.primaryAccount.connectionString), snapshotEndpoint) + ShareDirectoryClient client = getDirectoryClient(StorageSharedKeyCredential.fromConnectionString(environment.primaryAccount.connectionString), snapshotEndpoint) then: client.getDirectoryUrl() == snapshotEndpoint diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAsyncAPITests.groovy b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAsyncAPITests.groovy index a94918a5c4e31..5efb87c767d35 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAsyncAPITests.groovy +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAsyncAPITests.groovy @@ -39,7 +39,7 @@ class DirectoryAsyncAPITests extends APISpec { def "Get directory URL"() { given: - def accountName = StorageSharedKeyCredential.fromConnectionString(env.primaryAccount.connectionString).getAccountName() + def accountName = StorageSharedKeyCredential.fromConnectionString(environment.primaryAccount.connectionString).getAccountName() def expectURL = String.format("https://%s.file.core.windows.net/%s/%s", accountName, shareName, directoryPath) when: def directoryURL = primaryDirectoryAsyncClient.getDirectoryUrl() diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAPITests.groovy b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAPITests.groovy index 4d757d6ed82fa..283e2b3832c32 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAPITests.groovy +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAPITests.groovy @@ -33,7 +33,6 @@ import com.azure.storage.file.share.sas.ShareServiceSasSignatureValues import spock.lang.Ignore import spock.lang.Unroll -import java.nio.ByteBuffer import java.nio.charset.StandardCharsets import java.nio.file.FileAlreadyExistsException import java.nio.file.NoSuchFileException @@ -75,7 +74,7 @@ class FileAPITests extends APISpec { def "Get file URL"() { given: - def accountName = StorageSharedKeyCredential.fromConnectionString(env.primaryAccount.connectionString).getAccountName() + def accountName = StorageSharedKeyCredential.fromConnectionString(environment.primaryAccount.connectionString).getAccountName() def expectURL = String.format("https://%s.file.core.windows.net/%s/%s", accountName, shareName, filePath) when: @@ -87,7 +86,7 @@ class FileAPITests extends APISpec { def "Get share snapshot URL"() { given: - def accountName = StorageSharedKeyCredential.fromConnectionString(env.primaryAccount.connectionString).getAccountName() + def accountName = StorageSharedKeyCredential.fromConnectionString(environment.primaryAccount.connectionString).getAccountName() def expectURL = String.format("https://%s.file.core.windows.net/%s/%s", accountName, shareName, filePath) when: @@ -102,7 +101,7 @@ class FileAPITests extends APISpec { when: def snapshotEndpoint = String.format("https://%s.file.core.windows.net/%s/%s?sharesnapshot=%s", accountName, shareName, filePath, shareSnapshotInfo.getSnapshot()) - ShareFileClient client = getFileClient(StorageSharedKeyCredential.fromConnectionString(env.primaryAccount.connectionString), snapshotEndpoint) + ShareFileClient client = getFileClient(StorageSharedKeyCredential.fromConnectionString(environment.primaryAccount.connectionString), snapshotEndpoint) then: client.getFileUrl() == snapshotEndpoint @@ -339,7 +338,7 @@ class FileAPITests extends APISpec { given: primaryFileClient.create(data.defaultDataSize) def clientWithFailure = getFileClient( - env.primaryAccount.credential, + environment.primaryAccount.credential, primaryFileClient.getFileUrl(), new TransientFailureInjectingHttpPipelinePolicy()) @@ -462,7 +461,7 @@ class FileAPITests extends APISpec { setup: primaryFileClient.create(data.defaultDataSizeLong) primaryFileClient.upload(data.defaultInputStream, data.defaultDataSizeLong) - def fc2 = getFileClient(env.primaryAccount.credential, primaryFileClient.getFileUrl(), new MockRetryRangeResponsePolicy("bytes=2-6")) + def fc2 = getFileClient(environment.primaryAccount.credential, primaryFileClient.getFileUrl(), new MockRetryRangeResponsePolicy("bytes=2-6")) when: def range = new ShareFileRange(2, 6L) @@ -482,7 +481,7 @@ class FileAPITests extends APISpec { setup: primaryFileClient.create(data.defaultDataSizeLong) primaryFileClient.upload(data.defaultInputStream, data.defaultDataSizeLong) - def failureClient = getFileClient(env.primaryAccount.credential, primaryFileClient.getFileUrl(), new MockFailureResponsePolicy(5)) + def failureClient = getFileClient(environment.primaryAccount.credential, primaryFileClient.getFileUrl(), new MockFailureResponsePolicy(5)) when: def outStream = new ByteArrayOutputStream() @@ -601,7 +600,7 @@ class FileAPITests extends APISpec { def "Upload data retry on transient failure"() { setup: def clientWithFailure = getFileClient( - env.primaryAccount.credential, + environment.primaryAccount.credential, primaryFileClient.getFileUrl(), new TransientFailureInjectingHttpPipelinePolicy() ) @@ -774,7 +773,7 @@ class FileAPITests extends APISpec { def "Download file buffer copy"() { setup: def shareServiceClient = new ShareServiceClientBuilder() - .connectionString(env.primaryAccount.connectionString) + .connectionString(environment.primaryAccount.connectionString) .buildClient() def fileClient = shareServiceClient.getShareClient(shareName) @@ -865,7 +864,7 @@ class FileAPITests extends APISpec { def destinationOffset = 0 primaryFileClient.upload(getInputStream(data.getBytes()), data.length()) - def credential = StorageSharedKeyCredential.fromConnectionString(env.primaryAccount.connectionString) + def credential = StorageSharedKeyCredential.fromConnectionString(environment.primaryAccount.connectionString) def sasToken = new ShareServiceSasSignatureValues() .setExpiryTime(namer.getUtcNow().plusDays(1)) .setPermissions(new ShareFileSasPermission().setReadPermission(true)) diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAsyncAPITests.groovy b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAsyncAPITests.groovy index 133497a46ff33..32441aa3438dc 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAsyncAPITests.groovy +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAsyncAPITests.groovy @@ -23,7 +23,6 @@ import com.azure.storage.file.share.sas.ShareServiceSasSignatureValues import reactor.core.publisher.Flux import reactor.test.StepVerifier import spock.lang.Ignore -import spock.lang.Requires import spock.lang.Unroll import java.nio.ByteBuffer @@ -61,7 +60,7 @@ class FileAsyncAPITests extends APISpec { def "Get file URL"() { given: - def accountName = StorageSharedKeyCredential.fromConnectionString(env.primaryAccount.connectionString).getAccountName() + def accountName = StorageSharedKeyCredential.fromConnectionString(environment.primaryAccount.connectionString).getAccountName() def expectURL = String.format("https://%s.file.core.windows.net/%s/%s", accountName, shareName, filePath) when: @@ -178,7 +177,7 @@ class FileAsyncAPITests extends APISpec { def "Download file buffer copy"() { setup: def shareServiceAsyncClient = new ShareServiceClientBuilder() - .connectionString(env.primaryAccount.connectionString) + .connectionString(environment.primaryAccount.connectionString) .buildAsyncClient() def fileClient = shareServiceAsyncClient.getShareAsyncClient(shareName) @@ -621,7 +620,7 @@ class FileAsyncAPITests extends APISpec { def destinationOffset = 0 primaryFileAsyncClient.upload(Flux.just(ByteBuffer.wrap(data.getBytes())), data.length()).block() - def credential = StorageSharedKeyCredential.fromConnectionString(env.primaryAccount.connectionString) + def credential = StorageSharedKeyCredential.fromConnectionString(environment.primaryAccount.connectionString) def sasToken = new ShareServiceSasSignatureValues() .setExpiryTime(namer.getUtcNow().plusDays(1)) .setPermissions(new ShareFileSasPermission().setReadPermission(true)) @@ -657,7 +656,7 @@ class FileAsyncAPITests extends APISpec { def destinationOffset = 0 primaryFileAsyncClient.upload(Flux.just(ByteBuffer.wrap(data.getBytes())), data.length()).block() - def credential = StorageSharedKeyCredential.fromConnectionString(env.primaryAccount.connectionString) + def credential = StorageSharedKeyCredential.fromConnectionString(environment.primaryAccount.connectionString) def sasToken = new ShareServiceSasSignatureValues() .setExpiryTime(namer.getUtcNow().plusDays(1)) .setPermissions(new ShareFileSasPermission().setReadPermission(true)) @@ -689,7 +688,7 @@ class FileAsyncAPITests extends APISpec { def destinationOffset = 0 primaryFileAsyncClient.upload(Flux.just(ByteBuffer.wrap(data.getBytes())), data.length()).block() - def credential = StorageSharedKeyCredential.fromConnectionString(env.primaryAccount.connectionString) + def credential = StorageSharedKeyCredential.fromConnectionString(environment.primaryAccount.connectionString) def sasToken = new ShareServiceSasSignatureValues() .setExpiryTime(namer.getUtcNow().plusDays(1)) .setPermissions(new ShareFileSasPermission().setReadPermission(true)) diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileSASTests.groovy b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileSASTests.groovy index c1bd897a7ada0..ebf06bfc598b1 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileSASTests.groovy +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileSASTests.groovy @@ -1,15 +1,12 @@ package com.azure.storage.file.share import com.azure.core.credential.AzureSasCredential -import com.azure.core.http.policy.HttpPipelinePolicy -import com.azure.core.test.TestMode import com.azure.storage.common.StorageSharedKeyCredential import com.azure.storage.common.implementation.Constants import com.azure.storage.common.sas.AccountSasPermission import com.azure.storage.common.sas.AccountSasResourceType import com.azure.storage.common.sas.AccountSasService import com.azure.storage.common.sas.AccountSasSignatureValues -import com.azure.storage.common.sas.SasIpRange import com.azure.storage.common.sas.SasProtocol import com.azure.storage.file.share.models.ShareAccessPolicy import com.azure.storage.file.share.models.ShareSignedIdentifier @@ -165,7 +162,7 @@ class FileSASTests extends APISpec { def contentType = "type" when: - def credential = StorageSharedKeyCredential.fromConnectionString(env.primaryAccount.connectionString) + def credential = StorageSharedKeyCredential.fromConnectionString(environment.primaryAccount.connectionString) def sas = new ShareServiceSasSignatureValues() .setPermissions(permissions) .setExpiryTime(expiryTime) @@ -221,7 +218,7 @@ class FileSASTests extends APISpec { def contentType = "type" when: - def credential = StorageSharedKeyCredential.fromConnectionString(env.primaryAccount.connectionString) + def credential = StorageSharedKeyCredential.fromConnectionString(environment.primaryAccount.connectionString) def sas = new ShareServiceSasSignatureValues() .setPermissions(permissions) .setExpiryTime(expiryTime) @@ -274,7 +271,7 @@ class FileSASTests extends APISpec { OffsetDateTime expiryTime = namer.getUtcNow().plusDays(1) when: - def credential = StorageSharedKeyCredential.fromConnectionString(env.primaryAccount.connectionString) + def credential = StorageSharedKeyCredential.fromConnectionString(environment.primaryAccount.connectionString) def sasWithId = new ShareServiceSasSignatureValues() .setIdentifier(identifier.getId()) .setShareName(primaryShareClient.getShareName()) @@ -325,7 +322,7 @@ class FileSASTests extends APISpec { def expiryTime = namer.getUtcNow().plusDays(1) when: - def credential = StorageSharedKeyCredential.fromConnectionString(env.primaryAccount.connectionString) + def credential = StorageSharedKeyCredential.fromConnectionString(environment.primaryAccount.connectionString) def sas = new AccountSasSignatureValues() .setServices(service.toString()) .setResourceTypes(resourceType.toString()) @@ -368,7 +365,7 @@ class FileSASTests extends APISpec { .setResourceTypes(resourceType.toString()) .setPermissions(permissions) .setExpiryTime(expiryTime) - .generateSasQueryParameters(env.primaryAccount.credential) + .generateSasQueryParameters(environment.primaryAccount.credential) .encode() def shareName = namer.getRandomName(60) def pathName = namer.getRandomName(60) diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileSasClientTests.groovy b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileSasClientTests.groovy index bfccacb64561f..548b2913eb3a0 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileSasClientTests.groovy +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileSasClientTests.groovy @@ -1,12 +1,11 @@ package com.azure.storage.file.share -import com.azure.storage.common.StorageSharedKeyCredential + import com.azure.storage.common.implementation.Constants import com.azure.storage.common.sas.AccountSasPermission import com.azure.storage.common.sas.AccountSasResourceType import com.azure.storage.common.sas.AccountSasService import com.azure.storage.common.sas.AccountSasSignatureValues -import com.azure.storage.common.sas.SasIpRange import com.azure.storage.common.sas.SasProtocol import com.azure.storage.file.share.models.ShareAccessPolicy import com.azure.storage.file.share.models.ShareSignedIdentifier @@ -189,12 +188,12 @@ class FileSasClientTests extends APISpec { */ def "Remember about string to sign deprecation"() { setup: - def client = shareBuilderHelper(shareName).credential(env.primaryAccount.credential).buildClient() + def client = shareBuilderHelper(shareName).credential(environment.primaryAccount.credential).buildClient() def values = new ShareServiceSasSignatureValues(namer.getUtcNow(), new ShareSasPermission()) values.setShareName(client.getShareName()) when: - def deprecatedStringToSign = values.generateSasQueryParameters(env.primaryAccount.credential).encode() + def deprecatedStringToSign = values.generateSasQueryParameters(environment.primaryAccount.credential).encode() def stringToSign = client.generateSas(values) then: diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileServiceAPITests.groovy b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileServiceAPITests.groovy index 70413353949ad..c3296477f1974 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileServiceAPITests.groovy +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileServiceAPITests.groovy @@ -23,7 +23,6 @@ import com.azure.storage.file.share.models.SmbMultichannel import com.azure.storage.file.share.options.ShareCreateOptions import com.azure.storage.file.share.options.ShareSetPropertiesOptions import spock.lang.IgnoreIf -import spock.lang.Requires import spock.lang.ResourceLock import spock.lang.Unroll @@ -55,7 +54,7 @@ class FileServiceAPITests extends APISpec { def "Get file service URL"() { given: - def accountName = StorageSharedKeyCredential.fromConnectionString(env.primaryAccount.connectionString).getAccountName() + def accountName = StorageSharedKeyCredential.fromConnectionString(environment.primaryAccount.connectionString).getAccountName() def expectURL = String.format("https://%s.file.core.windows.net", accountName) when: def fileServiceURL = primaryFileServiceClient.getFileServiceUrl() @@ -396,10 +395,10 @@ class FileServiceAPITests extends APISpec { thrown(ShareStorageException.class) } - @IgnoreIf( { getEnv().serviceVersion != null } ) + @IgnoreIf( { getEnvironment().serviceVersion != null } ) // This tests the policy is in the right place because if it were added per retry, it would be after the credentials and auth would fail because we changed a signed header. def "Per call policy"() { - def serviceClient = getServiceClient(env.primaryAccount.credential, primaryFileServiceClient.getFileServiceUrl(), getPerCallVersionPolicy()) + def serviceClient = getServiceClient(environment.primaryAccount.credential, primaryFileServiceClient.getFileServiceUrl(), getPerCallVersionPolicy()) when: def response = serviceClient.getPropertiesWithResponse(null, null) diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileServiceAsyncAPITests.groovy b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileServiceAsyncAPITests.groovy index 7363deeb9b8d5..fbd6e83086918 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileServiceAsyncAPITests.groovy +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileServiceAsyncAPITests.groovy @@ -38,7 +38,7 @@ class FileServiceAsyncAPITests extends APISpec { def "Get file service URL"() { given: - def accountName = StorageSharedKeyCredential.fromConnectionString(env.primaryAccount.connectionString).getAccountName() + def accountName = StorageSharedKeyCredential.fromConnectionString(environment.primaryAccount.connectionString).getAccountName() def expectURL = String.format("https://%s.file.core.windows.net", accountName) when: diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/OAuthCopySourceTests.groovy b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/OAuthCopySourceTests.groovy index 0b053b172b23a..9ddd8547d6fcc 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/OAuthCopySourceTests.groovy +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/OAuthCopySourceTests.groovy @@ -39,14 +39,14 @@ class OAuthCopySourceTests extends APISpec { def getBlobContainer() { instrument(new BlobServiceClientBuilder()) - .endpoint(env.primaryAccount.blobEndpoint) - .credential(env.primaryAccount.credential) + .endpoint(environment.primaryAccount.blobEndpoint) + .credential(environment.primaryAccount.credential) .buildClient() .createBlobContainer(getShareName()) } // RBAC replication lag - @Retry(count = 5, delay = 30, condition = { env.testMode == TestMode.LIVE }) + @Retry(count = 5, delay = 30, condition = { environment.testMode == TestMode.LIVE }) def "Copy from URL with oauth source"() { given: def oauthHeader = getAuthToken() diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/ShareAPITests.groovy b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/ShareAPITests.groovy index aebcc38d29920..5f3ae7305ba4b 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/ShareAPITests.groovy +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/ShareAPITests.groovy @@ -29,7 +29,6 @@ import com.azure.storage.file.share.options.ShareGetStatisticsOptions import com.azure.storage.file.share.options.ShareSetAccessPolicyOptions import com.azure.storage.file.share.options.ShareSetPropertiesOptions import com.azure.storage.file.share.options.ShareSetMetadataOptions -import spock.lang.Requires import spock.lang.Unroll import java.time.LocalDateTime @@ -55,7 +54,7 @@ class ShareAPITests extends APISpec { def "Get share URL"() { given: - def accountName = StorageSharedKeyCredential.fromConnectionString(env.primaryAccount.connectionString).getAccountName() + def accountName = StorageSharedKeyCredential.fromConnectionString(environment.primaryAccount.connectionString).getAccountName() def expectURL = String.format("https://%s.file.core.windows.net/%s", accountName, shareName) when: @@ -67,7 +66,7 @@ class ShareAPITests extends APISpec { def "Get share snapshot URL"() { given: - def accountName = StorageSharedKeyCredential.fromConnectionString(env.primaryAccount.connectionString).getAccountName() + def accountName = StorageSharedKeyCredential.fromConnectionString(environment.primaryAccount.connectionString).getAccountName() def expectURL = String.format("https://%s.file.core.windows.net/%s", accountName, shareName) primaryShareClient.create() when: @@ -82,7 +81,7 @@ class ShareAPITests extends APISpec { when: def snapshotEndpoint = String.format("https://%s.file.core.windows.net/%s?sharesnapshot=%s", accountName, shareName, shareSnapshotInfo.getSnapshot()) - ShareClient client = getShareClientBuilder(snapshotEndpoint).credential(StorageSharedKeyCredential.fromConnectionString(env.primaryAccount.connectionString)).buildClient() + ShareClient client = getShareClientBuilder(snapshotEndpoint).credential(StorageSharedKeyCredential.fromConnectionString(environment.primaryAccount.connectionString)).buildClient() then: client.getShareUrl() == snapshotEndpoint @@ -173,7 +172,7 @@ class ShareAPITests extends APISpec { when: def createSnapshotResponse = primaryShareClient.createSnapshotWithResponse(null, null, null) - def shareSnapshotClient = new ShareClientBuilder().shareName(shareSnapshotName).connectionString(env.primaryAccount.connectionString) + def shareSnapshotClient = new ShareClientBuilder().shareName(shareSnapshotName).connectionString(environment.primaryAccount.connectionString) .snapshot(createSnapshotResponse.getValue().getSnapshot()).httpClient(new NettyAsyncHttpClientBuilder().build()) .buildClient() then: @@ -197,7 +196,7 @@ class ShareAPITests extends APISpec { when: def createSnapshotResponse = primaryShareClient.createSnapshotWithResponse(testMetadata, null, null) - def shareSnapshotClient = new ShareClientBuilder().shareName(shareSnapshotName).connectionString(env.primaryAccount.connectionString) + def shareSnapshotClient = new ShareClientBuilder().shareName(shareSnapshotName).connectionString(environment.primaryAccount.connectionString) .snapshot(createSnapshotResponse.getValue().getSnapshot()).httpClient(new NettyAsyncHttpClientBuilder().build()) .buildClient() then: diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/ShareAsyncAPITests.groovy b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/ShareAsyncAPITests.groovy index 58ea5a973b21a..c6d0537fd2d03 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/ShareAsyncAPITests.groovy +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/ShareAsyncAPITests.groovy @@ -18,7 +18,6 @@ import com.azure.storage.file.share.models.ShareStorageException import com.azure.storage.file.share.options.ShareCreateOptions import com.azure.storage.file.share.options.ShareSetPropertiesOptions import reactor.test.StepVerifier -import spock.lang.Requires import spock.lang.Unroll import java.time.LocalDateTime @@ -42,7 +41,7 @@ class ShareAsyncAPITests extends APISpec { def "Get share URL"() { given: - def accountName = StorageSharedKeyCredential.fromConnectionString(env.primaryAccount.connectionString).getAccountName() + def accountName = StorageSharedKeyCredential.fromConnectionString(environment.primaryAccount.connectionString).getAccountName() def expectURL = String.format("https://%s.file.core.windows.net/%s", accountName, shareName) when: def shareURL = primaryShareAsyncClient.getShareUrl() @@ -113,7 +112,7 @@ class ShareAsyncAPITests extends APISpec { then: createSnapshotVerifier.assertNext { assert FileTestHelper.assertResponseStatusCode(it, 201) - def shareSnapshotClient = new ShareClientBuilder().shareName(shareSnapshotName).connectionString(env.primaryAccount.connectionString) + def shareSnapshotClient = new ShareClientBuilder().shareName(shareSnapshotName).connectionString(environment.primaryAccount.connectionString) .snapshot(it.getValue().getSnapshot()).httpClient(new NettyAsyncHttpClientBuilder().build()).buildClient() assert Objects.equals(it.getValue().getSnapshot(), shareSnapshotClient.getSnapshotId()) @@ -139,7 +138,7 @@ class ShareAsyncAPITests extends APISpec { then: createSnapshotVerifier.assertNext { assert FileTestHelper.assertResponseStatusCode(it, 201) - def shareSnapshotClient = new ShareClientBuilder().shareName(shareSnapshotName).connectionString(env.primaryAccount.connectionString) + def shareSnapshotClient = new ShareClientBuilder().shareName(shareSnapshotName).connectionString(environment.primaryAccount.connectionString) .snapshot(it.getValue().getSnapshot()).httpClient(new NettyAsyncHttpClientBuilder().build()).buildClient() assert Objects.equals(it.getValue().getSnapshot(), shareSnapshotClient.getSnapshotId()) diff --git a/sdk/storage/azure-storage-internal-avro/pom.xml b/sdk/storage/azure-storage-internal-avro/pom.xml index 72cf9a0f271b0..87e07dc82831c 100644 --- a/sdk/storage/azure-storage-internal-avro/pom.xml +++ b/sdk/storage/azure-storage-internal-avro/pom.xml @@ -65,12 +65,6 @@ 3.4.9 test - - org.spockframework - spock-core - 2.0-M4-groovy-2.5 - test - com.azure azure-storage-common @@ -179,6 +173,14 @@ [1.8,9) + + + org.spockframework + spock-core + 2.0-M4-groovy-2.5 + test + + @@ -221,6 +223,14 @@ [9,) + + + org.spockframework + spock-core + 2.0-groovy-3.0 + test + + diff --git a/sdk/storage/azure-storage-queue/pom.xml b/sdk/storage/azure-storage-queue/pom.xml index 5a81a4fcce827..57bf47ebcff2e 100644 --- a/sdk/storage/azure-storage-queue/pom.xml +++ b/sdk/storage/azure-storage-queue/pom.xml @@ -81,13 +81,6 @@ 1.7.1 test - - - org.spockframework - spock-core - 2.0-M4-groovy-2.5 - test - io.projectreactor reactor-test @@ -171,6 +164,14 @@ [1.8,9) + + + org.spockframework + spock-core + 2.0-M4-groovy-2.5 + test + + @@ -213,6 +214,14 @@ [9,) + + + org.spockframework + spock-core + 2.0-groovy-3.0 + test + + diff --git a/sdk/storage/azure-storage-queue/src/test/java/com/azure/storage/queue/APISpec.groovy b/sdk/storage/azure-storage-queue/src/test/java/com/azure/storage/queue/APISpec.groovy index c1f0eb03be950..fe68d5503a447 100644 --- a/sdk/storage/azure-storage-queue/src/test/java/com/azure/storage/queue/APISpec.groovy +++ b/sdk/storage/azure-storage-queue/src/test/java/com/azure/storage/queue/APISpec.groovy @@ -28,9 +28,9 @@ class APISpec extends StorageSpec { * Clean up the test queues and messages for the account. */ def cleanup() { - if (env.testMode != TestMode.PLAYBACK) { + if (environment.testMode != TestMode.PLAYBACK) { def cleanupQueueServiceClient = new QueueServiceClientBuilder() - .connectionString(env.primaryAccount.connectionString) + .connectionString(environment.primaryAccount.connectionString) .buildClient() cleanupQueueServiceClient.listQueues(new QueuesSegmentOptions().setPrefix(namer.getResourcePrefix()), null, Context.NONE).each { @@ -42,14 +42,14 @@ class APISpec extends StorageSpec { def queueServiceBuilderHelper() { QueueServiceClientBuilder builder = instrument(new QueueServiceClientBuilder()) return builder - .connectionString(env.primaryAccount.connectionString) + .connectionString(environment.primaryAccount.connectionString) } def queueBuilderHelper() { def queueName = namer.getRandomName(60) QueueClientBuilder builder = instrument(new QueueClientBuilder()) return builder - .connectionString(env.primaryAccount.connectionString) + .connectionString(environment.primaryAccount.connectionString) .queueName(queueName) } @@ -79,7 +79,7 @@ class APISpec extends StorageSpec { } def sleepIfLive(long milliseconds) { - if (env.testMode == TestMode.PLAYBACK) { + if (environment.testMode == TestMode.PLAYBACK) { return } @@ -87,7 +87,7 @@ class APISpec extends StorageSpec { } def getMessageUpdateDelay(long liveTestDurationInMillis) { - return (env.testMode == TestMode.PLAYBACK) ? Duration.ofMillis(10) : Duration.ofMillis(liveTestDurationInMillis) + return (environment.testMode == TestMode.PLAYBACK) ? Duration.ofMillis(10) : Duration.ofMillis(liveTestDurationInMillis) } def getPerCallVersionPolicy() { diff --git a/sdk/storage/azure-storage-queue/src/test/java/com/azure/storage/queue/QueueAPITests.groovy b/sdk/storage/azure-storage-queue/src/test/java/com/azure/storage/queue/QueueAPITests.groovy index a7f9ae46601f5..33aadf4af8daa 100644 --- a/sdk/storage/azure-storage-queue/src/test/java/com/azure/storage/queue/QueueAPITests.groovy +++ b/sdk/storage/azure-storage-queue/src/test/java/com/azure/storage/queue/QueueAPITests.groovy @@ -37,7 +37,7 @@ class QueueAPITests extends APISpec { def "Get queue URL"() { given: - def accountName = StorageSharedKeyCredential.fromConnectionString(env.primaryAccount.connectionString).getAccountName() + def accountName = StorageSharedKeyCredential.fromConnectionString(environment.primaryAccount.connectionString).getAccountName() def expectURL = String.format("https://%s.queue.core.windows.net/%s", accountName, queueName) when: @@ -50,7 +50,7 @@ class QueueAPITests extends APISpec { def "IP based endpoint"() { when: def queueClient = new QueueClientBuilder() - .connectionString(env.primaryAccount.connectionString) + .connectionString(environment.primaryAccount.connectionString) .endpoint("http://127.0.0.1:10001/devstoreaccount1/myqueue") .buildClient() diff --git a/sdk/storage/azure-storage-queue/src/test/java/com/azure/storage/queue/QueueAysncAPITests.groovy b/sdk/storage/azure-storage-queue/src/test/java/com/azure/storage/queue/QueueAysncAPITests.groovy index b5ab3c1e77093..ce8c1f5513235 100644 --- a/sdk/storage/azure-storage-queue/src/test/java/com/azure/storage/queue/QueueAysncAPITests.groovy +++ b/sdk/storage/azure-storage-queue/src/test/java/com/azure/storage/queue/QueueAysncAPITests.groovy @@ -36,7 +36,7 @@ class QueueAysncAPITests extends APISpec { def "Get queue URL"() { given: - def accountName = StorageSharedKeyCredential.fromConnectionString(env.primaryAccount.connectionString).getAccountName() + def accountName = StorageSharedKeyCredential.fromConnectionString(environment.primaryAccount.connectionString).getAccountName() def expectURL = String.format("https://%s.queue.core.windows.net/%s", accountName, queueName) when: @@ -49,7 +49,7 @@ class QueueAysncAPITests extends APISpec { def "IP based endpoint"() { when: def queueAsyncClient = new QueueClientBuilder() - .connectionString(env.primaryAccount.connectionString) + .connectionString(environment.primaryAccount.connectionString) .endpoint("http://127.0.0.1:10001/devstoreaccount1/myqueue") .buildAsyncClient() diff --git a/sdk/storage/azure-storage-queue/src/test/java/com/azure/storage/queue/QueueSASTests.groovy b/sdk/storage/azure-storage-queue/src/test/java/com/azure/storage/queue/QueueSASTests.groovy index 2539d27b91bdc..5bc8712f58f0d 100644 --- a/sdk/storage/azure-storage-queue/src/test/java/com/azure/storage/queue/QueueSASTests.groovy +++ b/sdk/storage/azure-storage-queue/src/test/java/com/azure/storage/queue/QueueSASTests.groovy @@ -4,8 +4,6 @@ package com.azure.storage.queue import com.azure.core.credential.AzureSasCredential -import com.azure.core.http.policy.HttpPipelinePolicy -import com.azure.core.test.TestMode import com.azure.storage.common.sas.AccountSasPermission import com.azure.storage.common.sas.AccountSasResourceType import com.azure.storage.common.sas.AccountSasService @@ -110,7 +108,7 @@ class QueueSASTests extends APISpec { def sasProtocol = SasProtocol.HTTPS_HTTP when: - def credential = StorageSharedKeyCredential.fromConnectionString(env.primaryAccount.connectionString) + def credential = StorageSharedKeyCredential.fromConnectionString(environment.primaryAccount.connectionString) def sasPermissions = new QueueServiceSasSignatureValues() .setPermissions(permissions) .setExpiryTime(expiryTime) @@ -155,7 +153,7 @@ class QueueSASTests extends APISpec { def sasProtocol = SasProtocol.HTTPS_HTTP when: - def credential = StorageSharedKeyCredential.fromConnectionString(env.primaryAccount.connectionString) + def credential = StorageSharedKeyCredential.fromConnectionString(environment.primaryAccount.connectionString) def sasPermissions = new QueueServiceSasSignatureValues() .setPermissions(permissions) .setExpiryTime(expiryTime) @@ -208,7 +206,7 @@ class QueueSASTests extends APISpec { sleepIfLive(30000) when: - def credential = StorageSharedKeyCredential.fromConnectionString(env.primaryAccount.connectionString) + def credential = StorageSharedKeyCredential.fromConnectionString(environment.primaryAccount.connectionString) def sasIdentifier = new QueueServiceSasSignatureValues() .setIdentifier(identifier.getId()) .setQueueName(queueClient.getQueueName()) @@ -244,7 +242,7 @@ class QueueSASTests extends APISpec { def expiryTime = namer.getUtcNow().plusDays(1) when: - def credential = StorageSharedKeyCredential.fromConnectionString(env.primaryAccount.connectionString) + def credential = StorageSharedKeyCredential.fromConnectionString(environment.primaryAccount.connectionString) def sas = new AccountSasSignatureValues() .setServices(service.toString()) .setResourceTypes(resourceType.toString()) @@ -282,7 +280,7 @@ class QueueSASTests extends APISpec { def expiryTime = namer.getUtcNow().plusDays(1) when: - def credential = StorageSharedKeyCredential.fromConnectionString(env.primaryAccount.connectionString) + def credential = StorageSharedKeyCredential.fromConnectionString(environment.primaryAccount.connectionString) def sas = new AccountSasSignatureValues() .setServices(service.toString()) .setResourceTypes(resourceType.toString()) @@ -323,7 +321,7 @@ class QueueSASTests extends APISpec { .setResourceTypes(resourceType.toString()) .setPermissions(permissions) .setExpiryTime(expiryTime) - .generateSasQueryParameters(env.primaryAccount.credential) + .generateSasQueryParameters(environment.primaryAccount.credential) .encode() def queueName = namer.getRandomName(60) diff --git a/sdk/storage/azure-storage-queue/src/test/java/com/azure/storage/queue/QueueSasClientTests.groovy b/sdk/storage/azure-storage-queue/src/test/java/com/azure/storage/queue/QueueSasClientTests.groovy index 17e2f41b59ea5..ee7e7bc5619df 100644 --- a/sdk/storage/azure-storage-queue/src/test/java/com/azure/storage/queue/QueueSasClientTests.groovy +++ b/sdk/storage/azure-storage-queue/src/test/java/com/azure/storage/queue/QueueSasClientTests.groovy @@ -201,12 +201,12 @@ class QueueSasClientTests extends APISpec { */ def "Remember about string to sign deprecation"() { setup: - def client = queueBuilderHelper().credential(env.primaryAccount.credential).buildClient() + def client = queueBuilderHelper().credential(environment.primaryAccount.credential).buildClient() def values = new QueueServiceSasSignatureValues(namer.getUtcNow(), new QueueSasPermission()) values.setQueueName(client.getQueueName()) when: - def deprecatedStringToSign = values.generateSasQueryParameters(env.primaryAccount.credential).encode() + def deprecatedStringToSign = values.generateSasQueryParameters(environment.primaryAccount.credential).encode() def stringToSign = client.generateSas(values) then: diff --git a/sdk/storage/microsoft-azure-storage-blob/pom.xml b/sdk/storage/microsoft-azure-storage-blob/pom.xml index 033f983a9281f..e6cd437a1294c 100644 --- a/sdk/storage/microsoft-azure-storage-blob/pom.xml +++ b/sdk/storage/microsoft-azure-storage-blob/pom.xml @@ -73,13 +73,6 @@ test - - org.spockframework - spock-core - 1.3-groovy-2.5 - test - - cglib cglib-nodep @@ -106,6 +99,14 @@ [1.8,9) + + + org.spockframework + spock-core + 1.3-groovy-2.5 + test + + @@ -148,6 +149,14 @@ [9,) + + + org.spockframework + spock-core + 2.0-groovy-3.0 + test + +