|
| 1 | +describe('/workspaces', function () { |
| 2 | + const client = require("../../lib/client")("root", "secret"); |
| 3 | + const secrets = client.secrets; |
| 4 | + const nock = require('nock'); |
| 5 | + |
| 6 | + describe('/{id}/secrets', function() { |
| 7 | + describe('/{secretId}', function() { |
| 8 | + it('should send request successfully', function (done) { |
| 9 | + const response = { |
| 10 | + 'id': '54f4be3fe7d5224f91000002', |
| 11 | + 'type': 'auth-secret', |
| 12 | + 'attributes': { |
| 13 | + 'name': 'secret-name', |
| 14 | + 'credentials': {}, |
| 15 | + 'state': 'secret-state' |
| 16 | + }, |
| 17 | + 'relationships': { |
| 18 | + 'workspace': { |
| 19 | + 'data': { |
| 20 | + 'id': '54f4be3fe7d5224f91000001', |
| 21 | + 'type': 'workspace' |
| 22 | + }, |
| 23 | + 'links': { |
| 24 | + 'self': '/v2/workspaces/54f4be3fe7d5224f91000001' |
| 25 | + } |
| 26 | + }, |
| 27 | + 'user': { |
| 28 | + 'data': { |
| 29 | + 'id': '54f4be3fe7d5224f91000003', |
| 30 | + 'type': 'user' |
| 31 | + }, |
| 32 | + 'links': { |
| 33 | + 'self': '/v2/users/54f4be3fe7d5224f91000003' |
| 34 | + } |
| 35 | + }, |
| 36 | + 'auth_client': { |
| 37 | + 'data': { |
| 38 | + 'id': '54f4be3fe7d5224f91000004', |
| 39 | + 'type': 'auth-client' |
| 40 | + }, |
| 41 | + 'links': { |
| 42 | + 'self': '/v2/tenants/54f4be3fe7d5224f91000005/auth-clients/54f4be3fe7d5224f91000004' |
| 43 | + } |
| 44 | + } |
| 45 | + }, |
| 46 | + 'links': { |
| 47 | + 'self': '/v2/workspaces/54f4be3fe7d5224f91000001/secrets/54f4be3fe7d5224f91000002' |
| 48 | + } |
| 49 | + }; |
| 50 | + |
| 51 | + nock('https://api.elastic.io') |
| 52 | + .matchHeader('Connection', 'Keep-Alive') |
| 53 | + .get('/v2/workspaces/54f4be3fe7d5224f91000001/secrets/54f4be3fe7d5224f91000002') |
| 54 | + .basicAuth({ |
| 55 | + user: 'root', |
| 56 | + pass: 'secret' |
| 57 | + }) |
| 58 | + .reply(200, response); |
| 59 | + |
| 60 | + secrets.retrieve('54f4be3fe7d5224f91000001', '54f4be3fe7d5224f91000002') |
| 61 | + .then(function (result) { |
| 62 | + expect(result).toEqual(response); |
| 63 | + }) |
| 64 | + .then(done) |
| 65 | + .catch(done.fail); |
| 66 | + }); |
| 67 | + }); |
| 68 | + }); |
| 69 | +}); |
0 commit comments