Skip to content

Commit

Permalink
Bug 1608011 - ensure sync telemetry reports the storage node type. r=…
Browse files Browse the repository at this point in the history
…tcsc

Differential Revision: https://phabricator.services.mozilla.com/D59273

--HG--
extra : moz-landing-system : lando
  • Loading branch information
mhammond committed Jan 9, 2020
1 parent 1f941a2 commit dad771f
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
45 changes: 44 additions & 1 deletion services/common/tests/unit/test_tokenserverclient.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,55 @@ add_task(async function test_working_bid_exchange() {
let url = server.baseURI + "/1.0/foo/1.0";
let result = await client.getTokenFromBrowserIDAssertion(url, "assertion");
Assert.equal("object", typeof result);
do_check_attribute_count(result, 6);
do_check_attribute_count(result, 7);
Assert.equal(service, result.endpoint);
Assert.equal("id", result.id);
Assert.equal("key", result.key);
Assert.equal("uid", result.uid);
Assert.equal(duration, result.duration);
Assert.deepEqual(undefined, result.node_type);
await promiseStopServer(server);
});

add_task(async function test_working_bid_exchange_with_nodetype() {
_("Ensure that a token response with a node type as expected.");

let service = "http://example.com/foo";
let duration = 300;
let nodeType = "the-node-type";

let server = httpd_setup({
"/1.0/foo/1.0": function (request, response) {
Assert.ok(request.hasHeader("accept"));
Assert.ok(!request.hasHeader("x-conditions-accepted"));
Assert.equal("application/json", request.getHeader("accept"));

response.setStatusLine(request.httpVersion, 200, "OK");
response.setHeader("Content-Type", "application/json");

let body = JSON.stringify({
id: "id",
key: "key",
api_endpoint: service,
uid: "uid",
duration,
node_type: nodeType,
});
response.bodyOutputStream.write(body, body.length);
},
});

let client = new TokenServerClient();
let url = server.baseURI + "/1.0/foo/1.0";
let result = await client.getTokenFromBrowserIDAssertion(url, "assertion");
Assert.equal("object", typeof result);
do_check_attribute_count(result, 7);
Assert.equal(service, result.endpoint);
Assert.equal("id", result.id);
Assert.equal("key", result.key);
Assert.equal("uid", result.uid);
Assert.equal(duration, result.duration);
Assert.equal(nodeType, result.node_type);
await promiseStopServer(server);
});

Expand Down
1 change: 1 addition & 0 deletions services/common/tokenserverclient.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ TokenServerClient.prototype = {
uid: result.uid,
duration: result.duration,
hashed_fxa_uid: result.hashed_fxa_uid,
node_type: result.node_type,
};
},

Expand Down

0 comments on commit dad771f

Please sign in to comment.