Skip to content

Commit

Permalink
Fix: Add sharedLink header for autocad metadata (#1035)
Browse files Browse the repository at this point in the history
  • Loading branch information
ConradJChan authored Jul 9, 2019
1 parent 22bc140 commit 1a2e4db
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
18 changes: 17 additions & 1 deletion src/lib/__tests__/metadataAPI-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable no-unused-expressions */
import metadataAPI from '../metadataAPI';
import api from '../api';
import * as utils from '../util';

const sandbox = sinon.sandbox.create();
let stubs = {};
Expand All @@ -15,7 +16,7 @@ describe('metadataAPI', () => {
sandbox.verifyAndRestore();
});

describe('getXrefsMetadata', () => {
describe('getXrefsMetadata()', () => {
it('Should reject the promise if id is not provided on the file', () => {
return metadataAPI.getXrefsMetadata(null, 'autocad').catch((err) => {
expect(stubs.get).not.to.have.been.called;
Expand Down Expand Up @@ -50,4 +51,19 @@ describe('metadataAPI', () => {
});
});
});

describe('getMetadata()', () => {
it('Should get the metadata with the provided headers', () => {
stubs.getHeaders = sandbox.stub(utils, 'getHeaders');

metadataAPI.getMetadata('123', 'global', 'autocad', {
apiHost: 'foo.com',
token: '456',
sharedLink: 'shared-link',
sharedLinkPassword: 'shared-link-password'
});

expect(stubs.getHeaders).to.have.been.calledWith({}, '456', 'shared-link', 'shared-link-password');
});
});
});
13 changes: 8 additions & 5 deletions src/lib/metadataAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,16 @@ const metadataAPI = {
* @param {string} id - File id
* @param {string} scope - Metadata template scope
* @param {string} template - Metadata template
* @param {Object} [options] - options object
* @param {Object} [options.apiHost] - api host
* @param {Object} [options.token] - authentication token
* @param {Object} [options.sharedLink] - shared link
* @param {Object} [options.sharedLinkPassword] - shared link password if any
* @return {Promise} XHR promise
*/
getMetadata(id, scope, template, options = {}) {
const { apiHost, token } = options;

return api.get(metadataAPI.getMetadataURL(id, scope, template, apiHost), { headers: getHeaders({}, token) });
getMetadata(id, scope, template, { apiHost, token, sharedLink, sharedLinkPassword }) {
return api.get(metadataAPI.getMetadataURL(id, scope, template, apiHost), {
headers: getHeaders({}, token, sharedLink, sharedLinkPassword)
});
},

/**
Expand Down

0 comments on commit 1a2e4db

Please sign in to comment.