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);