2015-08-11 12:27:07 -04:00
|
|
|
import { blank, present } from 'helpers/qunit-helpers';
|
2015-11-20 20:27:06 -05:00
|
|
|
import AdminUser from 'admin/models/admin-user';
|
|
|
|
import ApiKey from 'admin/models/api-key';
|
2013-10-22 15:53:08 -04:00
|
|
|
|
2016-06-30 13:55:44 -04:00
|
|
|
module("model:admin-user");
|
2013-10-22 15:53:08 -04:00
|
|
|
|
2016-06-30 13:55:44 -04:00
|
|
|
test('generate key', function() {
|
2015-11-20 20:27:06 -05:00
|
|
|
var adminUser = AdminUser.create({id: 333});
|
2013-10-22 15:53:08 -04:00
|
|
|
blank(adminUser.get('api_key'), 'it has no api key by default');
|
|
|
|
adminUser.generateApiKey().then(function() {
|
|
|
|
present(adminUser.get('api_key'), 'it has an api_key now');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2016-06-30 13:55:44 -04:00
|
|
|
test('revoke key', function() {
|
2013-10-22 15:53:08 -04:00
|
|
|
|
2015-11-20 20:27:06 -05:00
|
|
|
var apiKey = ApiKey.create({id: 1234, key: 'asdfasdf'}),
|
|
|
|
adminUser = AdminUser.create({id: 333, api_key: apiKey});
|
2013-10-22 15:53:08 -04:00
|
|
|
|
|
|
|
equal(adminUser.get('api_key'), apiKey, 'it has the api key in the beginning');
|
|
|
|
adminUser.revokeApiKey().then(function() {
|
|
|
|
blank(adminUser.get('api_key'), 'it cleared the api_key');
|
|
|
|
});
|
2014-07-30 18:56:01 -04:00
|
|
|
});
|