Removed authenticate() method
Functionality is now available via tokenIssue() and catalogList(). Change-Id: I9871304694286d1d0f4f6c395074ebd6d8f2e2c8
This commit is contained in:
parent
be86176883
commit
a3bfae8976
|
@ -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;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue