Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Add sharedLink header for autocad metadata #1035

Merged
merged 2 commits into from
Jul 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
jstoffan marked this conversation as resolved.
Show resolved Hide resolved
});
},

/**
Expand Down