Use /keys/current for key requests

Possible after https://github.com/zotero/dataserver/commit/beb38579ca1
This commit is contained in:
Dan Stillman 2016-04-25 02:45:03 -04:00
parent ebb2f1667d
commit 4eee369b66
2 changed files with 5 additions and 4 deletions

View File

@ -47,7 +47,7 @@ Zotero.Sync.APIClient.prototype = {
getKeyInfo: Zotero.Promise.coroutine(function* (options={}) { getKeyInfo: Zotero.Promise.coroutine(function* (options={}) {
var uri = this.baseURL + "keys/" + this.apiKey; var uri = this.baseURL + "keys/current";
let opts = {}; let opts = {};
Object.assign(opts, options); Object.assign(opts, options);
opts.successCodes = [200, 404]; opts.successCodes = [200, 404];
@ -518,7 +518,7 @@ Zotero.Sync.APIClient.prototype = {
// Deletes current API key // Deletes current API key
deleteAPIKey: Zotero.Promise.coroutine(function* () { deleteAPIKey: Zotero.Promise.coroutine(function* () {
yield this.makeRequest("DELETE", this.baseURL + "keys/" + this.apiKey); yield this.makeRequest("DELETE", this.baseURL + "keys/current");
}), }),

View File

@ -11,7 +11,7 @@ describe("Zotero.Sync.Runner", function () {
keyInfo: { keyInfo: {
fullAccess: { fullAccess: {
method: "GET", method: "GET",
url: "keys/" + apiKey, url: "keys/current",
status: 200, status: 200,
json: { json: {
key: apiKey, key: apiKey,
@ -729,7 +729,8 @@ describe("Zotero.Sync.Runner", function () {
server.respond(function (req) { server.respond(function (req) {
if (req.method == "DELETE") { if (req.method == "DELETE") {
assert.equal(req.url, baseURL + "keys/" + apiKey); assert.propertyVal(req.requestHeaders, 'Zotero-API-Key', apiKey);
assert.equal(req.url, baseURL + "keys/current");
} }
req.respond(204); req.respond(204);
}); });