Skip to content
This repository was archived by the owner on Jul 19, 2024. It is now read-only.

Commit 1375dbe

Browse files
authored
Merge pull request #456 from rickle-msft/legacy-dev
Legacy dev
2 parents 24c28e0 + a921e0a commit 1375dbe

32 files changed

+1512
-179
lines changed

ChangeLog.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
2019.04.05 Version 8.2.0
2+
* Support for 2018-11-09 REST version. Please see our REST API documentation and blogs for information about the related added features.
3+
* Added appendBlockFromURL method. A block may be created with another blob as its source.
4+
* Added uploadPagesFromURL method. Pages may be written to with another blob as their source.
5+
* Fixed a bug in which putBlockFromURI accessConditions were indicated as being on the destination when in actuality they only apply to the source.
6+
* Added a method to get share stats in bytes.
7+
* Support for snapshot-level shared access signature tokens on blobs.
8+
19
2019.03.01 Version 8.1.0
210
* Added support for the deep sync copy blob api.
311
* Added the option to disable etag validation on BlobInputStream reads.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ To get the binaries of this library as distributed by Microsoft, ready for use w
3939
<dependency>
4040
<groupId>com.microsoft.azure</groupId>
4141
<artifactId>azure-storage</artifactId>
42-
<version>8.1.0</version>
42+
<version>8.2.0</version>
4343
</dependency>
4444
```
4545

microsoft-azure-storage-samples/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<dependency>
2727
<groupId>com.microsoft.azure</groupId>
2828
<artifactId>azure-storage</artifactId>
29-
<version>8.1.0</version>
29+
<version>8.2.0</version>
3030
</dependency>
3131
<dependency>
3232
<groupId>com.microsoft.azure</groupId>

microsoft-azure-storage-samples/src/com/microsoft/azure/storage/logging/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<dependency>
2727
<groupId>com.microsoft.azure</groupId>
2828
<artifactId>azure-storage</artifactId>
29-
<version>8.1.0</version>
29+
<version>8.2.0</version>
3030
</dependency>
3131
<dependency>
3232
<groupId>com.microsoft.azure</groupId>
Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
1-
<TestConfigurations>
2-
<TargetTestTenant>ProductionTenant</TargetTestTenant>
3-
<TargetPremiumBlobTenant>ProductionTenant</TargetPremiumBlobTenant>
4-
<TargetCopySourceTenant>ProductionTenant</TargetCopySourceTenant>
5-
<TenantConfigurations>
6-
<TenantConfiguration>
7-
<TenantName>DevStore</TenantName>
8-
<TenantType>DevStore</TenantType>
9-
<AccountName>devstoreaccount1</AccountName>
10-
<AccountKey>Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==</AccountKey>
11-
<BlobServiceEndpoint>http://127.0.0.1:10000/devstoreaccount1</BlobServiceEndpoint>
12-
<QueueServiceEndpoint>http://127.0.0.1:10001/devstoreaccount1</QueueServiceEndpoint>
13-
<TableServiceEndpoint>http://127.0.0.1:10002/devstoreaccount1</TableServiceEndpoint>
14-
<BlobServiceSecondaryEndpoint>http://127.0.0.1:10000/devstoreaccount1-secondary</BlobServiceSecondaryEndpoint>
15-
<QueueServiceSecondaryEndpoint>http://127.0.0.1:10001/devstoreaccount1-secondary</QueueServiceSecondaryEndpoint>
16-
<TableServiceSecondaryEndpoint>http://127.0.0.1:10002/devstoreaccount1-secondary</TableServiceSecondaryEndpoint>
17-
</TenantConfiguration>
18-
<TenantConfiguration>
19-
<TenantName>ProductionTenant</TenantName>
20-
<TenantType>Cloud</TenantType>
21-
<AccountName>[ACCOUNT NAME HERE]</AccountName>
22-
<AccountKey>[ACCOUNT KEY HERE]</AccountKey>
23-
<BlobServiceEndpoint>http://[ACCOUNT].blob.core.windows.net</BlobServiceEndpoint>
24-
<QueueServiceEndpoint>http://[ACCOUNT].queue.core.windows.net</QueueServiceEndpoint>
25-
<TableServiceEndpoint>http://[ACCOUNT].table.core.windows.net</TableServiceEndpoint>
26-
<FileServiceEndpoint>http://[ACCOUNT].file.core.windows.net</FileServiceEndpoint>
27-
<BlobServiceSecondaryEndpoint>http://[ACCOUNT]-secondary.blob.core.windows.net</BlobServiceSecondaryEndpoint>
28-
<QueueServiceSecondaryEndpoint>http://[ACCOUNT]-secondary.queue.core.windows.net</QueueServiceSecondaryEndpoint>
29-
<TableServiceSecondaryEndpoint>http://[ACCOUNT]-secondary.table.core.windows.net</TableServiceSecondaryEndpoint>
30-
<ActiveDirectoryApplicationId>[APPLICATION_ID]</ActiveDirectoryApplicationId>
31-
<ActiveDirectoryApplicationSecret>[APPLICATION_SECRET]</ActiveDirectoryApplicationSecret>
32-
<ActiveDirectoryTenantId>[TENANT_ID]</ActiveDirectoryTenantId>
33-
</TenantConfiguration>
34-
</TenantConfigurations>
1+
<TestConfigurations>
2+
<TargetTestTenant>ProductionTenant</TargetTestTenant>
3+
<TargetPremiumBlobTenant>ProductionTenant</TargetPremiumBlobTenant>
4+
<TargetCopySourceTenant>ProductionTenant</TargetCopySourceTenant>
5+
<TenantConfigurations>
6+
<TenantConfiguration>
7+
<TenantName>DevStore</TenantName>
8+
<TenantType>DevStore</TenantType>
9+
<AccountName>devstoreaccount1</AccountName>
10+
<AccountKey>Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==</AccountKey>
11+
<BlobServiceEndpoint>http://127.0.0.1:10000/devstoreaccount1</BlobServiceEndpoint>
12+
<QueueServiceEndpoint>http://127.0.0.1:10001/devstoreaccount1</QueueServiceEndpoint>
13+
<TableServiceEndpoint>http://127.0.0.1:10002/devstoreaccount1</TableServiceEndpoint>
14+
<BlobServiceSecondaryEndpoint>http://127.0.0.1:10000/devstoreaccount1-secondary</BlobServiceSecondaryEndpoint>
15+
<QueueServiceSecondaryEndpoint>http://127.0.0.1:10001/devstoreaccount1-secondary</QueueServiceSecondaryEndpoint>
16+
<TableServiceSecondaryEndpoint>http://127.0.0.1:10002/devstoreaccount1-secondary</TableServiceSecondaryEndpoint>
17+
</TenantConfiguration>
18+
<TenantConfiguration>
19+
<TenantName>ProductionTenant</TenantName>
20+
<TenantType>Cloud</TenantType>
21+
<AccountName>[ACCOUNT NAME HERE]</AccountName>
22+
<AccountKey>[ACCOUNT KEY HERE]</AccountKey>
23+
<BlobServiceEndpoint>http://[ACCOUNT].blob.core.windows.net</BlobServiceEndpoint>
24+
<QueueServiceEndpoint>http://[ACCOUNT].queue.core.windows.net</QueueServiceEndpoint>
25+
<TableServiceEndpoint>http://[ACCOUNT].table.core.windows.net</TableServiceEndpoint>
26+
<FileServiceEndpoint>http://[ACCOUNT].file.core.windows.net</FileServiceEndpoint>
27+
<BlobServiceSecondaryEndpoint>http://[ACCOUNT]-secondary.blob.core.windows.net</BlobServiceSecondaryEndpoint>
28+
<QueueServiceSecondaryEndpoint>http://[ACCOUNT]-secondary.queue.core.windows.net</QueueServiceSecondaryEndpoint>
29+
<TableServiceSecondaryEndpoint>http://[ACCOUNT]-secondary.table.core.windows.net</TableServiceSecondaryEndpoint>
30+
<ActiveDirectoryApplicationId>[APPLICATION_ID]</ActiveDirectoryApplicationId>
31+
<ActiveDirectoryApplicationSecret>[APPLICATION_SECRET]</ActiveDirectoryApplicationSecret>
32+
<ActiveDirectoryTenantId>[TENANT_ID]</ActiveDirectoryTenantId>
33+
</TenantConfiguration>
34+
</TenantConfigurations>
3535
</TestConfigurations>

microsoft-azure-storage-test/src/com/microsoft/azure/storage/Tenant.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public class Tenant {
3535
private String activeDirectoryApplicationId;
3636
private String activeDirectoryApplicationSecret;
3737
private String activeDirectoryTenantId;
38+
private String activeDirectoryAuthEndpoint;
3839

3940
public String getTenantName() {
4041
return this.tenantName;
@@ -108,6 +109,10 @@ public String getActiveDirectoryTenantId() {
108109
return this.activeDirectoryTenantId;
109110
}
110111

112+
public String getActiveDirectoryAuthEndpoint() {
113+
return this.activeDirectoryAuthEndpoint;
114+
}
115+
111116
public void setActiveDirectoryApplicationId(String activeDirectoryApplicationId) {
112117
this.activeDirectoryApplicationId = activeDirectoryApplicationId;
113118
}
@@ -120,6 +125,10 @@ public void setActiveDirectoryTenantId(String activeDirectoryTenantId) {
120125
this.activeDirectoryTenantId = activeDirectoryTenantId;
121126
}
122127

128+
public void setActiveDirectoryAuthEndpoint(String activeDirectoryAuthEndpoint) {
129+
this.activeDirectoryAuthEndpoint = activeDirectoryAuthEndpoint;
130+
}
131+
123132
void setTenantName(String tenantName) {
124133
this.tenantName = tenantName;
125134
}

microsoft-azure-storage-test/src/com/microsoft/azure/storage/TestHelper.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public static String generateOAuthToken() throws MalformedURLException, Interrup
8787
}
8888

8989
// this boiler plate code is from the ADAL sample
90-
String authority = String.format("https://login.microsoftonline.com/%s/oauth2/token",
90+
String authority = String.format(tenant.getActiveDirectoryAuthEndpoint() + "/%s/oauth2/token",
9191
tenant.getActiveDirectoryTenantId());
9292
ClientCredential credential = new ClientCredential(tenant.getActiveDirectoryApplicationId(),
9393
tenant.getActiveDirectoryApplicationSecret());
@@ -647,6 +647,9 @@ else if (name.equals("ActiveDirectoryApplicationSecret")) {
647647
else if (name.equals("ActiveDirectoryTenantId")) {
648648
tenant.setActiveDirectoryTenantId(node.getTextContent());
649649
}
650+
else if (name.equals(("ActiveDirectoryAuthEndpoint"))) {
651+
tenant.setActiveDirectoryAuthEndpoint(node.getTextContent());
652+
}
650653
else if (!premiumBlob){
651654
throw new IllegalArgumentException(String.format(
652655
"Invalid child of TenantConfiguration with name: %s", name));

microsoft-azure-storage-test/src/com/microsoft/azure/storage/blob/CloudAppendBlobTests.java

Lines changed: 54 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,10 @@
1414
*/
1515
package com.microsoft.azure.storage.blob;
1616

17-
import com.microsoft.azure.storage.AccessCondition;
17+
import com.microsoft.azure.storage.*;
18+
import com.microsoft.azure.storage.core.Base64;
1819
import com.microsoft.azure.storage.core.SR;
1920
import com.microsoft.azure.storage.core.Utility;
20-
import com.microsoft.azure.storage.OperationContext;
21-
import com.microsoft.azure.storage.ResponseReceivedEvent;
22-
import com.microsoft.azure.storage.RetryNoRetry;
23-
import com.microsoft.azure.storage.SendingRequestEvent;
24-
import com.microsoft.azure.storage.StorageErrorCodeStrings;
25-
import com.microsoft.azure.storage.StorageEvent;
26-
import com.microsoft.azure.storage.StorageException;
2721
import com.microsoft.azure.storage.TestRunners.CloudTests;
2822
import com.microsoft.azure.storage.TestRunners.DevFabricTests;
2923

@@ -40,6 +34,8 @@
4034
import java.io.IOException;
4135
import java.net.HttpURLConnection;
4236
import java.net.URISyntaxException;
37+
import java.security.MessageDigest;
38+
import java.security.NoSuchAlgorithmException;
4339
import java.util.Calendar;
4440
import java.util.Date;
4541
import java.util.EnumSet;
@@ -210,6 +206,56 @@ public void testCopyFromAppendBlobAbortTest() throws StorageException,
210206
}
211207
}
212208

209+
@Test
210+
@Category({ DevFabricTests.class, TestRunners.DevStoreTests.class })
211+
public void testAppendBlockFromURI() throws URISyntaxException, StorageException, IOException, NoSuchAlgorithmException {
212+
CloudBlobContainer container = BlobTestHelper.getRandomContainerReference();
213+
container.create(BlobContainerPublicAccessType.CONTAINER, null, null);
214+
final CloudBlockBlob blob = container.getBlockBlobReference(BlobTestHelper
215+
.generateRandomBlobNameWithPrefix("testBlob"));
216+
217+
// Note that we copy the blob in halves, so text.length() % 2 must equal 0.
218+
String text = "Test data.";
219+
220+
// create
221+
blob.uploadText(text);
222+
assertTrue(blob.exists());
223+
224+
try {
225+
final CloudAppendBlob blob2 = container.getAppendBlobReference(BlobTestHelper
226+
.generateRandomBlobNameWithPrefix("copyBlob"));
227+
228+
blob2.createOrReplace();
229+
// Copy the first half of the blob.
230+
long pos = blob2.appendBlockFromURI(blob.getUri(), 0L, text.length() / 2L);
231+
assertEquals(0, pos);
232+
233+
// Copy the second half of the blob, specifying the MD5 and setting null for the length to indicate the remainder of the blob.
234+
235+
String md5 = Base64.encode(MessageDigest.getInstance("MD5").digest(text.substring(5).getBytes()));
236+
boolean exceptionThrown = false;
237+
try {
238+
blob2.appendBlockFromURI(blob.getUri(), (text.length() / 2L) + 1, null,
239+
Base64.encode(MessageDigest.getInstance("MD5").digest("garbage".getBytes())), null, null, null, null);
240+
} catch (StorageException e) {
241+
exceptionThrown = true;
242+
assertEquals("Md5Mismatch", e.getErrorCode());
243+
pos = blob2.appendBlockFromURI(blob.getUri(), 5L, null, md5, null, null, null, null);
244+
assertEquals(text.length()/2L, pos);
245+
}
246+
assertTrue(exceptionThrown);
247+
248+
byte[] result = new byte[text.length()];
249+
blob2.downloadToByteArray(result, 0);
250+
for (int i = 0; i < result.length; i++) {
251+
assertEquals(result[i], text.getBytes()[i]);
252+
}
253+
}
254+
finally {
255+
container.deleteIfExists();
256+
}
257+
}
258+
213259
/**
214260
* Create a snapshot
215261
*/

microsoft-azure-storage-test/src/com/microsoft/azure/storage/blob/CloudPageBlobTests.java

Lines changed: 61 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@
2424
import java.net.HttpURLConnection;
2525
import java.net.URI;
2626
import java.net.URISyntaxException;
27+
import java.nio.ByteBuffer;
28+
import java.security.DigestException;
2729
import java.security.InvalidKeyException;
30+
import java.security.MessageDigest;
31+
import java.security.NoSuchAlgorithmException;
2832
import java.util.ArrayList;
2933
import java.util.Calendar;
3034
import java.util.Date;
@@ -36,23 +40,13 @@
3640

3741
import static org.junit.Assert.*;
3842

43+
import com.microsoft.azure.storage.*;
44+
import com.microsoft.azure.storage.core.Base64;
3945
import org.junit.After;
4046
import org.junit.Before;
4147
import org.junit.Test;
4248
import org.junit.experimental.categories.Category;
4349

44-
import com.microsoft.azure.storage.AccessCondition;
45-
import com.microsoft.azure.storage.Constants;
46-
import com.microsoft.azure.storage.OperationContext;
47-
import com.microsoft.azure.storage.RetryNoRetry;
48-
import com.microsoft.azure.storage.SendingRequestEvent;
49-
import com.microsoft.azure.storage.SharedAccessAccountPermissions;
50-
import com.microsoft.azure.storage.SharedAccessAccountPolicy;
51-
import com.microsoft.azure.storage.SharedAccessAccountResourceType;
52-
import com.microsoft.azure.storage.SharedAccessAccountService;
53-
import com.microsoft.azure.storage.StorageEvent;
54-
import com.microsoft.azure.storage.StorageException;
55-
import com.microsoft.azure.storage.TestHelper;
5650
import com.microsoft.azure.storage.TestRunners.CloudTests;
5751
import com.microsoft.azure.storage.TestRunners.DevFabricTests;
5852
import com.microsoft.azure.storage.TestRunners.DevStoreTests;
@@ -797,6 +791,61 @@ public void testUploadPages() throws URISyntaxException, StorageException, IOExc
797791
}
798792
}
799793

794+
@Test
795+
@Category({ DevFabricTests.class, TestRunners.DevStoreTests.class })
796+
public void testPutPagesFromURI() throws URISyntaxException, StorageException, IOException,
797+
NoSuchAlgorithmException, DigestException {
798+
CloudBlobContainer container = BlobTestHelper.getRandomContainerReference();
799+
container.create(BlobContainerPublicAccessType.CONTAINER, null, null);
800+
final CloudBlockBlob blob = container.getBlockBlobReference(BlobTestHelper
801+
.generateRandomBlobNameWithPrefix("testBlob"));
802+
803+
byte[] data = TestHelper.getRandomBuffer(2 * Constants.PAGE_SIZE);
804+
805+
// create
806+
blob.uploadFromByteArray(data, 0, data.length);
807+
assertTrue(blob.exists());
808+
809+
try {
810+
final CloudPageBlob blob2 = container.getPageBlobReference(BlobTestHelper
811+
.generateRandomBlobNameWithPrefix("copyBlob"));
812+
813+
blob2.create(3 * Constants.PAGE_SIZE);
814+
// Copy the first half of the blob.
815+
blob2.putPagesFromURI(0, data.length/2L, blob.getUri(), 0L);
816+
817+
// Copy the second half of the blob, specifying the MD5 and setting null for the length to indicate the remainder of the blob.
818+
MessageDigest digest = MessageDigest.getInstance("MD5");
819+
digest.update(data, Constants.PAGE_SIZE, Constants.PAGE_SIZE);
820+
String md5 = Base64.encode(digest.digest());
821+
boolean exceptionThrown = false;
822+
try {
823+
blob2.putPagesFromURI(Constants.PAGE_SIZE * 2, Constants.PAGE_SIZE, blob.getUri(),
824+
(long)Constants.PAGE_SIZE,
825+
Base64.encode(MessageDigest.getInstance("MD5").digest("garbage".getBytes())), null, null, null,
826+
null);
827+
} catch (StorageException e) {
828+
exceptionThrown = true;
829+
assertEquals("Md5Mismatch", e.getErrorCode());
830+
// Write to the third page.
831+
blob2.putPagesFromURI(Constants.PAGE_SIZE * 2, Constants.PAGE_SIZE, blob.getUri(),
832+
(long)Constants.PAGE_SIZE, md5, null, null, null, null);
833+
}
834+
assertTrue(exceptionThrown);
835+
836+
byte[] result = new byte[2 * Constants.PAGE_SIZE];
837+
blob2.downloadRangeToByteArray(0, (long)Constants.PAGE_SIZE, result, 0);
838+
blob2.downloadRangeToByteArray(2 * Constants.PAGE_SIZE, (long)Constants.PAGE_SIZE, result,
839+
Constants.PAGE_SIZE);
840+
for (int i = 0; i < result.length; i++) {
841+
assertEquals(result[i], data[i]);
842+
}
843+
}
844+
finally {
845+
container.deleteIfExists();
846+
}
847+
}
848+
800849
@Test
801850
public void testClearPages() throws URISyntaxException, StorageException, IOException {
802851
int blobLengthToUse = 8 * 512;

0 commit comments

Comments
 (0)