Merge pull request #491 from hashicorp/chore-ember-upgrade

Chore ember upgrade
This commit is contained in:
Susmitha Girumala authored and GitHub committed 2021-03-08 10:51:55 -05:00
commit 99754e47e0
281 files changed
+2277 -1613

No files matched your search

+1
View File
@@ -13,6 +13,7 @@
# misc
/coverage/
!.*
.eslintcache
# ember-try
/.node_modules.ember-try/
+21 -15
View File
@@ -7,48 +7,54 @@ module.exports = {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
legacyDecorators: true
}
legacyDecorators: true,
},
},
plugins: [
'ember'
],
plugins: ['ember'],
extends: [
'eslint:recommended',
'plugin:ember/recommended'
'plugin:ember/recommended',
'plugin:prettier/recommended',
],
env: {
browser: true
browser: true,
},
rules: {
'ember/no-get': 'off',
'ember/no-get-with-default': 'off',
'ember/no-computed-properties-in-native-classes': 'off',
'ember/no-assignment-of-untracked-properties-used-in-tracking-contexts':
'off',
},
rules: {},
overrides: [
// node files
{
files: [
'.eslintrc.js',
'.prettierrc.js',
'.template-lintrc.js',
'ember-cli-build.js',
'index.js',
'testem.js',
'blueprints/*/index.js',
'config/**/*.js',
'tests/dummy/config/**/*.js'
'tests/dummy/config/**/*.js',
],
excludedFiles: [
'addon/**',
'addon-test-support/**',
'app/**',
'tests/dummy/app/**'
'tests/dummy/app/**',
],
parserOptions: {
sourceType: 'script'
sourceType: 'script',
},
env: {
browser: false,
node: true
node: true,
},
plugins: ['node'],
extends: ['plugin:node/recommended']
}
]
extends: ['plugin:node/recommended'],
},
],
};
+1
View File
@@ -10,6 +10,7 @@
/.editorconfig
/.ember-cli
/.env*
/.eslintcache
/.eslintignore
/.eslintrc.js
/.git/
@@ -1,4 +1,6 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.
# unconventional js
/blueprints/*/files/
/vendor/
# compiled output
/dist/
@@ -9,15 +11,9 @@
/node_modules/
# misc
/.env*
/.pnp*
/.sass-cache
/connect.lock
/coverage/
/libpeerconnection.log
/npm-debug.log*
/testem.log
/yarn-error.log
!.*
.eslintcache
# ember-try
/.node_modules.ember-try/
+5
View File
@@ -0,0 +1,5 @@
'use strict';
module.exports = {
singleQuote: true,
};
+1 -1
View File
@@ -1,5 +1,5 @@
'use strict';
module.exports = {
extends: 'octane'
extends: 'octane',
};
+2 -1
View File
@@ -18,7 +18,8 @@ export default class GeneratedRoleModel extends BaseModel {
description;
@attr('string', {
description: 'The scope to which this role applies. Defaults to the role\'s scope.',
description:
"The scope to which this role applies. Defaults to the role's scope.",
})
grant_scope_id;
@@ -2,7 +2,6 @@ import BaseModel from '../../models/base';
import { attr } from '@ember-data/model';
export default class GeneratedSessionModel extends BaseModel {
// =attributes
@attr('string') user_id;
@@ -32,5 +31,4 @@ export default class GeneratedSessionModel extends BaseModel {
description: 'Current version number of this resource.',
})
version;
}
+2 -2
View File
@@ -24,13 +24,13 @@ export default class GeneratedTargetModel extends BaseModel {
@attr('number', {
description: '',
defaultValue: 28800
defaultValue: 28800,
})
session_max_seconds;
@attr('number', {
description: '',
defaultValue: 1
defaultValue: 1,
})
session_connection_limit;
-1
View File
@@ -4,7 +4,6 @@ import { computed } from '@ember/object';
import { equal } from '@ember/object/computed';
export default class AccountModel extends GeneratedAccountModel {
// =attributes
/**
-1
View File
@@ -25,7 +25,6 @@ import { computed } from '@ember/object';
* 2) Or as an ID: `record.scopeID`.
*/
export default class BaseModel extends Model {
// =relationships
/**
-1
View File
@@ -2,7 +2,6 @@ import GeneratedHostSetModel from '../generated/models/host-set';
import { fragmentArray } from 'ember-data-model-fragments/attributes';
export default class HostSetModel extends GeneratedHostSetModel {
// =attributes
/**
-2
View File
@@ -2,11 +2,9 @@ import GeneratedHostModel from '../generated/models/host';
import { fragment } from 'ember-data-model-fragments/attributes';
export default class HostModel extends GeneratedHostModel {
/**
* Attributes of this resource, if any, represented as a JSON fragment.
* @type {FragmentHostAttributesModel}
*/
@fragment('fragment-host-attributes', { defaultValue: {} }) attributes;
}
+1 -1
View File
@@ -35,7 +35,7 @@ export default class RoleModel extends GeneratedRoleModel {
return this.save({
adapterOptions: {
method: 'set-grants',
grantStrings
grantStrings,
},
});
}
-2
View File
@@ -4,7 +4,6 @@ import { equal } from '@ember/object/computed';
import { attr } from '@ember-data/model';
export default class SessionModel extends GeneratedSessionModel {
// =attributes
@attr('string', { readOnly: true }) proxy_address;
@@ -61,5 +60,4 @@ export default class SessionModel extends GeneratedSessionModel {
},
});
}
}
+6 -4
View File
@@ -41,8 +41,9 @@ export default class TargetModel extends GeneratedTargetModel {
* @type {SessionModel[]}
*/
get sessions() {
return this.store.peekAll('session')
.filter(s => s && (s.target_id === this.id));
return this.store
.peekAll('session')
.filter((s) => s && s.target_id === this.id);
}
/**
@@ -58,8 +59,9 @@ export default class TargetModel extends GeneratedTargetModel {
* @type {boolean}
*/
get isActive() {
const pendingOrActiveSessions =
this.sessions.filter(s => s.isActive || s.isPending);
const pendingOrActiveSessions = this.sessions.filter(
(s) => s.isActive || s.isPending
);
return Boolean(pendingOrActiveSessions.length);
}
-2
View File
@@ -3,7 +3,6 @@ import { attr } from '@ember-data/model';
import { A } from '@ember/array';
export default class UserModel extends GeneratedUserModel {
// =attributes
/**
@@ -74,5 +73,4 @@ export default class UserModel extends GeneratedUserModel {
removeAccount(accountID, options) {
return this.removeAccounts([accountID], options);
}
}
-1
View File
@@ -1,7 +1,6 @@
import ApplicationSerializer from './application';
export default class AccountSerializer extends ApplicationSerializer {
// =properties
/**
+1 -2
View File
@@ -7,7 +7,6 @@ import { copy } from 'ember-copy';
* Manages serialization/normalization of data to/from the API.
*/
export default class ApplicationSerializer extends RESTSerializer {
// =properties
/**
@@ -82,7 +81,7 @@ export default class ApplicationSerializer extends RESTSerializer {
// Delete `scope` field
delete serialized.scope;
// And serialize `scope_id`
if(this.serializeScopeID) {
if (this.serializeScopeID) {
const scope_id = snapshot?.attr('scope')?.attr('scope_id');
if (scope_id) serialized.scope_id = scope_id;
}
-1
View File
@@ -1,7 +1,6 @@
import ApplicationSerializer from './application';
export default class HostSetSerializer extends ApplicationSerializer {
// =properties
/**
-2
View File
@@ -1,12 +1,10 @@
import ApplicationSerializer from './application';
export default class HostSerializer extends ApplicationSerializer {
// =properties
/**
* @type {boolean}
*/
serializeScopeID = false;
}
+3 -3
View File
@@ -17,8 +17,8 @@ export default class RoleSerializer extends ApplicationSerializer {
serialize(snapshot) {
const grantStrings = get(snapshot, 'adapterOptions.grantStrings');
let serialized = super.serialize(...arguments);
if (grantStrings) serialized =
this.serializeWithGrantStrings(snapshot, grantStrings);
if (grantStrings)
serialized = this.serializeWithGrantStrings(snapshot, grantStrings);
const principalIDs = snapshot?.adapterOptions?.principalIDs;
if (principalIDs)
serialized = this.serializewithPrincipals(snapshot, principalIDs);
@@ -34,7 +34,7 @@ export default class RoleSerializer extends ApplicationSerializer {
serializeWithGrantStrings(snapshot, grantStrings) {
return {
version: snapshot.attr('version'),
grant_strings: grantStrings
grant_strings: grantStrings,
};
}
+2 -2
View File
@@ -13,8 +13,8 @@ export default class UserSerializer extends ApplicationSerializer {
serialize(snapshot) {
let serialized = super.serialize(...arguments);
const accountIDs = snapshot?.adapterOptions?.accountIDs;
if (accountIDs) serialized =
this.serializewithAccounts(snapshot, accountIDs);
if (accountIDs)
serialized = this.serializewithAccounts(snapshot, accountIDs);
return serialized;
}
+6 -6
View File
@@ -25,9 +25,9 @@ module.exports = async function () {
name: 'ember-lts-3.20',
npm: {
devDependencies: {
'ember-source': '~3.20.5'
}
}
'ember-source': '~3.20.5',
},
},
},
{
name: 'ember-release',
@@ -62,9 +62,9 @@ module.exports = async function () {
},
npm: {
devDependencies: {
'@ember/jquery': '^1.1.0'
}
}
'@ember/jquery': '^1.1.0',
},
},
},
{
name: 'ember-classic',
+268 -221
View File
@@ -5,8 +5,7 @@ import { pickRandomStatusString } from './factories/session';
import { Response } from 'miragejs';
import initializeMockIPC from './scenarios/ipc';
export default function() {
export default function () {
initializeMockIPC(this);
// make this `http://localhost:8080`, for example, if your API is on a different server
@@ -23,17 +22,20 @@ export default function() {
// Scope resources
this.get('/scopes', ({ scopes }, { queryParams: { scope_id, recursive } }) => {
// Default parent scope is global
if (!scope_id) scope_id = 'global';
if (recursive && scope_id === 'global') {
return scopes.all();
} else {
return scopes.where(scope => {
return scope.scope ? scope.scope.id === scope_id : false
});
this.get(
'/scopes',
({ scopes }, { queryParams: { scope_id, recursive } }) => {
// Default parent scope is global
if (!scope_id) scope_id = 'global';
if (recursive && scope_id === 'global') {
return scopes.all();
} else {
return scopes.where((scope) => {
return scope.scope ? scope.scope.id === scope_id : false;
});
}
}
});
);
this.post('/scopes', function ({ scopes }) {
// Parent scope comes through the payload via `scope_id`, but this needs
// to be expanded to a scope object `scope: {id:..., type:...}` before
@@ -49,41 +51,50 @@ export default function() {
// Auth & IAM resources
this.get('/auth-methods', ({ authMethods }, { queryParams: { scope_id: scopeId } }) => {
return authMethods.where({ scopeId });
});
this.get(
'/auth-methods',
({ authMethods }, { queryParams: { scope_id: scopeId } }) => {
return authMethods.where({ scopeId });
}
);
this.post('/auth-methods');
this.get('/auth-methods/:id');
this.patch('/auth-methods/:id');
this.del('/auth-methods/:id');
// Auth Method Accounts
this.get('/accounts', ({ accounts }, { queryParams: { auth_method_id: authMethodId } }) => {
return accounts.where({ authMethodId });
});
this.get(
'/accounts',
({ accounts }, { queryParams: { auth_method_id: authMethodId } }) => {
return accounts.where({ authMethodId });
}
);
this.post('/accounts');
this.get('/accounts/:id');
this.patch('/accounts/:id');
this.del('/accounts/:id');
this.post('/accounts/:idMethod', function ({ accounts }, { params: { idMethod } }) {
const attrs = this.normalizedRequestAttrs();
const id = idMethod.split(':')[0];
const method = idMethod.split(':')[1];
const account = accounts.find(id);
const updatedAttrs = {
version: attrs.version,
attributes: account.attributes
};
// Set new password
if (method === 'set-password') {
updatedAttrs.attributes.password = attrs.password;
this.post(
'/accounts/:idMethod',
function ({ accounts }, { params: { idMethod } }) {
const attrs = this.normalizedRequestAttrs();
const id = idMethod.split(':')[0];
const method = idMethod.split(':')[1];
const account = accounts.find(id);
const updatedAttrs = {
version: attrs.version,
attributes: account.attributes,
};
// Set new password
if (method === 'set-password') {
updatedAttrs.attributes.password = attrs.password;
}
// Set new password
if (method === 'change-password') {
updatedAttrs.attributes.password = attrs.new_password;
}
return account.update(updatedAttrs);
}
// Set new password
if (method === 'change-password') {
updatedAttrs.attributes.password = attrs.new_password;
}
return account.update(updatedAttrs);
});
);
// Authenticate/deauthenticate routes
this.post('/auth-methods/:id_method', authHandler);
@@ -104,11 +115,11 @@ export default function() {
const user = users.find(id);
const updatedAttrs = {
version: attrs.version,
accountIds: user.accountIds
accountIds: user.accountIds,
};
// If adding accounts, push them into the array
if (method === 'add-accounts') {
attrs.accountIds.forEach(id => {
attrs.accountIds.forEach((id) => {
if (!updatedAttrs.accountIds.includes(id)) {
updatedAttrs.accountIds.push(id);
}
@@ -116,7 +127,7 @@ export default function() {
}
// If deleting accounts, filter them out of the array
if (method === 'remove-accounts') {
updatedAttrs.accountIds = updatedAttrs.accountIds.filter(id => {
updatedAttrs.accountIds = updatedAttrs.accountIds.filter((id) => {
return !attrs.accountIds.includes(id);
});
}
@@ -131,31 +142,34 @@ export default function() {
this.get('/groups/:id');
this.patch('/groups/:id');
this.del('/groups/:id');
this.post('/groups/:idMethod', function ({ groups }, { params: { idMethod } }) {
const attrs = this.normalizedRequestAttrs();
const id = idMethod.split(':')[0];
const method = idMethod.split(':')[1];
const group = groups.find(id);
const updatedAttrs = {
version: attrs.version,
memberIds: group.memberIds
};
// If adding members, push them into the array
if (method === 'add-members') {
attrs.memberIds.forEach(id => {
if (!updatedAttrs.memberIds.includes(id)) {
updatedAttrs.memberIds.push(id);
}
});
this.post(
'/groups/:idMethod',
function ({ groups }, { params: { idMethod } }) {
const attrs = this.normalizedRequestAttrs();
const id = idMethod.split(':')[0];
const method = idMethod.split(':')[1];
const group = groups.find(id);
const updatedAttrs = {
version: attrs.version,
memberIds: group.memberIds,
};
// If adding members, push them into the array
if (method === 'add-members') {
attrs.memberIds.forEach((id) => {
if (!updatedAttrs.memberIds.includes(id)) {
updatedAttrs.memberIds.push(id);
}
});
}
// If deleting members, filter them out of the array
if (method === 'remove-members') {
updatedAttrs.memberIds = updatedAttrs.memberIds.filter((id) => {
return !attrs.memberIds.includes(id);
});
}
return group.update(updatedAttrs);
}
// If deleting members, filter them out of the array
if (method === 'remove-members') {
updatedAttrs.memberIds = updatedAttrs.memberIds.filter(id => {
return !attrs.memberIds.includes(id);
});
}
return group.update(updatedAttrs);
});
);
// IAM: Roles
this.get('/roles', ({ roles }, { queryParams: { scope_id: scopeId } }) => {
@@ -165,66 +179,72 @@ export default function() {
this.get('/roles/:id');
this.patch('/roles/:id');
this.del('/roles/:id');
this.post('/roles/:idMethod', function ({ roles, users, groups }, { params: { idMethod } }) {
const attrs = this.normalizedRequestAttrs();
const id = idMethod.split(':')[0];
const method = idMethod.split(':')[1];
const role = roles.find(id);
let updatedAttrs = {};
this.post(
'/roles/:idMethod',
function ({ roles, users, groups }, { params: { idMethod } }) {
const attrs = this.normalizedRequestAttrs();
const id = idMethod.split(':')[0];
const method = idMethod.split(':')[1];
const role = roles.find(id);
let updatedAttrs = {};
// Principals is a combined list of users and groups, but in Mirage we've
// internally modelled them as separate lists. Therefore we must check
// the type by looking up the user or group first, then determine which
// list to add the principal to.
if (method === 'add-principals') {
updatedAttrs = {
version: attrs.version,
userIds: role.userIds,
groupIds: role.groupIds
};
attrs.principalIds.forEach(id => {
const isUser = users.find(id);
const isGroup = groups.find(id);
if (isUser && !updatedAttrs.userIds.includes(id)) {
updatedAttrs.userIds.push(id);
}
if (isGroup && !updatedAttrs.groupIds.includes(id)) {
updatedAttrs.groupIds.push(id);
}
});
}
// If deleting principals, filter them out of both users and groups,
// and in this case don't care about the type
if (method === 'remove-principals') {
updatedAttrs = {
version: attrs.version,
userIds: role.userIds,
groupIds: role.groupIds
};
updatedAttrs.userIds = updatedAttrs.userIds.filter(id => {
return !attrs.principalIds.includes(id);
});
updatedAttrs.groupIds = updatedAttrs.groupIds.filter(id => {
return !attrs.principalIds.includes(id);
});
}
// Principals is a combined list of users and groups, but in Mirage we've
// internally modelled them as separate lists. Therefore we must check
// the type by looking up the user or group first, then determine which
// list to add the principal to.
if (method === 'add-principals') {
updatedAttrs = {
version: attrs.version,
userIds: role.userIds,
groupIds: role.groupIds,
};
attrs.principalIds.forEach((id) => {
const isUser = users.find(id);
const isGroup = groups.find(id);
if (isUser && !updatedAttrs.userIds.includes(id)) {
updatedAttrs.userIds.push(id);
}
if (isGroup && !updatedAttrs.groupIds.includes(id)) {
updatedAttrs.groupIds.push(id);
}
});
}
// If deleting principals, filter them out of both users and groups,
// and in this case don't care about the type
if (method === 'remove-principals') {
updatedAttrs = {
version: attrs.version,
userIds: role.userIds,
groupIds: role.groupIds,
};
updatedAttrs.userIds = updatedAttrs.userIds.filter((id) => {
return !attrs.principalIds.includes(id);
});
updatedAttrs.groupIds = updatedAttrs.groupIds.filter((id) => {
return !attrs.principalIds.includes(id);
});
}
if (method === 'set-grants') {
updatedAttrs = {
version: attrs.version,
grantStrings: attrs.grantStrings
};
}
if (method === 'set-grants') {
updatedAttrs = {
version: attrs.version,
grantStrings: attrs.grantStrings,
};
}
return role.update(updatedAttrs);
});
return role.update(updatedAttrs);
}
);
// Other resources
// host-catalog
this.get('/host-catalogs', ({ hostCatalogs }, { queryParams: { scope_id: scopeId } }) => {
return hostCatalogs.where({ scopeId });
});
this.get(
'/host-catalogs',
({ hostCatalogs }, { queryParams: { scope_id: scopeId } }) => {
return hostCatalogs.where({ scopeId });
}
);
this.post('/host-catalogs');
this.get('/host-catalogs/:id');
this.patch('/host-catalogs/:id');
@@ -232,9 +252,12 @@ export default function() {
// host
this.get('/hosts', function ({ hosts }, { queryParams: { host_catalog_id: hostCatalogId } }) {
return hosts.where({ hostCatalogId });
});
this.get(
'/hosts',
function ({ hosts }, { queryParams: { host_catalog_id: hostCatalogId } }) {
return hosts.where({ hostCatalogId });
}
);
this.post('/hosts', function ({ hostCatalogs, hosts }) {
const attrs = this.normalizedRequestAttrs();
const hostCatalog = hostCatalogs.find(attrs.hostCatalogId);
@@ -247,9 +270,15 @@ export default function() {
// host-set
this.get('/host-sets', function ({ hostSets }, { queryParams: { host_catalog_id: hostCatalogId } }) {
return hostSets.where({ hostCatalogId });
});
this.get(
'/host-sets',
function (
{ hostSets },
{ queryParams: { host_catalog_id: hostCatalogId } }
) {
return hostSets.where({ hostCatalogId });
}
);
this.post('/host-sets', function ({ hostCatalogs, hostSets }) {
const attrs = this.normalizedRequestAttrs();
const hostCatalog = hostCatalogs.find(attrs.hostCatalogId);
@@ -259,49 +288,57 @@ export default function() {
this.get('/host-sets/:id');
this.patch('/host-sets/:id');
this.del('/host-sets/:id');
this.post('/host-sets/:idMethod', function ({ hostSets }, { params: { idMethod } }) {
const attrs = this.normalizedRequestAttrs();
const id = idMethod.split(':')[0];
const method = idMethod.split(':')[1];
const hostSet = hostSets.find(id);
const updatedAttrs = {
version: attrs.version,
hostIds: hostSet.hostIds
}
this.post(
'/host-sets/:idMethod',
function ({ hostSets }, { params: { idMethod } }) {
const attrs = this.normalizedRequestAttrs();
const id = idMethod.split(':')[0];
const method = idMethod.split(':')[1];
const hostSet = hostSets.find(id);
const updatedAttrs = {
version: attrs.version,
hostIds: hostSet.hostIds,
};
// If adding hosts, push them into the array
if(method === 'add-hosts') {
attrs.hostIds.forEach(id => {
if(!updatedAttrs.hostIds.includes(id)) {
updatedAttrs.hostIds.push(id);
}
})
}
// If adding hosts, push them into the array
if (method === 'add-hosts') {
attrs.hostIds.forEach((id) => {
if (!updatedAttrs.hostIds.includes(id)) {
updatedAttrs.hostIds.push(id);
}
});
}
// If deleting hosts, filter them out of the array
if (method === 'remove-hosts') {
updatedAttrs.hostIds = updatedAttrs.hostIds.filter(id => {
return !attrs.hostIds.includes(id);
});
}
// If deleting hosts, filter them out of the array
if (method === 'remove-hosts') {
updatedAttrs.hostIds = updatedAttrs.hostIds.filter((id) => {
return !attrs.hostIds.includes(id);
});
}
return hostSet.update(updatedAttrs);
});
return hostSet.update(updatedAttrs);
}
);
// target
this.get('/targets', function ({ targets }, { queryParams: { scope_id, recursive } }) {
if (recursive && scope_id === 'global') {
return targets.all();
} else if (recursive) {
return targets.where(target => {
const targetModel = targets.find(target.id);
return (target.scopeId === scope_id)
|| (targetModel?.scope?.scope?.id === scope_id)
});
this.get(
'/targets',
function ({ targets }, { queryParams: { scope_id, recursive } }) {
if (recursive && scope_id === 'global') {
return targets.all();
} else if (recursive) {
return targets.where((target) => {
const targetModel = targets.find(target.id);
return (
target.scopeId === scope_id ||
targetModel?.scope?.scope?.id === scope_id
);
});
}
return targets.where((target) => target.scopeId === scope_id);
}
return targets.where(target => target.scopeId === scope_id);
});
);
this.post('/targets', function ({ targets }) {
const attrs = this.normalizedRequestAttrs();
return targets.create(attrs);
@@ -309,83 +346,93 @@ export default function() {
this.get('/targets/:id');
this.patch('/targets/:id');
this.del('/targets/:id');
this.post('/targets/:idMethod', function ({ targets }, { params: { idMethod } }) {
const attrs = this.normalizedRequestAttrs();
const id = idMethod.split(':')[0];
const method = idMethod.split(':')[1];
const target = targets.find(id);
const updatedAttrs = {
version: attrs.version,
hostSetIds: target.hostSetIds
};
// If adding host sets, push them into the array
if (method === 'add-host-sets') {
attrs.hostSetIds.forEach(id => {
if (!updatedAttrs.hostSetIds.includes(id)) {
updatedAttrs.hostSetIds.push(id);
}
});
this.post(
'/targets/:idMethod',
function ({ targets }, { params: { idMethod } }) {
const attrs = this.normalizedRequestAttrs();
const id = idMethod.split(':')[0];
const method = idMethod.split(':')[1];
const target = targets.find(id);
const updatedAttrs = {
version: attrs.version,
hostSetIds: target.hostSetIds,
};
// If adding host sets, push them into the array
if (method === 'add-host-sets') {
attrs.hostSetIds.forEach((id) => {
if (!updatedAttrs.hostSetIds.includes(id)) {
updatedAttrs.hostSetIds.push(id);
}
});
}
// If deleting host sets, filter them out of the array
if (method === 'remove-host-sets') {
updatedAttrs.hostSetIds = updatedAttrs.hostSetIds.filter((id) => {
return !attrs.hostSetIds.includes(id);
});
}
return target.update(updatedAttrs);
}
// If deleting host sets, filter them out of the array
if (method === 'remove-host-sets') {
updatedAttrs.hostSetIds = updatedAttrs.hostSetIds.filter(id => {
return !attrs.hostSetIds.includes(id);
});
}
return target.update(updatedAttrs);
});
);
// session
this.get('/sessions', function ({ sessions }, { queryParams: { scope_id, recursive } }) {
// To simulate changes to `session.status` that may occur in the backend,
// we quietly randomize the value of the field on GET.
// To populate sessions for logged in user,
// update alternate sessions to auth user.
// But only if not in testing mode.
// In tests, we need deterministic statuses.
if (!Ember.testing) {
sessions.all()
.models
.forEach(session => {
this.get(
'/sessions',
function ({ sessions }, { queryParams: { scope_id, recursive } }) {
// To simulate changes to `session.status` that may occur in the backend,
// we quietly randomize the value of the field on GET.
// To populate sessions for logged in user,
// update alternate sessions to auth user.
// But only if not in testing mode.
// In tests, we need deterministic statuses.
if (!Ember.testing) {
sessions.all().models.forEach((session) => {
session.update({
status: pickRandomStatusString()
});
if(session.id.split('-').pop() % 2) session.update({
userId: 'authenticateduser'
status: pickRandomStatusString(),
});
if (session.id.split('-').pop() % 2)
session.update({
userId: 'authenticateduser',
});
});
}
if (recursive && scope_id === 'global') {
return sessions.all();
} else if (recursive) {
return sessions.where((session) => {
const sessionModel = sessions.find(session.id);
return (
session.scopeId === scope_id ||
sessionModel?.scope?.scope?.id === scope_id
);
});
}
return sessions.where((session) => session.scopeId === scope_id);
}
if (recursive && scope_id === 'global') {
return sessions.all();
} else if (recursive) {
return sessions.where(session => {
const sessionModel = sessions.find(session.id);
return (session.scopeId === scope_id)
|| (sessionModel?.scope?.scope?.id === scope_id)
});
}
return sessions.where(session => session.scopeId === scope_id);
});
);
this.get('/sessions/:id', function ({ sessions }, { params: { id } }) {
const session = sessions.find(id);
return session.update({
status: pickRandomStatusString()
status: pickRandomStatusString(),
});
});
this.post('/sessions/:idMethod', function ({ sessions }, { params: { idMethod } }) {
const attrs = this.normalizedRequestAttrs();
const id = idMethod.split(':')[0];
const method = idMethod.split(':')[1];
const session = sessions.find(id);
const updatedAttrs = {
version: attrs.version
};
if (method === 'cancel') {
updatedAttrs.status = 'canceling';
this.post(
'/sessions/:idMethod',
function ({ sessions }, { params: { idMethod } }) {
const attrs = this.normalizedRequestAttrs();
const id = idMethod.split(':')[0];
const method = idMethod.split(':')[1];
const session = sessions.find(id);
const updatedAttrs = {
version: attrs.version,
};
if (method === 'cancel') {
updatedAttrs.status = 'canceling';
}
return session.update(updatedAttrs);
}
return session.update(updatedAttrs);
});
);
// auth-tokens
+3 -4
View File
@@ -10,11 +10,10 @@ export default factory.extend({
withAccountsAndUsers: trait({
afterCreate(authMethod, server) {
const { scope } = authMethod;
server.createList('user', 5, { scope }).map(user => {
server.createList('user', 5, { scope }).map((user) => {
const { id } = server.create('account', { scope, authMethod });
user.update({ accountIds: [id] });
});
}
})
},
}),
});
+2 -2
View File
@@ -13,6 +13,6 @@ export default factory.extend({
const scope = group.scope;
const members = server.createList('user', 2, { scope });
group.update({ members });
}
})
},
}),
});
+2 -4
View File
@@ -2,13 +2,11 @@ import factory from '../generated/factories/host-catalog';
import { trait } from 'ember-cli-mirage';
export default factory.extend({
withChildren: trait({
afterCreate(hostCatalog, server) {
const { scope } = hostCatalog;
const hosts = server.createList('host', 10, { scope, hostCatalog });
server.createList('host-set', 3, { scope, hostCatalog, hosts });
}
})
},
}),
});
+1 -1
View File
@@ -1,5 +1,5 @@
import factory from '../generated/factories/host-set';
export default factory.extend({
id: (i) => `host-set-id-${i}`
id: (i) => `host-set-id-${i}`,
});
+1 -1
View File
@@ -1,5 +1,5 @@
import factory from '../generated/factories/host';
export default factory.extend({
id: (i) => `host-id-${i}`
id: (i) => `host-id-${i}`,
});
+6 -6
View File
@@ -2,11 +2,10 @@ import factory from '../generated/factories/role';
import { trait } from 'ember-cli-mirage';
export default factory.extend({
// eslint-disable-next-line ember/avoid-leaking-state-in-ember-objects
grant_strings: () => [
'id=*;action=*',
'id=*;type=host-catalog;actions=create,read'
'id=*;type=host-catalog;actions=create,read',
],
/**
@@ -18,15 +17,16 @@ export default factory.extend({
const users = server.createList('user', 2, { scope });
const groups = server.createList('group', 2, { scope });
role.update({ users, groups });
}
},
}),
/**
* Set the grant scope ID to match the scope ID.
*/
afterCreate(role) {
const { scope: { id } } = role;
const {
scope: { id },
} = role;
role.update({ grant_scope_id: id });
}
},
});
+12 -9
View File
@@ -2,7 +2,6 @@ import factory from '../generated/factories/scope';
import { trait } from 'ember-cli-mirage';
export default factory.extend({
type: 'global',
/**
@@ -18,18 +17,22 @@ export default factory.extend({
withChildren: trait({
afterCreate(record, server) {
if (record.type === 'global') {
server.createList('scope', 1, {
type: 'org',
scope: { id: record.id, type: record.type }
}, 'withChildren');
server.createList(
'scope',
1,
{
type: 'org',
scope: { id: record.id, type: record.type },
},
'withChildren'
);
}
if (record.type === 'org') {
server.createList('scope', 3, {
type: 'project',
scope: { id: record.id, type: record.type }
scope: { id: record.id, type: record.type },
});
}
}
})
},
}),
});
+5 -11
View File
@@ -2,17 +2,11 @@ import factory from '../generated/factories/session';
import { trait } from 'ember-cli-mirage';
import { random } from 'faker';
const statusStrings = [
'pending',
'active',
'canceling',
'terminated'
];
const statusStrings = ['pending', 'active', 'canceling', 'terminated'];
export const pickRandomStatusString = () => random.arrayElement(statusStrings);
export default factory.extend({
id: (i) => `session-id-${i}`,
status: pickRandomStatusString,
@@ -26,7 +20,8 @@ export default factory.extend({
const scopeId = record.scopeId;
if (record.scope.type === 'project') {
const orgScopeId = record.scope?.scope.id;
const user = server.schema.users.where({ scopeId: orgScopeId }).models[0];
const user = server.schema.users.where({ scopeId: orgScopeId })
.models[0];
if (user) record.update({ user });
}
const target = server.schema.targets.where({ scopeId }).models[0];
@@ -39,7 +34,6 @@ export default factory.extend({
if (host) record.update({ host });
}
}
}
})
},
}),
});
+7 -9
View File
@@ -6,7 +6,6 @@ const randomBoolean = (chance = 0.5) => Math.random() < chance;
const hostSetChance = 0.3;
export default factory.extend({
/**
* -1 means "unlimited" and we want to generate these on occassion.
*/
@@ -19,8 +18,8 @@ export default factory.extend({
if (target.type === 'tcp') {
target.update({
attributes: {
default_port: random.number()
}
default_port: random.number(),
},
});
}
},
@@ -37,10 +36,9 @@ export default factory.extend({
// expect at this level of abstraction, but appears to be a serialized
// representation of the model instance. It's very confusing since
// the result set of `where` _is a collection of model instances_.
.where(hostSet => hostSet.scopeId === target.scope.id).models
.filter(() => randomBoolean(hostSetChance));
target.update({hostSets: randomlySelectedHostSets});
}
})
.where((hostSet) => hostSet.scopeId === target.scope.id)
.models.filter(() => randomBoolean(hostSetChance));
target.update({ hostSets: randomlySelectedHostSets });
},
}),
});
+1 -1
View File
@@ -1,5 +1,5 @@
import factory from '../generated/factories/user';
export default factory.extend({
id: (i) => `user-${i}`
id: (i) => `user-${i}`,
});
@@ -5,7 +5,6 @@ import { random, date } from 'faker';
* GeneratedAccountFactory
*/
export default Factory.extend({
type: 'password',
name: () => random.words(),
description: () => random.words(),
@@ -13,5 +12,4 @@ export default Factory.extend({
updated_time: () => date.recent(),
version: () => random.number(),
attributes: () => ({ login_name: random.words() }),
});
@@ -5,12 +5,10 @@ import { random, date } from 'faker';
* GeneratedAuthMethodModelFactory
*/
export default Factory.extend({
type: 'password',
name: () => random.words(),
description: () => random.words(),
created_time: () => date.recent(),
updated_time: () => date.recent(),
disabled: () => random.boolean(),
});
@@ -6,11 +6,9 @@ import { random, date } from 'faker';
* Group contains all fields related to a Group resource
*/
export default Factory.extend({
name: () => random.words(),
description: () => random.words(),
created_time: () => date.recent(),
updated_time: () => date.recent(),
disabled: () => random.boolean(),
});
@@ -5,12 +5,10 @@ import { random, date } from 'faker';
* GeneratedHostCatalogModelFactory
*/
export default Factory.extend({
type: 'static',
name: () => random.words(),
description: () => random.words(),
created_time: () => date.recent(),
updated_time: () => date.recent(),
disabled: () => random.boolean(),
});
@@ -5,7 +5,6 @@ import { random, date } from 'faker';
* GeneratedHostSetModelFactory
*/
export default Factory.extend({
type: 'static',
name: () => random.words(),
description: () => random.words(),
@@ -13,5 +12,4 @@ export default Factory.extend({
updated_time: () => date.recent(),
version: () => random.number(),
size: () => random.number(),
});
@@ -5,13 +5,13 @@ import { random, date, internet } from 'faker';
* GeneratedHostModelFactory
*/
export default Factory.extend({
type: 'static',
name: () => random.words(),
description: () => random.words(),
created_time: () => date.recent(),
updated_time: () => date.recent(),
version: () => random.number(),
attributes: () => { return { address: internet.ipv6() } },
attributes: () => {
return { address: internet.ipv6() };
},
});
@@ -6,10 +6,8 @@ import { random, date } from 'faker';
*
*/
export default Factory.extend({
name: () => random.words(),
description: () => random.words(),
created_time: () => date.recent(),
updated_time: () => date.recent(),
});
@@ -6,11 +6,9 @@ import { random, date } from 'faker';
* Project contains all fields related to a Project resource
*/
export default Factory.extend({
name: () => random.words(),
description: () => random.words(),
created_time: () => date.recent(),
updated_time: () => date.recent(),
disabled: () => random.boolean(),
});
@@ -6,12 +6,10 @@ import { random, date } from 'faker';
* Role contains all field related to a Role resource
*/
export default Factory.extend({
name: () => random.words(),
description: () => random.words(),
created_time: () => date.recent(),
updated_time: () => date.recent(),
disabled: () => random.boolean(),
version: () => random.number(),
});
@@ -5,11 +5,9 @@ import { random, date } from 'faker';
* GeneratedScopeModelFactory
*/
export default Factory.extend({
name: () => random.words(),
description: () => random.words(),
created_time: () => date.recent(),
updated_time: () => date.recent(),
disabled: () => random.boolean(),
});
@@ -5,10 +5,8 @@ import { random, date } from 'faker';
* GeneratedSessionModelFactory
*/
export default Factory.extend({
type: 'tcp',
created_time: () => date.recent(),
updated_time: () => date.recent(),
version: () => random.number(),
});
@@ -5,7 +5,6 @@ import { random, date } from 'faker';
* GeneratedTargetModelFactory
*/
export default Factory.extend({
type: 'tcp',
name: () => random.words(),
session_max_seconds: () => random.number(),
@@ -15,5 +14,4 @@ export default Factory.extend({
updated_time: () => date.recent(),
disabled: () => random.boolean(),
version: () => random.number(),
});
@@ -6,11 +6,9 @@ import { random, date } from 'faker';
* User contains all fields related to a User resource
*/
export default Factory.extend({
name: () => random.words(),
description: () => random.words(),
created_time: () => date.recent(),
updated_time: () => date.recent(),
disabled: () => random.boolean(),
});
+1 -3
View File
@@ -1,8 +1,6 @@
import { Model, belongsTo } from 'ember-cli-mirage';
export default Model.extend({
scope: belongsTo(),
authMethod: belongsTo()
authMethod: belongsTo(),
});
+1 -3
View File
@@ -1,7 +1,5 @@
import { Model, belongsTo } from 'ember-cli-mirage';
export default Model.extend({
scope: belongsTo()
scope: belongsTo(),
});
+1 -3
View File
@@ -1,8 +1,6 @@
import { Model, belongsTo, hasMany } from 'ember-cli-mirage';
export default Model.extend({
scope: belongsTo(),
members: hasMany('user')
members: hasMany('user'),
});
+1 -3
View File
@@ -1,8 +1,6 @@
import { Model, belongsTo, hasMany } from 'ember-cli-mirage';
export default Model.extend({
scope: belongsTo(),
hostSets: hasMany()
hostSets: hasMany(),
});
+1 -3
View File
@@ -1,10 +1,8 @@
import { Model, belongsTo, hasMany } from 'ember-cli-mirage';
export default Model.extend({
scope: belongsTo(),
target: belongsTo(),
hostCatalog: belongsTo(),
hosts: hasMany()
hosts: hasMany(),
});
+1 -3
View File
@@ -1,8 +1,6 @@
import { Model, belongsTo } from 'ember-cli-mirage';
export default Model.extend({
scope: belongsTo(),
hostCatalog: belongsTo()
hostCatalog: belongsTo(),
});
+1 -3
View File
@@ -1,9 +1,7 @@
import { Model, belongsTo, hasMany } from 'ember-cli-mirage';
export default Model.extend({
scope: belongsTo(),
users: hasMany(),
groups: hasMany()
groups: hasMany(),
});
-2
View File
@@ -1,11 +1,9 @@
import { Model, belongsTo } from 'ember-cli-mirage';
export default Model.extend({
scope: belongsTo(),
user: belongsTo(),
target: belongsTo(),
host: belongsTo(),
hostSet: belongsTo(),
});
+1 -3
View File
@@ -1,8 +1,6 @@
import { Model, belongsTo, hasMany } from 'ember-cli-mirage';
export default Model.extend({
scope: belongsTo(),
hostSets: hasMany()
hostSets: hasMany(),
});
+1 -3
View File
@@ -1,8 +1,6 @@
import { Model, belongsTo, hasMany } from 'ember-cli-mirage';
export default Model.extend({
scope: belongsTo(),
accounts: hasMany('account')
accounts: hasMany('account'),
});
+17 -14
View File
@@ -31,20 +31,23 @@ export function authHandler({ scopes, authMethods }, request) {
const id = request.params.id_method.split(':')[0];
const authMethod = authMethods.find(id);
const scope = scopes.find(authMethod.scopeId);
const scopeAttrs =
this.serialize(scopes.find(scope.id));
return new Response(200, {}, {
scope: scopeAttrs,
id: 'token123',
token: 'thetokenstring',
account_id: '1',
user_id: 'authenticateduser',
auth_method_id: 'authmethod123',
created_time: '',
updated_time: '',
last_used_time: '',
expiration_time: ''
});
const scopeAttrs = this.serialize(scopes.find(scope.id));
return new Response(
200,
{},
{
scope: scopeAttrs,
id: 'token123',
token: 'thetokenstring',
account_id: '1',
user_id: 'authenticateduser',
auth_method_id: 'authmethod123',
created_time: '',
updated_time: '',
last_used_time: '',
expiration_time: '',
}
);
}
}
+24 -10
View File
@@ -1,23 +1,37 @@
export default function(server) {
export default function (server) {
// Scope resources
// creates a global scope
const globalScope = server.create('scope', {
id: 'global',
type: 'global',
name: 'Global'
name: 'Global',
});
const orgScope = server.createList('scope', 3, {
type: 'org',
scope: { id: globalScope.id, type: globalScope.type }
}, 'withChildren')[0];
const orgScope = server.createList(
'scope',
3,
{
type: 'org',
scope: { id: globalScope.id, type: globalScope.type },
},
'withChildren'
)[0];
server.create('user', { id: 'authenticateduser' });
// Auth
server.createList('auth-method', 1, { scope: globalScope }, 'withAccountsAndUsers');
server.createList('auth-method', 3, { scope: orgScope }, 'withAccountsAndUsers');
server.createList(
'auth-method',
1,
{ scope: globalScope },
'withAccountsAndUsers'
);
server.createList(
'auth-method',
3,
{ scope: orgScope },
'withAccountsAndUsers'
);
// Groups and Users
server.createList('group', 1, { scope: globalScope }, 'withMembers');
@@ -27,7 +41,7 @@ export default function(server) {
server.createList('role', 5, { scope: orgScope }, 'withPrincipals');
// Other resources
server.schema.scopes.where({type: 'project'}).models.forEach(scope => {
server.schema.scopes.where({ type: 'project' }).models.forEach((scope) => {
server.createList('host-catalog', 2, { scope }, 'withChildren');
server.createList('target', 2, { scope }, 'withRandomHostSets');
server.createList('session', 4, { scope }, 'withAssociations');
+3 -4
View File
@@ -2,7 +2,7 @@ import Ember from 'ember';
import config from 'ember-get-config';
import { random } from 'faker';
export default function initializeMockIPC (server) {
export default function initializeMockIPC(server) {
/**
* We strive to make this application runnable in a regular web browser, since
* it is a convenient environment for development and testing. But only an
@@ -51,13 +51,13 @@ export default function initializeMockIPC (server) {
target,
userId: 'authenticateduser',
type,
created_time: new Date().toISOString()
created_time: new Date().toISOString(),
});
return {
address: window.location.hostname,
port: random.number(),
protocol: type,
session_id: newSession.id
session_id: newSession.id,
};
}
}
@@ -80,5 +80,4 @@ export default function initializeMockIPC (server) {
}
});
}
}
+5 -2
View File
@@ -4,9 +4,12 @@ export default ApplicationSerializer.extend({
modelName: 'account',
_hashForModel(model) {
const json = ApplicationSerializer.prototype._hashForModel.apply(this, arguments);
const json = ApplicationSerializer.prototype._hashForModel.apply(
this,
arguments
);
json.auth_method_id = model.authMethodId;
delete json.attributes?.password;
return json;
}
},
});
+3 -5
View File
@@ -6,7 +6,6 @@ import { isArray } from '@ember/array';
* Manages serialization/normalization of data into and out of the mock API.
*/
export default RestSerializer.extend({
// =attributes
/**
@@ -45,7 +44,7 @@ export default RestSerializer.extend({
serialize() {
let json = RestSerializer.prototype.serialize.apply(this, arguments);
// If array, root it under a standard `items` key
if (isArray(json)) json = {items: json};
if (isArray(json)) json = { items: json };
return json;
},
@@ -59,7 +58,7 @@ export default RestSerializer.extend({
if (model.scope) {
json.scope = {
id: model.scope.id,
type: model.scope.type
type: model.scope.type,
};
}
return json;
@@ -79,6 +78,5 @@ export default RestSerializer.extend({
}
const value = RestSerializer.prototype.normalize.apply(this, [newJSON]);
return value;
}
},
});
+1 -1
View File
@@ -1,5 +1,5 @@
import ApplicationSerializer from './application';
export default ApplicationSerializer.extend({
modelName: 'auth-method'
modelName: 'auth-method',
});
+5 -3
View File
@@ -11,9 +11,11 @@ export default ApplicationSerializer.extend({
},
_hashForModel(model) {
const json = ApplicationSerializer.prototype._hashForModel.apply(this, arguments);
const json = ApplicationSerializer.prototype._hashForModel.apply(
this,
arguments
);
if (model.memberIds.length) json.member_ids = model.memberIds;
return json;
}
},
});
+5 -3
View File
@@ -11,12 +11,14 @@ export default ApplicationSerializer.extend({
},
_hashForModel(model) {
const json = ApplicationSerializer.prototype._hashForModel.apply(this, arguments);
const json = ApplicationSerializer.prototype._hashForModel.apply(
this,
arguments
);
json.host_catalog_id = model.hostCatalogId;
if (model.hostIds?.length) {
json.host_ids = model.hostIds;
}
return json;
}
},
});
+1 -1
View File
@@ -1,5 +1,5 @@
import ApplicationSerializer from './application';
export default ApplicationSerializer.extend({
modelName: 'host'
modelName: 'host',
});
+10 -7
View File
@@ -4,23 +4,26 @@ export default ApplicationSerializer.extend({
modelName: 'role',
_hashForModel(model) {
const json = ApplicationSerializer.prototype._hashForModel.apply(this, arguments);
const serializedUsers = model.users.models.map(user => ({
const json = ApplicationSerializer.prototype._hashForModel.apply(
this,
arguments
);
const serializedUsers = model.users.models.map((user) => ({
scope_id: model.scope.id,
id: user.id,
type: 'user'
type: 'user',
}));
const serializedGroups = model.groups.models.map(group => ({
const serializedGroups = model.groups.models.map((group) => ({
scope_id: model.scope.id,
id: group.id,
type: 'group'
type: 'group',
}));
json.principals = [ ...serializedUsers, ...serializedGroups ];
json.principals = [...serializedUsers, ...serializedGroups];
if (!json.principals.length) delete json.principals;
// default grant scope
if (!json.grant_scope_id) json.grant_scope_id = json.scope.id;
return json;
}
},
});
+1 -1
View File
@@ -1,5 +1,5 @@
import ApplicationSerializer from './application';
export default ApplicationSerializer.extend({
modelName: 'scope'
modelName: 'scope',
});
+5 -3
View File
@@ -11,12 +11,14 @@ export default ApplicationSerializer.extend({
},
_hashForModel(model) {
const json = ApplicationSerializer.prototype._hashForModel.apply(this, arguments);
const json = ApplicationSerializer.prototype._hashForModel.apply(
this,
arguments
);
json.user_id = model.userId;
json.target_id = model.targetId;
json.host_set_id = model.hostSetId;
json.host_id = model.hostId;
return json;
}
},
});
+6 -4
View File
@@ -11,16 +11,18 @@ export default ApplicationSerializer.extend({
},
_hashForModel(model) {
const json = ApplicationSerializer.prototype._hashForModel.apply(this, arguments);
const json = ApplicationSerializer.prototype._hashForModel.apply(
this,
arguments
);
const { hostSets } = this.schema;
if (model.hostSetIds?.length) {
json.host_sets = model.hostSetIds.map(host_set_id => {
json.host_sets = model.hostSetIds.map((host_set_id) => {
const hostSet = hostSets.find(host_set_id);
const host_catalog_id = hostSet?.hostCatalog?.id;
return { id: host_set_id, host_catalog_id };
});
}
return json;
}
},
});
+5 -2
View File
@@ -11,8 +11,11 @@ export default ApplicationSerializer.extend({
},
_hashForModel(model) {
const json = ApplicationSerializer.prototype._hashForModel.apply(this, arguments);
const json = ApplicationSerializer.prototype._hashForModel.apply(
this,
arguments
);
if (model.accountIds.length) json.account_ids = model.accountIds;
return json;
}
},
});
+31 -22
View File
@@ -10,56 +10,65 @@
"scripts": {
"build:development": "ember build",
"build": "ember build --environment=production",
"lint": "npm-run-all --aggregate-output --continue-on-error --parallel lint:*",
"lint": "npm-run-all --aggregate-output --continue-on-error --parallel 'lint:!(fix)'",
"lint:fix": "npm-run-all --aggregate-output --continue-on-error --parallel lint:*:fix",
"lint:hbs": "ember-template-lint .",
"lint:hbs:fix": "ember-template-lint . --fix",
"lint:js": "eslint .",
"lint:js:fix": "eslint . --fix",
"format": "npm run format:js",
"format:js": "prettier --write '{addon,app,config,stories,tests}/**/*.js' *.js",
"format:js": "prettier --write '{addon,app,config,stories,tests,mirage}/**/*.js' *.js",
"start": "ember serve",
"test": "ember test",
"test:ember-compatibility": "ember try:each",
"doc:toc": "doctoc README.md"
},
"dependencies": {
"ember-cli-babel": "^7.21.0",
"ember-cli-htmlbars": "^5.2.0",
"ember-cli-babel": "^7.23.0",
"ember-cli-htmlbars": "^5.3.1",
"ember-cli-mirage": "^1.1.8",
"ember-data": "^3.20.0",
"ember-data-model-fragments": "5.0.0-beta.0",
"ember-fetch": "^8.0.1",
"ember-cli-mirage": "^1.1.8"
"ember-fetch": "^8.0.1"
},
"devDependencies": {
"@ember/optional-features": "^1.3.0",
"@glimmer/component": "^1.0.1",
"@glimmer/tracking": "^1.0.0",
"@ember/optional-features": "^2.0.0",
"@ember/test-helpers": "^2.1.4",
"@glimmer/component": "^1.0.3",
"@glimmer/tracking": "^1.0.3",
"babel-eslint": "^10.1.0",
"broccoli-asset-rev": "^3.0.0",
"doctoc": "^1.4.0",
"ember-auto-import": "^1.6.0",
"ember-cli": "~3.20.2",
"ember-auto-import": "^1.10.1",
"ember-cli": "~3.24.0",
"ember-cli-dependency-checker": "^3.2.0",
"ember-cli-inject-live-reload": "^2.0.2",
"ember-cli-sri": "^2.1.1",
"ember-cli-uglify": "^3.0.0",
"ember-cli-terser": "^4.0.1",
"ember-cli-update": "^0.54.6",
"ember-copy": "^1.0.0",
"ember-disable-prototype-extensions": "^1.1.3",
"ember-export-application-global": "^2.0.1",
"ember-get-config": "^0.3.0",
"ember-load-initializers": "^2.1.1",
"ember-load-initializers": "^2.1.2",
"ember-maybe-import-regenerator": "^0.1.6",
"ember-qunit": "^4.6.0",
"ember-resolver": "^8.0.0",
"ember-source": "~3.20.2",
"ember-source-channel-url": "^2.0.1",
"ember-template-lint": "^2.9.1",
"ember-page-title": "^6.0.3",
"ember-qunit": "^5.1.1",
"ember-resolver": "^8.0.2",
"ember-source": "~3.24.0",
"ember-source-channel-url": "^3.0.0",
"ember-template-lint": "^2.15.0",
"ember-try": "^1.4.0",
"eslint": "^7.5.0",
"eslint-plugin-ember": "^8.9.1",
"eslint": "^7.17.0",
"eslint-config-prettier": "^7.1.0",
"eslint-plugin-ember": "^10.1.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.3.1",
"loader.js": "^4.7.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.0.5",
"qunit-dom": "^1.2.0"
"prettier": "^2.2.1",
"qunit": "^2.13.0",
"qunit-dom": "^1.6.0"
},
"engines": {
"node": "10.* || >= 12"
@@ -1,3 +1,5 @@
{{page-title "Dummy"}}
<h2 id="title">Welcome to Ember</h2>
{{outlet}}
@@ -3,7 +3,7 @@
"packages": [
{
"name": "ember-cli",
"version": "3.20.2",
"version": "3.24.0",
"blueprints": [
{
"name": "addon",
+7
View File
@@ -21,6 +21,13 @@
{{content-for "body"}}
{{content-for "test-body"}}
<div id="qunit"></div>
<div id="qunit-fixture">
<div id="ember-testing-container">
<div id="ember-testing"></div>
</div>
</div>
<script src="/testem.js" integrity=""></script>
<script src="{{rootURL}}assets/vendor.js"></script>
<script src="{{rootURL}}assets/test-support.js"></script>
+4
View File
@@ -1,8 +1,12 @@
import Application from 'dummy/app';
import config from 'dummy/config/environment';
import * as QUnit from 'qunit';
import { setApplication } from '@ember/test-helpers';
import { setup } from 'qunit-dom';
import { start } from 'ember-qunit';
setApplication(Application.create(config.APP));
setup(QUnit.assert);
start();
@@ -9,7 +9,7 @@ module('Unit | Mixin | build-url', function (hooks) {
test('it does not interfere with basic URLs', function (assert) {
assert.expect(1);
/* eslint-disable-next-line ember/no-new-mixins */
/* eslint-disable-next-line ember/no-new-mixins, ember/no-classic-classes */
const Adapter = RESTAdapter.extend(AdapterBuildURLMixin);
this.owner.register('adapter:adapter', Adapter);
const adapter = this.owner.lookup('adapter:adapter');
@@ -19,7 +19,7 @@ module('Unit | Mixin | build-url', function (hooks) {
test('it does not interfere with namespaced URLs', function (assert) {
assert.expect(1);
/* eslint-disable-next-line ember/no-new-mixins */
/* eslint-disable-next-line ember/no-new-mixins, ember/no-classic-classes */
const Adapter = RESTAdapter.extend(AdapterBuildURLMixin, {
namespace: 'api/v1',
});
@@ -31,7 +31,7 @@ module('Unit | Mixin | build-url', function (hooks) {
test('it can prepend a prefix', function (assert) {
assert.expect(1);
/* eslint-disable-next-line ember/no-new-mixins */
/* eslint-disable-next-line ember/no-new-mixins, ember/no-classic-classes */
const Adapter = RESTAdapter.extend(AdapterBuildURLMixin, {
urlPrefix() {
return '/foo/bars';
@@ -45,7 +45,7 @@ module('Unit | Mixin | build-url', function (hooks) {
test('it can append a suffix', function (assert) {
assert.expect(1);
/* eslint-disable-next-line ember/no-new-mixins */
/* eslint-disable-next-line ember/no-new-mixins, ember/no-classic-classes */
const Adapter = RESTAdapter.extend(AdapterBuildURLMixin, {
urlSuffix() {
return ':method';
@@ -21,5 +21,4 @@ module('Unit | Model | account', function (hooks) {
model.attributes.login_name = 'username';
assert.equal(model.username, 'username');
});
});
@@ -1,11 +1,11 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Model | auth token', function(hooks) {
module('Unit | Model | auth token', function (hooks) {
setupTest(hooks);
// Replace this with your real tests.
test('it exists', function(assert) {
test('it exists', function (assert) {
let store = this.owner.lookup('service:store');
let model = store.createRecord('auth-token', {});
assert.ok(model);
+4 -16
View File
@@ -24,10 +24,7 @@ module('Unit | Model | host set', function (hooks) {
attributes: {
name: 'Host Set',
description: 'Description',
host_ids: [
{value: '1'},
{value: '3'},
],
host_ids: [{ value: '1' }, { value: '3' }],
version: 1,
scope: {
scope_id: 'o_1',
@@ -58,10 +55,7 @@ module('Unit | Model | host set', function (hooks) {
attributes: {
name: 'Host Set',
description: 'Description',
host_ids: [
{value: '1'},
{value: '3'},
],
host_ids: [{ value: '1' }, { value: '3' }],
version: 1,
scope: {
scope_id: 'o_1',
@@ -92,10 +86,7 @@ module('Unit | Model | host set', function (hooks) {
attributes: {
name: 'Host Set',
description: 'Description',
host_ids: [
{value: '1'},
{value: '3'},
],
host_ids: [{ value: '1' }, { value: '3' }],
version: 1,
scope: {
scope_id: 'o_1',
@@ -126,10 +117,7 @@ module('Unit | Model | host set', function (hooks) {
attributes: {
name: 'Host Set',
description: 'Description',
host_ids: [
{value: '1'},
{value: '3'},
],
host_ids: [{ value: '1' }, { value: '3' }],
version: 1,
scope: {
scope_id: 'o_1',
+9 -9
View File
@@ -1,28 +1,28 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Model | session', function(hooks) {
module('Unit | Model | session', function (hooks) {
setupTest(hooks);
test('it exists', function(assert) {
test('it exists', function (assert) {
let store = this.owner.lookup('service:store');
let model = store.createRecord('session', {});
assert.ok(model);
assert.notOk(model.isCancelable);
});
test('it allows cancellation of an active session', function(assert) {
test('it allows cancellation of an active session', function (assert) {
let store = this.owner.lookup('service:store');
let model = store.createRecord('session', {
status: 'active'
status: 'active',
});
assert.ok(model.isCancelable);
});
test('it allows cancellation of a pending session', function(assert) {
test('it allows cancellation of a pending session', function (assert) {
let store = this.owner.lookup('service:store');
let model = store.createRecord('session', {
status: 'pending'
status: 'pending',
});
assert.ok(model.isCancelable);
});
@@ -31,7 +31,7 @@ module('Unit | Model | session', function(hooks) {
assert.expect(2);
let store = this.owner.lookup('service:store');
let model = store.createRecord('session', {
status: 'pending'
status: 'pending',
});
assert.notOk(model.isActive);
model.status = 'active';
@@ -42,7 +42,7 @@ module('Unit | Model | session', function(hooks) {
assert.expect(2);
let store = this.owner.lookup('service:store');
let model = store.createRecord('session', {
status: 'active'
status: 'active',
});
assert.notOk(model.isPending);
model.status = 'pending';
@@ -55,7 +55,7 @@ module('Unit | Model | session', function(hooks) {
assert.equal(model.proxy, null);
model.setProperties({
proxy_address: 'localhost',
proxy_port: '12345'
proxy_port: '12345',
});
assert.equal(model.proxy, 'localhost:12345');
});
+14 -10
View File
@@ -186,33 +186,37 @@ module('Unit | Model | target', function (hooks) {
store.push({
data: {
id: '123abc',
type: 'target'
}
type: 'target',
},
});
const target = store.peekRecord('target', '123abc');
assert.equal( target.sessions.length, 0);
assert.equal(target.sessions.length, 0);
store.push({
data: {
id: '1',
type: 'session',
attributes: { target_id: '123abc' }
}
attributes: { target_id: '123abc' },
},
});
store.push({
data: {
id: '2',
type: 'session',
attributes: { target_id: '123abc' }
}
attributes: { target_id: '123abc' },
},
});
store.push({
data: {
id: '3',
type: 'session',
attributes: { target_id: '456xyz' }
}
attributes: { target_id: '456xyz' },
},
});
assert.equal(store.peekAll('session').length, 3, 'There are 3 sessions loaded in the store');
assert.equal(
store.peekAll('session').length,
3,
'There are 3 sessions loaded in the store'
);
assert.equal(
target.sessions.length,
2,
@@ -66,7 +66,7 @@ module('Unit | Serializer | application', function (hooks) {
const serializedRecord = serializer.serialize(snapshot);
assert.deepEqual(serializedRecord, {
name: 'User',
description: 'Description'
description: 'Description',
});
});
@@ -172,7 +172,7 @@ module('Unit | Serializer | application', function (hooks) {
attributes: {
name: 'User 1',
account_ids: [],
scope: { scope_id: 'o_123' }
scope: { scope_id: 'o_123' },
},
relationships: {},
},
@@ -1,18 +1,18 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Serializer | host', function(hooks) {
module('Unit | Serializer | host', function (hooks) {
setupTest(hooks);
// Replace this with your real tests.
test('it exists', function(assert) {
test('it exists', function (assert) {
let store = this.owner.lookup('service:store');
let serializer = store.serializerFor('host');
assert.ok(serializer);
});
test('it serializes records', function(assert) {
test('it serializes records', function (assert) {
let store = this.owner.lookup('service:store');
let record = store.createRecord('host', {});
@@ -21,7 +21,7 @@ module('Unit | Serializer | role', function (hooks) {
name: 'User',
description: 'Description',
version: 1,
grant_scope_id: null
grant_scope_id: null,
});
});
@@ -1,11 +1,11 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Serializer | session', function(hooks) {
module('Unit | Serializer | session', function (hooks) {
setupTest(hooks);
// Replace this with your real tests.
test('it exists', function(assert) {
test('it exists', function (assert) {
let store = this.owner.lookup('service:store');
let serializer = store.serializerFor('session');
@@ -20,7 +20,7 @@ module('Unit | Serializer | target', function (hooks) {
type: 'org',
},
version: 1,
type: 'tcp'
type: 'tcp',
});
const snapshot = record._createSnapshot();
snapshot.adapterOptions = {};
@@ -55,11 +55,7 @@ module('Unit | Serializer | user', function (hooks) {
name: 'user 1',
scope: { id: 'o_123' },
};
const normalized = serializer.normalizeSingleResponse(
store,
user,
payload
);
const normalized = serializer.normalizeSingleResponse(store, user, payload);
assert.deepEqual(normalized, {
included: [],
data: {
+1
View File
@@ -13,6 +13,7 @@
# misc
/coverage/
!.*
.eslintcache
# ember-try
/.node_modules.ember-try/
+21 -15
View File
@@ -7,48 +7,54 @@ module.exports = {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
legacyDecorators: true
}
legacyDecorators: true,
},
},
plugins: [
'ember'
],
plugins: ['ember'],
extends: [
'eslint:recommended',
'plugin:ember/recommended'
'plugin:ember/recommended',
'plugin:prettier/recommended',
],
env: {
browser: true
browser: true,
},
rules: {
'ember/no-get': 'off',
'ember/no-get-with-default': 'off',
'ember/no-computed-properties-in-native-classes': 'off',
'ember/no-assignment-of-untracked-properties-used-in-tracking-contexts':
'off',
},
rules: {},
overrides: [
// node files
{
files: [
'.eslintrc.js',
'.prettierrc.js',
'.template-lintrc.js',
'ember-cli-build.js',
'index.js',
'testem.js',
'blueprints/*/index.js',
'config/**/*.js',
'tests/dummy/config/**/*.js'
'tests/dummy/config/**/*.js',
],
excludedFiles: [
'addon/**',
'addon-test-support/**',
'app/**',
'tests/dummy/app/**'
'tests/dummy/app/**',
],
parserOptions: {
sourceType: 'script'
sourceType: 'script',
},
env: {
browser: false,
node: true
node: true,
},
plugins: ['node'],
extends: ['plugin:node/recommended']
}
]
extends: ['plugin:node/recommended'],
},
],
};
+1
View File
@@ -10,6 +10,7 @@
/.editorconfig
/.ember-cli
/.env*
/.eslintcache
/.eslintignore
/.eslintrc.js
/.git/
+21
View File
@@ -0,0 +1,21 @@
# unconventional js
/blueprints/*/files/
/vendor/
# compiled output
/dist/
/tmp/
# dependencies
/bower_components/
/node_modules/
# misc
/coverage/
!.*
.eslintcache
# ember-try
/.node_modules.ember-try/
/bower.json.ember-try
/package.json.ember-try
+5
View File
@@ -0,0 +1,5 @@
'use strict';
module.exports = {
singleQuote: true,
};
+1 -1
View File
@@ -1,5 +1,5 @@
'use strict';
module.exports = {
extends: 'octane'
extends: 'octane',
};
+8 -7
View File
@@ -15,7 +15,7 @@ export default class BaseAuthenticator extends SimpleAuthBaseAuthenticator {
* @param {string} scopeID
* @return {string}
*/
buildDeauthEndpointURL(/* { scope: { id: scopeID } } */) { }
buildDeauthEndpointURL(/* { scope: { id: scopeID } } */) {}
/**
* Generates an auth token validation URL used to check tokens on restoration.
@@ -23,7 +23,7 @@ export default class BaseAuthenticator extends SimpleAuthBaseAuthenticator {
* @param {string} tokenID
* @return {string}
*/
buildTokenValidationEndpointURL(/* tokenID */) { }
buildTokenValidationEndpointURL(/* tokenID */) {}
// =methods
@@ -34,7 +34,7 @@ export default class BaseAuthenticator extends SimpleAuthBaseAuthenticator {
const tokenValidationURL = this.buildTokenValidationEndpointURL(tokenID);
const response = await fetch(tokenValidationURL, {
method: 'get',
headers: { 'Authorization': `Bearer ${token}` }
headers: { Authorization: `Bearer ${token}` },
});
// 401 and 404 responses mean the token is invalid, whereas other types of
// error responses do not tell us about the validity of the token.
@@ -51,8 +51,9 @@ export default class BaseAuthenticator extends SimpleAuthBaseAuthenticator {
*/
async restore(data) {
if (!data) return reject();
return this.validateToken(data.token, data.id)
.then(() => this.normalizeData(data));
return this.validateToken(data.token, data.id).then(() =>
this.normalizeData(data)
);
}
/**
@@ -65,8 +66,8 @@ export default class BaseAuthenticator extends SimpleAuthBaseAuthenticator {
*/
normalizeData(data, username) {
// Add booleans indicated the scope type
data.isGlobal = (data?.scope?.type === 'global');
data.isOrg = (data?.scope?.type === 'org');
data.isGlobal = data?.scope?.type === 'global';
data.isOrg = data?.scope?.type === 'org';
if (username) data.username = username;
return data;
}
+1 -2
View File
@@ -34,7 +34,6 @@ import fetch from 'fetch';
*
*/
export default class PasswordAuthenticator extends BaseAuthenticator {
// =unimplemented methods
/**
@@ -48,7 +47,7 @@ export default class PasswordAuthenticator extends BaseAuthenticator {
buildAuthEndpointURL(/* {
scope: { id: scopeID },
authMethod: { id: authMethodID },
} */) { }
} */) {}
// =methods
@@ -75,6 +75,9 @@ export default class CookieSessionStore extends BaseSessionStore {
* present. If either one is missing, we want to cleanup to be sure they
* are both absent.
*/
// The base class is a classic Ember class, but the linter doesn't know that.
// That's why this rule is disabled here.
/* eslint-disable-next-line ember/classic-decorator-hooks */
init() {
if (!this.sessionExists) this.clear();
}
+6 -14
View File
@@ -6,14 +6,6 @@ module.exports = async function () {
return {
useYarn: true,
scenarios: [
{
name: 'ember-lts-3.12',
npm: {
devDependencies: {
'ember-source': '~3.12.0',
},
},
},
{
name: 'ember-lts-3.16',
npm: {
@@ -26,9 +18,9 @@ module.exports = async function () {
name: 'ember-lts-3.20',
npm: {
devDependencies: {
'ember-source': '~3.20.5'
}
}
'ember-source': '~3.20.5',
},
},
},
{
name: 'ember-release',
@@ -63,9 +55,9 @@ module.exports = async function () {
},
npm: {
devDependencies: {
'@ember/jquery': '^1.1.0'
}
}
'@ember/jquery': '^1.1.0',
},
},
},
{
name: 'ember-classic',
+28 -20
View File
@@ -8,53 +8,61 @@
"ember-addon"
],
"scripts": {
"lint": "npm-run-all --aggregate-output --continue-on-error --parallel lint:*",
"lint": "npm-run-all --aggregate-output --continue-on-error --parallel 'lint:!(fix)'",
"lint:fix": "npm-run-all --aggregate-output --continue-on-error --parallel lint:*:fix",
"lint:hbs:fix": "ember-template-lint . --fix",
"lint:js": "eslint .",
"format": "npm run format:js",
"format:js": "prettier --write '{addon,app,config,stories,tests}/**/*.js' *.js",
"lint:js:fix": "eslint . --fix",
"start": "ember serve",
"test": "ember test",
"test:ember-compatibility": "ember try:each",
"doc:toc": "doctoc README.md"
},
"dependencies": {
"ember-cli-babel": "^7.21.0",
"ember-cli-htmlbars": "^5.2.0",
"ember-cli-babel": "^7.23.0",
"ember-cli-htmlbars": "^5.3.1",
"ember-simple-auth": "^3.0.1"
},
"devDependencies": {
"core": "*",
"@ember/optional-features": "^1.3.0",
"@glimmer/component": "^1.0.1",
"@glimmer/tracking": "^1.0.0",
"@ember/optional-features": "^2.0.0",
"@ember/test-helpers": "^2.1.4",
"@glimmer/component": "^1.0.3",
"@glimmer/tracking": "^1.0.3",
"babel-eslint": "^10.1.0",
"broccoli-asset-rev": "^3.0.0",
"core": "*",
"doctoc": "^1.4.0",
"ember-auto-import": "^1.6.0",
"ember-cli": "~3.20.2",
"ember-auto-import": "^1.10.1",
"ember-cli": "~3.24.0",
"ember-cli-dependency-checker": "^3.2.0",
"ember-cli-inject-live-reload": "^2.0.2",
"ember-cli-sri": "^2.1.1",
"ember-cli-uglify": "^3.0.0",
"ember-cli-terser": "^4.0.1",
"ember-cli-update": "^0.54.6",
"ember-cookies": "^0.5.2",
"ember-disable-prototype-extensions": "^1.1.3",
"ember-export-application-global": "^2.0.1",
"ember-load-initializers": "^2.1.1",
"ember-load-initializers": "^2.1.2",
"ember-maybe-import-regenerator": "^0.1.6",
"ember-qunit": "^4.6.0",
"ember-resolver": "^8.0.0",
"ember-source": "~3.20.2",
"ember-source-channel-url": "^2.0.1",
"ember-template-lint": "^2.9.1",
"ember-page-title": "^6.0.3",
"ember-qunit": "^5.1.1",
"ember-resolver": "^8.0.2",
"ember-source": "~3.24.0",
"ember-source-channel-url": "^3.0.0",
"ember-template-lint": "^2.15.0",
"ember-try": "^1.4.0",
"eslint": "^7.5.0",
"eslint-plugin-ember": "^8.9.1",
"eslint": "^7.17.0",
"eslint-config-prettier": "^7.1.0",
"eslint-plugin-ember": "^10.1.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.3.1",
"loader.js": "^4.7.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.0.5",
"qunit-dom": "^1.2.0"
"prettier": "^2.2.1",
"qunit": "^2.13.0",
"qunit-dom": "^1.6.0"
},
"engines": {
"node": "10.* || >= 12"
Loaded 100 of 281 files, more files were not shown because too many files have changed in this diff. Show more