Skip to content
This repository was archived by the owner on Apr 3, 2019. It is now read-only.

Commit 993b1ad

Browse files
author
Shane Tomlinson
committed
feat(basket): Make calls directly to the basket server rather than the proxy
Note: configuration under the basket namespace were merged into the marketing_email namespace, there doesn't seem to be a good reason for both namespaces to exist. fixes #7048 BREAKING CHANGE
1 parent aa89519 commit 993b1ad

File tree

4 files changed

+17
-28
lines changed

4 files changed

+17
-28
lines changed

app/scripts/lib/marketing-email-client.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class MarketingEmailClient {
5454
// I would prefer to place this into the MarketingEmailPrefs model
5555
// but doing so required passing around the preferencesUrl to lots of
5656
// irrelevant classes.
57-
if (response.token) {
57+
if ('token' in response) {
5858
response.preferencesUrl = this._preferencesUrl + response.token;
5959
}
6060

app/tests/spec/lib/marketing-email-client.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,15 @@ describe('lib/marketing-email-client', () => {
7676
it('returns a preferences URL for the user', () => {
7777
sinon.stub(xhrMock, 'ajax').callsFake(() => {
7878
return Promise.resolve({
79-
token: 'users_uuid'
79+
// the fake basket server can return a token of the number 0, ensure this is handled.
80+
token: 0
8081
});
8182
});
8283

8384
return client.fetch('token', '[email protected]')
8485
.then(function (data) {
8586
assert.equal(data.token, 'users_uuid');
86-
assert.equal(data.preferencesUrl, PREFERENCES_URL + 'users_uuid');
87+
assert.equal(data.preferencesUrl, `${PREFERENCES_URL}0`);
8788

8889
assert.isTrue(xhrMock.ajax.calledOnce);
8990
const request = xhrMock.ajax.args[0][0];

server/lib/configuration.js

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -35,28 +35,6 @@ const conf = module.exports = convict({
3535
doc: 'Check if the resources are under the /dist directory',
3636
format: Boolean
3737
},
38-
basket: {
39-
api_key: {
40-
default: 'test key please change',
41-
doc: 'Basket API key',
42-
format: String
43-
},
44-
api_timeout: {
45-
default: '5 seconds',
46-
doc: 'Timeout for talking to the Basket API server, in ms',
47-
format: Number
48-
},
49-
api_url: {
50-
default: 'http://127.0.0.1:10140',
51-
doc: 'Url for the Basket API server',
52-
format: String
53-
},
54-
proxy_url: {
55-
default: 'http://127.0.0.1:1114',
56-
doc: 'Url for the Basket proxy server',
57-
format: String
58-
}
59-
},
6038
cachify_prefix: {
6139
default: 'v',
6240
doc: 'The prefix for cachify hashes in URLs'
@@ -340,8 +318,18 @@ const conf = module.exports = convict({
340318
}
341319
},
342320
marketing_email: {
321+
api_key: {
322+
default: 'test key please change',
323+
doc: 'Basket API key',
324+
format: String
325+
},
326+
api_timeout: {
327+
default: '5 seconds',
328+
doc: 'Timeout for talking to the Basket API server, in ms',
329+
format: Number
330+
},
343331
api_url: {
344-
default: 'http://127.0.0.1:1114',
332+
default: 'http://127.0.0.1:10140',
345333
doc: 'User facing URL of the Marketing Email Server',
346334
env: 'FXA_MARKETING_EMAIL_API_URL',
347335
format: 'url'

tests/lib/basket.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
const request = require('./request');
66
const config = require('../../server/lib/configuration');
7-
var API_KEY = config.get('basket.api_key');
8-
var API_URL = config.get('basket.api_url');
7+
var API_KEY = config.get('marketing_email.api_key');
8+
var API_URL = config.get('marketing_email.api_url');
99

1010
var LOOKUP_URL = API_URL + '/lookup-user/?email=';
1111

0 commit comments

Comments
 (0)