Skip to content

Commit 19950ed

Browse files
committed
Fix test failures
1 parent 146bc7d commit 19950ed

36 files changed

+676
-1188
lines changed

package-lock.json

Lines changed: 0 additions & 396 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/blob/authentication/BlobSharedKeyAuthenticator.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default class BlobSharedKeyAuthenticator implements IAuthenticator {
1313
public constructor(
1414
private readonly dataStore: IAccountDataStore,
1515
private readonly logger: ILogger
16-
) {}
16+
) { }
1717

1818
public async validate(
1919
req: IRequest,
@@ -77,8 +77,8 @@ export default class BlobSharedKeyAuthenticator implements IAuthenticator {
7777
const stringToSign: string =
7878
[
7979
req.getMethod().toUpperCase(),
80-
this.getHeaderValueToSign(req, HeaderConstants.CONTENT_ENCODING),
8180
this.getHeaderValueToSign(req, HeaderConstants.CONTENT_LANGUAGE),
81+
this.getHeaderValueToSign(req, HeaderConstants.CONTENT_ENCODING),
8282
this.getHeaderValueToSign(req, HeaderConstants.CONTENT_LENGTH),
8383
this.getHeaderValueToSign(req, HeaderConstants.CONTENT_MD5),
8484
this.getHeaderValueToSign(req, HeaderConstants.CONTENT_TYPE),
@@ -137,10 +137,9 @@ export default class BlobSharedKeyAuthenticator implements IAuthenticator {
137137
}
138138
}
139139

140-
if (context.context.isSecondary && blobContext.authenticationPath?.indexOf(account) === 1)
141-
{
142-
// JS/.net Track2 SDK will generate stringToSign from IP style URI with "-secondary" in authenticationPath, so will also compare signature with this kind stringToSign
143-
const stringToSign_secondary: string =
140+
if (context.context.isSecondary && blobContext.authenticationPath?.indexOf(account) === 1) {
141+
// JS/.net Track2 SDK will generate stringToSign from IP style URI with "-secondary" in authenticationPath, so will also compare signature with this kind stringToSign
142+
const stringToSign_secondary: string =
144143
[
145144
req.getMethod().toUpperCase(),
146145
this.getHeaderValueToSign(req, HeaderConstants.CONTENT_ENCODING),
@@ -171,7 +170,7 @@ export default class BlobSharedKeyAuthenticator implements IAuthenticator {
171170
blobContext.contextId
172171
);
173172

174-
const signature1_secondary= computeHMACSHA256(stringToSign_secondary, accountProperties.key1);
173+
const signature1_secondary = computeHMACSHA256(stringToSign_secondary, accountProperties.key1);
175174
const authValue1_secondary = `SharedKey ${account}:${signature1_secondary}`;
176175
this.logger.info(
177176
`BlobSharedKeyAuthenticator:validate() Calculated authentication header based on key1 and stringToSign with "-secondary": ${authValue1_secondary}`,

src/blob/generated/ExpressRequestAdapter.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Request } from 'express';
33
import IRequest, { HttpMethod } from './IRequest';
44

55
export default class ExpressRequestAdapter implements IRequest {
6-
public constructor(private readonly req: Request) {}
6+
public constructor(private readonly req: Request) { }
77

88
public getMethod(): HttpMethod {
99
return this.req.method.toUpperCase() as HttpMethod;
@@ -48,7 +48,13 @@ export default class ExpressRequestAdapter implements IRequest {
4848
}
4949

5050
public getQuery(key: string): string | undefined {
51-
return this.req.query[key];
51+
const queryValue = this.req.query[key];
52+
if ((typeof queryValue) === "string") {
53+
return queryValue;
54+
}
55+
else {
56+
return undefined;
57+
}
5258
}
5359

5460
public getProtocol(): string {

src/blob/generated/artifacts/parameters.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,6 @@ export const blobSequenceNumber: msRest.OperationParameter = {
223223
],
224224
mapper: {
225225
serializedName: "x-ms-blob-sequence-number",
226-
defaultValue: 0,
227226
type: {
228227
name: "Number"
229228
}

src/blob/generated/utils/xml.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import * as xml2js from 'xml2js';
22

33
export function stringifyXML(obj: any, opts?: { rootName?: string }) {
44
const builder = new xml2js.Builder({
5-
explicitArray: false,
6-
explicitCharkey: false,
75
renderOpts: {
86
pretty: false
97
},
@@ -25,7 +23,7 @@ export function parseXML(
2523
emptyTag: undefined
2624
});
2725
return new Promise((resolve, reject) => {
28-
xmlParser.parseString(str, (err?: Error, res?: any) => {
26+
xmlParser.parseString(str, (err?: Error | null, res?: any) => {
2927
if (err) {
3028
reject(err);
3129
} else {

src/blob/handlers/AppendBlobHandler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ export default class AppendBlobHandler extends BaseHandler
205205
requestId: context.contextId,
206206
eTag: properties.etag,
207207
lastModified: properties.lastModified,
208-
contentMD5: contentMD5Buffer,
208+
contentMD5: contentMD5Buffer ? new Uint8Array(contentMD5Buffer) : undefined,
209209
xMsContentCrc64: undefined,
210210
clientRequestId: options.requestId,
211211
version: BLOB_API_VERSION,

src/blob/handlers/BlobBatchHandler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ export class BlobBatchHandler {
266266
return;
267267
}
268268

269-
buffer.fill(chunk, pos, pos + chunk.length);
269+
buffer.fill(new Uint8Array(chunk), pos, pos + chunk.length);
270270
pos += chunk.length;
271271
});
272272

src/blob/handlers/BlobBatchSubResponse.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ export class BlobBatchSubResponse implements IResponse {
7474
return this.bodyStream;
7575
}
7676

77-
public getBodyContent(): string{
77+
public getBodyContent(): string {
7878
return this.bodyStream.getBodyContent();
7979
}
8080

81-
public end(): void{
81+
public end(): void {
8282
this.setStatusMessage(STATUS_CODES[this.statusCode!] || 'unknown');
8383
}
8484
}

src/blob/handlers/SubResponseTextBodyStream.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { Writable } from "stream";
22
import { BlobBatchSubResponse } from "./BlobBatchSubResponse";
33

4-
export class SubResponseTextBodyStream extends Writable
5-
{
4+
export class SubResponseTextBodyStream extends Writable {
65
private bodyText: string;
76
public constructor(
87
private readonly subResponse: BlobBatchSubResponse) {
@@ -15,12 +14,13 @@ export class SubResponseTextBodyStream extends Writable
1514
callback();
1615
}
1716

18-
public end(cb?: (() => void) | undefined): void;
19-
public end(chunk: any, cb?: (() => void) | undefined): void;
20-
public end(chunk: any, encoding: BufferEncoding, cb?: (() => void) | undefined): void;
21-
public end(chunk?: unknown, encoding?: unknown, cb?: unknown): void {
17+
public end(cb?: (() => void) | undefined): this;
18+
public end(chunk: any, cb?: (() => void) | undefined): this;
19+
public end(chunk: any, encoding: BufferEncoding, cb?: (() => void) | undefined): this;
20+
public end(chunk?: unknown, encoding?: unknown, cb?: unknown): this {
2221
if (chunk) this.bodyText += (chunk! as any).toString();
2322
this.subResponse.end();
23+
return this;
2424
}
2525

2626
public getBodyContent(): string {

src/blob/main.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ function shutdown(server: BlobServer | SqlBlobServer) {
2020
});
2121
}
2222

23+
2324
/**
2425
* Entry for Azurite blob service.
2526
*/
@@ -45,9 +46,9 @@ async function main() {
4546
console.log(
4647
`Azurite Blob service successfully listens on ${server.getHttpServerAddress()}`
4748
);
48-
49+
4950
const location = await env.location();
50-
AzuriteTelemetryClient.init(location, !env.disableTelemetry(), env);
51+
AzuriteTelemetryClient.init(location, !env.disableTelemetry(), env);
5152
await AzuriteTelemetryClient.TraceStartEvent("Blob");
5253

5354
// Handle close event

0 commit comments

Comments
 (0)