Skip to content

Commit

Permalink
[Storage] Fix Get Account/Service properties fail, and update readme (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
blueww authored Jun 11, 2021
1 parent dbe5b71 commit d3caad6
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 7 deletions.
5 changes: 5 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
## Upcoming Release

Blob:

- Fixed get service properties or account properties failure from blob endpoint when Uri has suffix '/' after account name.
- Fixed get system container failure.

## 2021.6 Version 3.13.0

General:
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
[![Build Status](https://dev.azure.com/azure/Azurite/_apis/build/status/Azure.Azurite?branchName=master)](https://dev.azure.com/azure/Azurite/_build/latest?definitionId=20&branchName=master)

> Note:
> Azurite V2 has been moved to [legacy-master](https://github.com/Azure/azurite/tree/legacy-master) branch.
> Master branch has been updated with latest Azurite V3.
> V3 supports Blob, Queue and Table service (Table is in preview).
> The latest Azurite V3 code, which supports Blob, Queue, and Table (preview) is in the master branch.
> The legacy Azurite V2 code is in the [legacy-master](https://github.com/Azure/azurite/tree/legacy-master) branch.
| Version | Azure Storage API Version | Service Support | Description | Reference Links |
| ------------------------------------------------------------------ | ------------------------- | ------------------------------ | ------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
Expand Down
5 changes: 3 additions & 2 deletions src/blob/middlewares/blobStorageContext.middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,9 @@ export function blobStorageContextMiddleware(
return next(handlerError);
}

// validate conatainer name
if (container !== undefined) {
// validate conatainer name, when container name has value (not undefined or empty string)
// skip validate system container
if (container && !container.startsWith("$")) {
validateContainerName(requestID, container);
}

Expand Down
5 changes: 3 additions & 2 deletions src/table/middleware/tableStorageContext.middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,9 @@ export function tableStorageContextMiddleware(
requestID
);

// validate Table name
if (tableContext.tableName !== undefined) {
// validate table name, when table name has value (not undefined or empty string)
// skip check for system table
if (tableContext.tableName && !tableContext.tableName.startsWith("$")) {
validateTableName(tableContext, tableContext.tableName);
}

Expand Down
13 changes: 13 additions & 0 deletions tests/blob/apis/container.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,19 @@ describe("ContainerAPIs", () => {
assert.ok(expectedError);
});

it("getProperties should return 404 for non existed system container @loki @sql", async () => {
const nonExistedContainerURL = serviceClient.getContainerClient("$logs");
let expectedError = false;
try {
await nonExistedContainerURL.getProperties();
} catch (err) {
if (err.response.status === 404) {
expectedError = true;
}
}
assert.ok(expectedError);
});

it("create with default parameters @loki @sql", (done) => {
// create() with default parameters has been tested in beforeEach
done();
Expand Down
36 changes: 36 additions & 0 deletions tests/blob/apis/service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,4 +360,40 @@ describe("ServiceAPIs", () => {
result.clientRequestId
);
});

it("Get Account/Service Properties with Uri has suffix '/' after account name @loki @sql", async () => {
const baseURL1 = `http://${server.config.host}:${server.config.port}/devstoreaccount1/`;
const serviceClient1 = new BlobServiceClient(
baseURL1,
newPipeline(
new StorageSharedKeyCredential(
EMULATOR_ACCOUNT_NAME,
EMULATOR_ACCOUNT_KEY
),
{
retryOptions: { maxTries: 1 },
// Make sure socket is closed once the operation is done.
keepAliveOptions: { enable: false }
}
)
);

let result = await serviceClient1.getAccountInfo();
assert.equal(result.accountKind, EMULATOR_ACCOUNT_KIND);
assert.equal(result.skuName, EMULATOR_ACCOUNT_SKUNAME);
assert.equal(
result._response.request.headers.get("x-ms-client-request-id"),
result.clientRequestId
);

result = await serviceClient1.getProperties();
assert.ok(typeof result.requestId);
assert.ok(result.requestId!.length > 0);
assert.ok(typeof result.version);
assert.ok(result.version!.length > 0);
assert.equal(
result._response.request.headers.get("x-ms-client-request-id"),
result.clientRequestId
);
});
});

0 comments on commit d3caad6

Please sign in to comment.