refactor: 💡 upgrade addons/auth to Ember 3.24

This commit is contained in:
Randall Morey committed 2021-03-05 13:39:44 -05:00
1 parent fbf39b3bba
commit 6541fbade8
19 files changed
+193 -73

No files matched your search

+1
View File
@@ -0,0 +1 @@
[{"/Users/randallmorey/git/boundary-ui/addons/auth/.eslintrc.js":"1","/Users/randallmorey/git/boundary-ui/addons/auth/.prettierrc.js":"2","/Users/randallmorey/git/boundary-ui/addons/auth/.template-lintrc.js":"3","/Users/randallmorey/git/boundary-ui/addons/auth/addon/authenticators/base.js":"4","/Users/randallmorey/git/boundary-ui/addons/auth/addon/authenticators/password.js":"5","/Users/randallmorey/git/boundary-ui/addons/auth/addon/session-stores/cookie.js":"6","/Users/randallmorey/git/boundary-ui/addons/auth/addon/session-stores/local-storage.js":"7","/Users/randallmorey/git/boundary-ui/addons/auth/config/ember-try.js":"8","/Users/randallmorey/git/boundary-ui/addons/auth/config/environment.js":"9","/Users/randallmorey/git/boundary-ui/addons/auth/ember-cli-build.js":"10","/Users/randallmorey/git/boundary-ui/addons/auth/index.js":"11","/Users/randallmorey/git/boundary-ui/addons/auth/testem.js":"12","/Users/randallmorey/git/boundary-ui/addons/auth/tests/dummy/app/app.js":"13","/Users/randallmorey/git/boundary-ui/addons/auth/tests/dummy/app/authenticators/base.js":"14","/Users/randallmorey/git/boundary-ui/addons/auth/tests/dummy/app/authenticators/password.js":"15","/Users/randallmorey/git/boundary-ui/addons/auth/tests/dummy/app/router.js":"16","/Users/randallmorey/git/boundary-ui/addons/auth/tests/dummy/app/session-stores/cookie.js":"17","/Users/randallmorey/git/boundary-ui/addons/auth/tests/dummy/app/session-stores/local-storage.js":"18","/Users/randallmorey/git/boundary-ui/addons/auth/tests/dummy/config/environment.js":"19","/Users/randallmorey/git/boundary-ui/addons/auth/tests/dummy/config/targets.js":"20","/Users/randallmorey/git/boundary-ui/addons/auth/tests/dummy/mirage/config.js":"21","/Users/randallmorey/git/boundary-ui/addons/auth/tests/dummy/mirage/scenarios/default.js":"22","/Users/randallmorey/git/boundary-ui/addons/auth/tests/dummy/mirage/serializers/application.js":"23","/Users/randallmorey/git/boundary-ui/addons/auth/tests/test-helper.js":"24","/Users/randallmorey/git/boundary-ui/addons/auth/tests/unit/authenticators/base-test.js":"25","/Users/randallmorey/git/boundary-ui/addons/auth/tests/unit/authenticators/password-test.js":"26","/Users/randallmorey/git/boundary-ui/addons/auth/tests/unit/session-stores/cookie-test.js":"27"},{"size":1261,"mtime":1614968222345,"results":"28","hashOfConfig":"29"},{"size":58,"mtime":1614968153726,"results":"30","hashOfConfig":"29"},{"size":58,"mtime":1614968153727,"results":"31","hashOfConfig":"29"},{"size":2748,"mtime":1614968229848,"results":"32","hashOfConfig":"29"},{"size":2958,"mtime":1614968229863,"results":"33","hashOfConfig":"29"},{"size":4392,"mtime":1614968506425,"results":"34","hashOfConfig":"29"},{"size":694,"mtime":1605716837136,"results":"35","hashOfConfig":"29"},{"size":1686,"mtime":1614968189649,"results":"36","hashOfConfig":"29"},{"size":90,"mtime":1605716837137,"results":"37","hashOfConfig":"29"},{"size":495,"mtime":1605716837137,"results":"38","hashOfConfig":"29"},{"size":72,"mtime":1605716837137,"results":"39","hashOfConfig":"29"},{"size":681,"mtime":1614968201726,"results":"40","hashOfConfig":"29"},{"size":388,"mtime":1605716837138,"results":"41","hashOfConfig":"29"},{"size":277,"mtime":1609793139529,"results":"42","hashOfConfig":"29"},{"size":353,"mtime":1605716837138,"results":"43","hashOfConfig":"29"},{"size":240,"mtime":1605716837139,"results":"44","hashOfConfig":"29"},{"size":192,"mtime":1605716837139,"results":"45","hashOfConfig":"29"},{"size":168,"mtime":1605716837139,"results":"46","hashOfConfig":"29"},{"size":1242,"mtime":1605716837140,"results":"47","hashOfConfig":"29"},{"size":314,"mtime":1605716837140,"results":"48","hashOfConfig":"29"},{"size":763,"mtime":1605716837141,"results":"49","hashOfConfig":"29"},{"size":194,"mtime":1605716837141,"results":"50","hashOfConfig":"29"},{"size":100,"mtime":1605716837141,"results":"51","hashOfConfig":"29"},{"size":323,"mtime":1614968153728,"results":"52","hashOfConfig":"29"},{"size":2786,"mtime":1614968230015,"results":"53","hashOfConfig":"29"},{"size":2520,"mtime":1609793139530,"results":"54","hashOfConfig":"29"},{"size":2789,"mtime":1605716837143,"results":"55","hashOfConfig":"29"},{"filePath":"56","messages":"57","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"2hgbsh",{"filePath":"58","messages":"59","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"60","messages":"61","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"62","messages":"63","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"64","messages":"65","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"66","messages":"67","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"68","messages":"69","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"70","messages":"7Line truncated
+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',
};
+59
View File
@@ -0,0 +1,59 @@
---
language: node_js
node_js:
# we recommend testing addons with the same minimum supported node version as Ember CLI
# so that your addon works for all apps
- "10"
dist: xenial
addons:
chrome: stable
cache:
directories:
- $HOME/.npm
env:
global:
# See https://git.io/vdao3 for details.
- JOBS=1
branches:
only:
- master
# npm version tags
- /^v\d+\.\d+\.\d+/
jobs:
fast_finish: true
allow_failures:
- env: EMBER_TRY_SCENARIO=ember-canary
include:
# runs linting and tests with current locked deps
- stage: "Tests"
name: "Tests"
script:
- npm run lint
- npm run test:ember
- stage: "Additional Tests"
name: "Floating Dependencies"
install:
- npm install --no-package-lock
script:
- npm run test:ember
# we recommend new addons test the current and previous LTS
# as well as latest stable release (bonus points to beta/canary)
- env: EMBER_TRY_SCENARIO=ember-lts-3.16
- env: EMBER_TRY_SCENARIO=ember-lts-3.20
- env: EMBER_TRY_SCENARIO=ember-release
- env: EMBER_TRY_SCENARIO=ember-beta
- env: EMBER_TRY_SCENARIO=ember-canary
- env: EMBER_TRY_SCENARIO=ember-default-with-jquery
- env: EMBER_TRY_SCENARIO=ember-classic
script:
- node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO
+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',
+29 -21
View File
@@ -8,53 +8,61 @@
"ember-addon"
],
"scripts": {
"lint": "npm-run-all --aggregate-output --continue-on-error --parallel lint:*",
"lint:js": "eslint .",
"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 . --cache",
"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"
@@ -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();
@@ -34,10 +34,13 @@ module('Unit | Authenticator | base', function (hooks) {
assert.expect(1);
const mockData = { id: 'token_123' };
const authenticator = this.owner.lookup('authenticator:base');
this.server.get(authenticator.buildTokenValidationEndpointURL(mockData.id), () => {
assert.ok(true, 'token validation was requested');
return new Response(200);
});
this.server.get(
authenticator.buildTokenValidationEndpointURL(mockData.id),
() => {
assert.ok(true, 'token validation was requested');
return new Response(200);
}
);
await authenticator.restore(mockData);
});
@@ -45,10 +48,13 @@ module('Unit | Authenticator | base', function (hooks) {
assert.expect(2);
const mockData = { id: 'token_123' };
const authenticator = this.owner.lookup('authenticator:base');
this.server.get(authenticator.buildTokenValidationEndpointURL(mockData.id), () => {
assert.ok(true, 'token validation was requested');
return new Response(401);
});
this.server.get(
authenticator.buildTokenValidationEndpointURL(mockData.id),
() => {
assert.ok(true, 'token validation was requested');
return new Response(401);
}
);
try {
await authenticator.restore(mockData);
} catch (e) {
@@ -60,10 +66,13 @@ module('Unit | Authenticator | base', function (hooks) {
assert.expect(2);
const mockData = { id: 'token_123' };
const authenticator = this.owner.lookup('authenticator:base');
this.server.get(authenticator.buildTokenValidationEndpointURL(mockData.id), () => {
assert.ok(true, 'token validation was requested');
return new Response(404);
});
this.server.get(
authenticator.buildTokenValidationEndpointURL(mockData.id),
() => {
assert.ok(true, 'token validation was requested');
return new Response(404);
}
);
try {
await authenticator.restore(mockData);
} catch (e) {
+1
View File
@@ -12,6 +12,7 @@
/.env*
/.pnp*
/.sass-cache
/.eslintcache
/connect.lock
/coverage/
/libpeerconnection.log