Skip to content

Commit

Permalink
fix index tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ddelgrosso1 committed Jul 15, 2024
1 parent e155b1b commit 0cdab1f
Show file tree
Hide file tree
Showing 4 changed files with 518 additions and 700 deletions.
2 changes: 2 additions & 0 deletions src/storage-transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export class StorageTransport {
private retryOptions: RetryOptions;
private baseUrl: string;
private timeout?: number;
private useAuthWithCustomEndpoint?: boolean;

constructor(options: TransportParameters) {
if (options.authClient instanceof GoogleAuth) {
Expand All @@ -114,6 +115,7 @@ export class StorageTransport {
this.retryOptions = options.retryOptions;
this.baseUrl = options.baseUrl;
this.timeout = options.timeout;
this.useAuthWithCustomEndpoint = options.useAuthWithCustomEndpoint;
}

makeRequest<T>(
Expand Down
9 changes: 4 additions & 5 deletions src/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,7 @@ export class Storage {
{
method: 'POST',
queryParameters: query,
body: JSON.stringify(body),
body,
url: '/b',
responseType: 'json',
headers: {
Expand Down Expand Up @@ -1487,7 +1487,6 @@ export class Storage {
callback(err, null, null, resp);
return;
}

const itemsArray = data?.items ? data.items : [];
const hmacKeys = itemsArray.map((hmacKey: HmacKeyMetadata) => {
const hmacKeyInstance = this.hmacKey(hmacKey.accessId!, {
Expand All @@ -1501,7 +1500,7 @@ export class Storage {
? Object.assign({}, options, {pageToken: data.nextPageToken})
: null;

callback(null, [hmacKeys, nextQuery]);
callback(null, hmacKeys, nextQuery, resp);
}
);
}
Expand Down Expand Up @@ -1588,9 +1587,9 @@ export class Storage {
}
const camelCaseResponse = {} as {[index: string]: string};

for (const prop in resp) {
for (const prop in data) {
// eslint-disable-next-line no-prototype-builtins
if (resp.hasOwnProperty(prop)) {
if (data.hasOwnProperty(prop)) {
const camelCaseProp = prop.replace(/_(\w)/g, (_, match) =>
match.toUpperCase()
);
Expand Down
5 changes: 4 additions & 1 deletion test/headers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ import * as sinon from 'sinon';
import {StorageTransport} from '../src/storage-transport.js';
import {Storage} from '../src/storage.js';
import {GaxiosResponse} from 'gaxios';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import {getPackageJSON} from '../src/package-json-helper.cjs';

const error = Error('not implemented');

Expand Down Expand Up @@ -49,7 +52,7 @@ describe('headers', () => {
baseUrl: 'https://base-url.com',
scopes: 'scope',
retryOptions: {},
packageJson: require('../package.json'),
packageJson: getPackageJSON(),
});
storage.storageTransport = storageTransport;
});
Expand Down
Loading

0 comments on commit 0cdab1f

Please sign in to comment.