|
1 | 1 | package com.azure.storage.file.datalake |
2 | 2 |
|
| 3 | +import com.azure.storage.common.StorageSharedKeyCredential |
| 4 | +import spock.lang.Specification |
3 | 5 | import spock.lang.Unroll |
4 | 6 |
|
5 | | -class UrlTests extends APISpec { |
| 7 | +class UrlTests extends Specification { |
| 8 | + |
| 9 | + StorageSharedKeyCredential credential = new StorageSharedKeyCredential("accountname", "accountkey"); |
6 | 10 |
|
7 | 11 | @Unroll |
8 | 12 | def "test urls that should not change for datalake"() { |
9 | 13 | when: |
10 | 14 | DataLakeServiceClient client = new DataLakeServiceClientBuilder() |
11 | 15 | .endpoint(endpoint) |
12 | | - .credential(primaryCredential) |
| 16 | + .credential(credential) |
13 | 17 | .buildClient() |
14 | 18 | then: |
15 | 19 | client.getAccountUrl() == client.blobServiceClient.getAccountUrl() |
16 | 20 |
|
17 | 21 | where: |
18 | | - endpoint | _ |
19 | | - "https://www.customstorageurl.com" | _ |
20 | | - "https://account.core.windows.net" | _ |
21 | | - "https://0.0.0.0/account" | _ |
22 | | - "https://account.file.core.windows.net" | _ |
| 22 | + endpoint | _ |
| 23 | + "https://www.customstorageurl.com" | _ |
| 24 | + "https://account.core.windows.net" | _ |
| 25 | + "https://0.0.0.0/account" | _ |
| 26 | + "https://account.file.core.windows.net" | _ |
| 27 | + "https://www.customdfsstorageurl.com" | _ |
| 28 | + "https://dfsaccount.core.windows.net" | _ |
| 29 | + "https://0.0.0.0/dfsaccount" | _ |
| 30 | + "https://dfsaccount.file.core.windows.net" | _ |
23 | 31 | } |
24 | 32 |
|
25 | 33 | @Unroll |
26 | 34 | def "test correct service url set"() { |
27 | 35 | when: |
28 | | - def blobUrl = "https://account.blob.core.windows.net" |
29 | | - def dfsUrl = "https://account.dfs.core.windows.net" |
30 | | - |
31 | | - def testUrl = blobUrl |
32 | | - if (useDfsurl) { |
33 | | - testUrl = dfsUrl |
34 | | - } |
35 | | - |
36 | 36 | DataLakeServiceClient serviceClient = new DataLakeServiceClientBuilder() |
37 | | - .endpoint(testUrl) |
38 | | - .credential(primaryCredential) |
| 37 | + .endpoint(url) |
| 38 | + .credential(credential) |
39 | 39 | .buildClient() |
40 | 40 | DataLakeFileSystemClient fileSystemClient = new DataLakeFileSystemClientBuilder() |
41 | | - .endpoint(testUrl + "/container") |
42 | | - .credential(primaryCredential) |
| 41 | + .endpoint(url + "/container") |
| 42 | + .credential(credential) |
43 | 43 | .buildClient() |
44 | 44 | DataLakeFileClient pathClient = new DataLakePathClientBuilder() |
45 | | - .endpoint(testUrl + "/container/blob") |
46 | | - .credential(primaryCredential) |
| 45 | + .endpoint(url + "/container/blob") |
| 46 | + .credential(credential) |
47 | 47 | .buildFileClient() |
48 | 48 | then: |
49 | 49 | // In either case the dfs url should be set to the dfs client and blob url set to the blob client |
50 | | - serviceClient.getAccountUrl() == dfsUrl |
51 | | - serviceClient.blobServiceClient.getAccountUrl() == blobUrl |
52 | | - fileSystemClient.getFileSystemUrl() == dfsUrl + "/container" |
53 | | - fileSystemClient.blobContainerClient.getBlobContainerUrl() == blobUrl + "/container" |
54 | | - pathClient.getPathUrl() == dfsUrl + "/container/blob" |
55 | | - pathClient.blockBlobClient.getBlobUrl() == blobUrl + "/container/blob" |
| 50 | + serviceClient.getAccountUrl() == expectedDfsUrl |
| 51 | + serviceClient.blobServiceClient.getAccountUrl() == expectedBlobUrl |
| 52 | + fileSystemClient.getFileSystemUrl() == expectedDfsUrl + "/container" |
| 53 | + fileSystemClient.blobContainerClient.getBlobContainerUrl() == expectedBlobUrl + "/container" |
| 54 | + pathClient.getPathUrl() == expectedDfsUrl + "/container/blob" |
| 55 | + pathClient.blockBlobClient.getBlobUrl() == expectedBlobUrl + "/container/blob" |
56 | 56 |
|
57 | 57 | where: |
58 | | - useDfsurl | _ |
59 | | - true | _ |
60 | | - false | _ |
| 58 | + url || expectedBlobUrl | expectedDfsUrl |
| 59 | + "https://account.blob.core.windows.net" || "https://account.blob.core.windows.net" | "https://account.dfs.core.windows.net" |
| 60 | + "https://dfsaccount.blob.core.windows.net" || "https://dfsaccount.blob.core.windows.net" | "https://dfsaccount.dfs.core.windows.net" |
| 61 | + "https://account.dfs.core.windows.net" || "https://account.blob.core.windows.net" | "https://account.dfs.core.windows.net" |
| 62 | + "https://dfsaccount.dfs.core.windows.net" || "https://dfsaccount.blob.core.windows.net" | "https://dfsaccount.dfs.core.windows.net" |
61 | 63 | } |
62 | 64 | } |
0 commit comments