From fbe2829b935072b730c4553362cb3a41a7562021 Mon Sep 17 00:00:00 2001 From: kirrg001 Date: Fri, 18 Jan 2019 17:36:11 +0100 Subject: [PATCH] Added test helper for admin api v2: getValidAdminKey no issue --- core/test/functional/api/v2/admin/utils.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/core/test/functional/api/v2/admin/utils.js b/core/test/functional/api/v2/admin/utils.js index a0bcefee41..8c33a21180 100644 --- a/core/test/functional/api/v2/admin/utils.js +++ b/core/test/functional/api/v2/admin/utils.js @@ -99,5 +99,21 @@ module.exports = { doAuth(...args) { return testUtils.API.doAuth(`${API_URL}session/`, ...args); + }, + + getValidAdminKey(endpoint) { + const jwt = require('jsonwebtoken'); + const JWT_OPTIONS = { + algorithm: 'HS256' + }; + + return jwt.sign( + { + kid: testUtils.DataGenerator.Content.api_keys[0].id + }, + Buffer.from(testUtils.DataGenerator.Content.api_keys[0].secret, 'hex'), + JWT_OPTIONS, + endpoint + ); } };