From a3bfae89762c861d19a2b1ce89a02181b64895b8 Mon Sep 17 00:00:00 2001 From: Michael Krotscheck Date: Fri, 19 Aug 2016 12:43:04 -0700 Subject: [PATCH] Removed authenticate() method Functionality is now available via tokenIssue() and catalogList(). Change-Id: I9871304694286d1d0f4f6c395074ebd6d8f2e2c8 --- src/keystone.js | 30 ------------------------------ test/unit/keystoneTest.js | 31 +------------------------------ 2 files changed, 1 insertion(+), 60 deletions(-) diff --git a/src/keystone.js b/src/keystone.js index b85da98..54f628d 100644 --- a/src/keystone.js +++ b/src/keystone.js @@ -201,34 +201,4 @@ export default class Keystone { .then((response) => response.json()) .then((body) => body.catalog); } - - authenticate () { - const body = { - auth: { - identity: { - methods: ['password'], - password: { - user: { - name: this.cloudConfig.auth.username, - password: this.cloudConfig.auth.password - } - } - } - } - }; - - return this - .serviceEndpoint() - .then((url) => this.http.httpPost(url, body)) - .then((res) => { - this.token = res.headers.get('X-Subject-Token'); - return res.json(); // This returns a promise... - }) - .then((body) => { - this.catalog = body.catalog || {}; - }) - .catch((reason) => { - return reason; - }); - } } diff --git a/test/unit/keystoneTest.js b/test/unit/keystoneTest.js index 022b1aa..0142d69 100644 --- a/test/unit/keystoneTest.js +++ b/test/unit/keystoneTest.js @@ -14,41 +14,12 @@ describe('Keystone', () => { it('should throw an error for an empty config', () => { try { const keystone = new Keystone(); - keystone.authenticate(); + keystone.tokenIssue(); } catch (e) { expect(e.message).toEqual('A configuration is required.'); } }); - it('should authenticate', (done) => { - const authUrl = "http://192.168.99.99/identity_v2_admin/v3/"; - fetchMock.mock(mockData.root()); - - fetchMock - .post(authUrl, { - body: { - catalog: { - foo: 'bar' - } - }, - headers: { - 'X-Subject-Token': 'the-token' - } - }); - - const keystone = new Keystone(mockData.config); - - keystone.authenticate() - .then(() => { - expect(fetchMock.called(authUrl)).toEqual(true); - expect(typeof keystone.token).toEqual('string'); - expect(keystone.token).toEqual('the-token'); - expect(keystone.catalog).toEqual({foo: 'bar'}); - done(); - }) - .catch((error) => done.fail(error)); - }); - describe("versions()", () => { it("Should return a list of all versions available on this clouds' keystone", (done) => { const keystone = new Keystone(mockData.config);