mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-01 19:17:58 +00:00
replace moment.js with date-fns
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import Component from '@ember/component';
|
||||
|
||||
export default Component.extend({
|
||||
classNames: 'token-expire-warning',
|
||||
tagName: '',
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@ import { assign } from '@ember/polyfills';
|
||||
import { inject as service } from '@ember/service';
|
||||
import Component from '@ember/component';
|
||||
import { setProperties, computed, set, get } from '@ember/object';
|
||||
import moment from 'moment';
|
||||
import { addSeconds } from 'date-fns';
|
||||
|
||||
const DEFAULTS = {
|
||||
token: null,
|
||||
@@ -67,7 +67,8 @@ export default Component.extend(DEFAULTS, {
|
||||
if (!(creation_time && creation_ttl)) {
|
||||
return null;
|
||||
}
|
||||
return moment(creation_time).add(moment.duration(creation_ttl, 'seconds'));
|
||||
|
||||
return addSeconds(creation_time, creation_ttl);
|
||||
}),
|
||||
|
||||
handleError(e) {
|
||||
|
||||
35
ui/app/helpers/-date-base.js
Normal file
35
ui/app/helpers/-date-base.js
Normal file
@@ -0,0 +1,35 @@
|
||||
import { run } from '@ember/runloop';
|
||||
import Helper from '@ember/component/helper';
|
||||
import { get } from '@ember/object';
|
||||
|
||||
export default Helper.extend({
|
||||
disableInterval: false,
|
||||
|
||||
compute(value, { interval }) {
|
||||
if (get(this, 'disableInterval')) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.clearTimer();
|
||||
|
||||
if (interval) {
|
||||
/*
|
||||
* NOTE: intentionally a setTimeout so tests do not block on it
|
||||
* as the run loop queue is never clear so tests will stay locked waiting
|
||||
* for queue to clear.
|
||||
*/
|
||||
this.intervalTimer = setTimeout(() => {
|
||||
run(() => this.recompute());
|
||||
}, parseInt(interval, 10));
|
||||
}
|
||||
},
|
||||
|
||||
clearTimer() {
|
||||
clearTimeout(this.intervalTimer);
|
||||
},
|
||||
|
||||
destroy() {
|
||||
this.clearTimer();
|
||||
this._super(...arguments);
|
||||
},
|
||||
});
|
||||
8
ui/app/helpers/date-format.js
Normal file
8
ui/app/helpers/date-format.js
Normal file
@@ -0,0 +1,8 @@
|
||||
import { helper } from '@ember/component/helper';
|
||||
import formatDate from 'date-fns/format';
|
||||
|
||||
export function dateFormat([date, format]) {
|
||||
return formatDate(date, format);
|
||||
}
|
||||
|
||||
export default helper(dateFormat);
|
||||
8
ui/app/helpers/date-from-now.js
Normal file
8
ui/app/helpers/date-from-now.js
Normal file
@@ -0,0 +1,8 @@
|
||||
import { helper } from '@ember/component/helper';
|
||||
import { distanceInWordsToNow } from 'date-fns';
|
||||
|
||||
export function dateFromNow([date], options = {}) {
|
||||
return distanceInWordsToNow(date, options);
|
||||
}
|
||||
|
||||
export default helper(dateFromNow);
|
||||
10
ui/app/helpers/is-after.js
Normal file
10
ui/app/helpers/is-after.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import DateBase from './-date-base';
|
||||
import { isAfter } from 'date-fns';
|
||||
|
||||
export default DateBase.extend({
|
||||
compute: function([date1, date2]) {
|
||||
this._super(...arguments);
|
||||
|
||||
return isAfter(date1, date2);
|
||||
},
|
||||
});
|
||||
10
ui/app/helpers/is-before.js
Normal file
10
ui/app/helpers/is-before.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import DateBase from './-date-base';
|
||||
import { isBefore } from 'date-fns';
|
||||
|
||||
export default DateBase.extend({
|
||||
compute: function([date1, date2]) {
|
||||
this._super(...arguments);
|
||||
|
||||
return isBefore(date1, date2);
|
||||
},
|
||||
});
|
||||
9
ui/app/helpers/now.js
Normal file
9
ui/app/helpers/now.js
Normal file
@@ -0,0 +1,9 @@
|
||||
import DateBase from './-date-base';
|
||||
|
||||
export default DateBase.extend({
|
||||
compute() {
|
||||
this._super(...arguments);
|
||||
|
||||
return Date.now();
|
||||
},
|
||||
});
|
||||
@@ -7,7 +7,7 @@
|
||||
{{i-con glyph="hashicorp" size=18 aria-label="HashiCorp logo" }}
|
||||
</span>
|
||||
<span class="is-inline-block">
|
||||
© {{moment-format (now) "Y"}} HashiCorp, Inc.
|
||||
© {{date-format (now) "YYYY"}} HashiCorp, Inc.
|
||||
</span>
|
||||
<span>
|
||||
Vault {{activeCluster.leaderNode.version}}
|
||||
|
||||
@@ -7,12 +7,9 @@
|
||||
<ul class="menu-list">
|
||||
{{#if canExpire}}
|
||||
<li class="action">
|
||||
<AlertBanner
|
||||
@type="warning"
|
||||
@message="We've stopped auto-renewing your token due to inactivity.
|
||||
It will expire in {{moment-from-now auth.tokenExpirationDate interval=1000 hideSuffix=true}}.
|
||||
on {{moment-format auth.tokenExpirationDate 'MMMM Do YYYY, h:mm:ss a'}}"
|
||||
/>
|
||||
<AlertBanner @type="warning" @message="We've stopped auto-renewing your token due to inactivity.
|
||||
It will expire in {{date-from-now auth.tokenExpirationDate interval=1000 hideSuffix=true}}.
|
||||
on {{date-format auth.tokenExpirationDate 'MMMM Do YYYY, h:mm:ss a'}}" />
|
||||
</li>
|
||||
{{/if}}
|
||||
{{#if (is-before (now interval=1000) auth.tokenExpirationDate)}}
|
||||
|
||||
@@ -19,11 +19,11 @@
|
||||
{{/info-table-row}}
|
||||
{{#info-table-row label="Created" value=model.creationTime}}
|
||||
<time datetime={{model.creationTime}} title={{model.creationTime}}>
|
||||
{{moment-format model.creationTime 'MMM DD, YYYY [at] h:mm a'}}
|
||||
{{date-format model.creationTime 'MMM DD, YYYY [at] h:mm a'}}
|
||||
</time>
|
||||
{{/info-table-row}}
|
||||
{{#info-table-row label="Last Updated" value=model.lastUpdateTime}}
|
||||
<time datetime={{model.lastUpdateTime}} title={{model.lastUpdateTime}}>
|
||||
{{moment-format model.lastUpdateTime 'MMM DD, YYYY [at] h:mm a'}}
|
||||
{{date-format model.lastUpdateTime 'MMM DD, YYYY [at] h:mm a'}}
|
||||
</time>
|
||||
{{/info-table-row}}
|
||||
|
||||
@@ -26,12 +26,12 @@
|
||||
{{/info-table-row}}
|
||||
{{#info-table-row label="Created" value=model.creationTime}}
|
||||
<time datetime={{model.creationTime}} title={{model.creationTime}}>
|
||||
{{moment-format model.creationTime 'MMM DD, YYYY [at] h:mm a'}}
|
||||
{{date-format model.creationTime 'MMM DD, YYYY [at] h:mm a'}}
|
||||
</time>
|
||||
{{/info-table-row}}
|
||||
{{#info-table-row label="Last Updated" value=model.lastUpdateTime}}
|
||||
<time datetime={{model.lastUpdateTime}} title={{model.lastUpdateTime}}>
|
||||
{{moment-format model.lastUpdateTime 'MMM DD, YYYY [at] h:mm a'}}
|
||||
{{date-format model.lastUpdateTime 'MMM DD, YYYY [at] h:mm a'}}
|
||||
</time>
|
||||
{{/info-table-row}}
|
||||
</div>
|
||||
@@ -8,7 +8,7 @@
|
||||
<section class="box is-sideless is-fullwidth">
|
||||
<AlertBanner
|
||||
@type="warning"
|
||||
@message="Your temporary license expires {{moment-from-now expirationTime}} and your vault will seal. Please enter a valid license below."
|
||||
@message="Your temporary license expires in {{date-from-now expirationTime}} and your vault will seal. Please enter a valid license below."
|
||||
@class="license-warning"
|
||||
data-test-cluster-status
|
||||
data-test-warning-text
|
||||
@@ -54,7 +54,7 @@
|
||||
<div class="field box is-fullwidth is-shadowless is-paddingless is-marginless">
|
||||
{{info-table-row label="License ID" value=licenseId}}
|
||||
{{#info-table-row label="Valid from" value=startTime}}
|
||||
{{moment-format model.startTime 'MMM DD, YYYY hh:mm:ss A'}} to {{moment-format expirationTime 'MMM DD, YYYY hh:mm:ss A'}}
|
||||
{{date-format model.startTime 'MMM DD, YYYY hh:mm:ss A'}} to {{date-format expirationTime 'MMM DD, YYYY hh:mm:ss A'}}
|
||||
{{/info-table-row}}
|
||||
</div>
|
||||
<div class="field box is-fullwidth is-shadowless is-paddingless is-marginless">
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
<AlertBanner
|
||||
@type="danger"
|
||||
@message="Your auth token expired on {{moment-format auth.tokenExpirationDate 'MMMM Do YYYY, h:mm:ss a'}}. You will need to re-authenticate."
|
||||
>
|
||||
{{#link-to "vault.cluster.logout" class="button link"}}
|
||||
Reauthenticate
|
||||
{{/link-to}}
|
||||
</AlertBanner>
|
||||
{{#if (and expirationDate (is-after (now interval=1000) expirationDate)) }}
|
||||
<div class="token-expire-warning">
|
||||
<AlertBanner @type="danger" @message="Your auth token expired on {{date-format expirationDate 'MMMM Do YYYY, h:mm:ss a'}}. You will need to re-authenticate.">
|
||||
{{#link-to "vault.cluster.logout" class="button link"}}
|
||||
Reauthenticate
|
||||
{{/link-to}}
|
||||
</AlertBanner>
|
||||
</div>
|
||||
{{else}}
|
||||
{{yield}}
|
||||
{{/if}}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
{{info-table-row label="Creation TTL" value=creation_ttl data-test-tools="token-lookup-row"}}
|
||||
{{#if expirationDate}}
|
||||
{{info-table-row label="Expiration date" value=expirationDate data-test-tools="token-lookup-row"}}
|
||||
{{info-table-row label="Expires in" value=(moment-from-now expirationDate interval=1000 hideSuffix=true) data-test-tools="token-lookup-row"}}
|
||||
{{info-table-row label="Expires in" value=(date-from-now expirationDate) data-test-tools="token-lookup-row"}}
|
||||
{{/if}}
|
||||
</div>
|
||||
<div class="field is-grouped box is-fullwidth is-bottomless">
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
queryParams=(query-params tab='')
|
||||
data-test-transit-link="details"
|
||||
}}
|
||||
Details
|
||||
Details
|
||||
{{/secret-link}}
|
||||
</li>
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
queryParams=(query-params tab='versions')
|
||||
data-test-transit-link="versions"
|
||||
}}
|
||||
Versions
|
||||
Versions
|
||||
{{/secret-link}}
|
||||
</li>
|
||||
</ul>
|
||||
@@ -52,16 +52,16 @@
|
||||
<div class="td is-borderless">
|
||||
{{version}}
|
||||
{{#if (coerce-eq key.minDecryptionVersion version)}}
|
||||
<p class="help has-text-grey">(current minimum decryption version)</p>
|
||||
<p class="help has-text-grey">(current minimum decryption version)</p>
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="column is-half td">
|
||||
<div class="td is-borderless">
|
||||
{{moment-format (unix creationTimestamp) 'MMM DD, YYYY hh:mm:ss A'}}
|
||||
<br/>
|
||||
{{date-format creationTimestamp 'MMM DD, YYYY hh:mm:ss A'}}
|
||||
<br />
|
||||
<small class="is-font-mono has-text-grey">
|
||||
{{moment-format (unix creationTimestamp) }}
|
||||
{{date-format creationTimestamp }}
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
@@ -95,7 +95,8 @@
|
||||
</div>
|
||||
</div>
|
||||
{{#each-in key.keys as |version meta|}}
|
||||
<div class="columns is-gapless is-marginless table {{if (get this (concat version '-open')) 'has-background-grey-lighter' }}" data-test-transit-key-version-row={{version}}>
|
||||
<div class="columns is-gapless is-marginless table {{if (get this (concat version '-open')) 'has-background-grey-lighter' }}"
|
||||
data-test-transit-key-version-row={{version}}>
|
||||
<div class="column {{if (get this (concat version '-open')) '' 'td' }}">
|
||||
<div class="columns is-marginless is-gapless">
|
||||
<div class="column is-11">
|
||||
@@ -116,10 +117,10 @@
|
||||
<div class="column is-one-third">
|
||||
<div class="td is-borderless">
|
||||
<div>
|
||||
{{moment-format meta.creation_time 'MMM DD, YYYY hh:mm:ss A'}}
|
||||
<br/>
|
||||
{{date-format meta.creation_time 'MMM DD, YYYY hh:mm:ss A'}}
|
||||
<br />
|
||||
<small class="is-font-mono has-text-grey">
|
||||
{{moment-format meta.creation_time}}
|
||||
{{date-format meta.creation_time}}
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
@@ -136,27 +137,27 @@
|
||||
</div>
|
||||
{{#if (get this (concat version '-open'))}}
|
||||
<div class="table has-background-grey-lighter is-paddingless is-marginless">
|
||||
<div class="td">
|
||||
<div>
|
||||
<span class="is-label">
|
||||
Public Key
|
||||
</span>
|
||||
<pre class="has-background-transparent"><code class="is-paddingless">{{meta.public_key}}</code></pre>
|
||||
<div class="box is-fullwidth has-background-transparent is-shadowless">
|
||||
<div class="control">
|
||||
{{#copy-button
|
||||
<div class="td">
|
||||
<div>
|
||||
<span class="is-label">
|
||||
Public Key
|
||||
</span>
|
||||
<pre class="has-background-transparent"><code class="is-paddingless">{{meta.public_key}}</code></pre>
|
||||
<div class="box is-fullwidth has-background-transparent is-shadowless">
|
||||
<div class="control">
|
||||
{{#copy-button
|
||||
clipboardText=meta.public_key
|
||||
class="button"
|
||||
buttonType="button"
|
||||
success=(action (set-flash-message (concat 'Public key for version ' version ' copied!')))
|
||||
}}
|
||||
Copy
|
||||
{{/copy-button}}
|
||||
Copy
|
||||
{{/copy-button}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{/each-in}}
|
||||
{{/if}}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{{#if showNav}}
|
||||
<NavHeader data-test-header-with-nav @class="{{if consoleOpen 'panel-open'}} {{if consoleFullscreen ' panel-fullscreen'}}" as |Nav|>
|
||||
<NavHeader data-test-header-with-nav @class="{{if consoleOpen 'panel-open'}} {{if consoleFullscreen ' panel-fullscreen'}}"
|
||||
as |Nav|>
|
||||
<Nav.home>
|
||||
<HomeLink @class="navbar-item has-text-white has-current-color-fill">
|
||||
{{partial 'svg/vault-logo'}}
|
||||
@@ -16,9 +17,9 @@
|
||||
</NamespacePicker>
|
||||
</li>
|
||||
{{/if}}
|
||||
<li class="{{if (is-active-route 'vault.cluster.secrets') 'is-active'}}" >
|
||||
{{#link-to
|
||||
"vault.cluster.secrets"
|
||||
<li class="{{if (is-active-route 'vault.cluster.secrets') 'is-active'}}">
|
||||
{{#link-to
|
||||
"vault.cluster.secrets"
|
||||
current-when="vault.cluster.secrets vault.cluster.settings.mount-secret-backend vault.cluster.settings.configure-secret-backend"
|
||||
invokeAction=(action Nav.closeDrawer)
|
||||
}}
|
||||
@@ -35,9 +36,9 @@
|
||||
{{/link-to}}
|
||||
</li>
|
||||
<li class="{{if (is-active-route (array 'vault.cluster.policies' 'vault.cluster.policy')) 'is-active'}}">
|
||||
{{#link-to
|
||||
"vault.cluster.policies"
|
||||
"acl"
|
||||
{{#link-to
|
||||
"vault.cluster.policies"
|
||||
"acl"
|
||||
current-when="vault.cluster.policies vault.cluster.policy"
|
||||
invokeAction=(action Nav.closeDrawer)
|
||||
}}
|
||||
@@ -45,7 +46,7 @@
|
||||
{{/link-to}}
|
||||
</li>
|
||||
<li class="{{if (is-active-route 'vault.cluster.tools') 'is-active'}}">
|
||||
{{#link-to
|
||||
{{#link-to
|
||||
"vault.cluster.tools.tool"
|
||||
"wrap"
|
||||
invokeAction=(action Nav.closeDrawer)
|
||||
@@ -64,7 +65,8 @@
|
||||
<div class="navbar-separator is-hidden-mobile"></div>
|
||||
{{/if}}
|
||||
<div class="navbar-item">
|
||||
<button type="button" class="button is-transparent nav-console-button{{if consoleOpen " popup-open"}}" {{action (queue (action 'toggleConsole') (action Nav.closeDrawer))}} data-test-console-toggle>
|
||||
<button type="button" class="button is-transparent nav-console-button{{if consoleOpen " popup-open"}}"
|
||||
{{action (queue (action 'toggleConsole') (action Nav.closeDrawer))}} data-test-console-toggle>
|
||||
<ICon @glyph="console" @size=24 />
|
||||
<div class="status-menu-label">
|
||||
Console
|
||||
@@ -113,11 +115,9 @@
|
||||
<UiWizard>
|
||||
<section class="section">
|
||||
<div class="container is-widescreen">
|
||||
{{#if (is-after (now interval=1000) auth.tokenExpirationDate) }}
|
||||
<TokenExpireWarning />
|
||||
{{else}}
|
||||
<TokenExpireWarning @expirationDate={{auth.tokenExpirationDate}}>
|
||||
{{outlet}}
|
||||
{{/if}}
|
||||
</TokenExpireWarning>
|
||||
</div>
|
||||
</section>
|
||||
</UiWizard>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
</PageHeader>
|
||||
<div class="field box is-fullwidth is-sideless is-paddingless is-marginless">
|
||||
{{#info-table-row label="Issue time" value=model.issueTime}}
|
||||
{{moment-format model.issueTime 'MMM DD, YYYY hh:mm:ss A'}}
|
||||
{{date-format model.issueTime 'MMM DD, YYYY hh:mm:ss A'}}
|
||||
<br/>
|
||||
<code>
|
||||
{{model.issueTime}}
|
||||
@@ -26,7 +26,7 @@
|
||||
{{/info-table-row}}
|
||||
{{info-table-row label="Renewable" value=model.renewable}}
|
||||
{{#info-table-row label="Last renewal" value=model.lastRenewal}}
|
||||
{{moment-format model.lastRenewal 'MMM DD, YYYY hh:mm:ss A'}}
|
||||
{{date-format model.lastRenewal 'MMM DD, YYYY hh:mm:ss A'}}
|
||||
<br/>
|
||||
<code>
|
||||
{{model.lastRenewal}}
|
||||
@@ -34,13 +34,13 @@
|
||||
{{/info-table-row}}
|
||||
{{#if model.expireTime}}
|
||||
{{#info-table-row label="Expiration time" value=model.expireTime}}
|
||||
{{moment-format model.expireTime 'MMM DD, YYYY hh:mm:ss A'}}
|
||||
{{date-format model.expireTime 'MMM DD, YYYY hh:mm:ss A'}}
|
||||
<br/>
|
||||
<code>
|
||||
{{model.expireTime}}
|
||||
</code>
|
||||
{{/info-table-row}}
|
||||
{{info-table-row label="Expires in" value=(moment-from-now model.expireTime interval=1000 hideSuffix=true)}}
|
||||
{{info-table-row label="Expires in" value=(date-from-now model.expireTime interval=1000 hideSuffix=true)}}
|
||||
{{/if}}
|
||||
{{info-table-row label="TTL" value=model.ttl}}
|
||||
</div>
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
"codemirror": "5.15.2",
|
||||
"columnify": "^1.5.4",
|
||||
"cool-checkboxes-for-bulma.io": "^1.1.0",
|
||||
"date-fns": "^1.29.0",
|
||||
"deepmerge": "^2.1.1",
|
||||
"ember-ajax": "^3.1.0",
|
||||
"ember-api-actions": "^0.1.8",
|
||||
@@ -65,7 +66,6 @@
|
||||
"ember-cli-htmlbars": "^3.0.0",
|
||||
"ember-cli-htmlbars-inline-precompile": "^1.0.3",
|
||||
"ember-cli-inject-live-reload": "^1.8.2",
|
||||
"ember-cli-moment-shim": "^3.7.1",
|
||||
"ember-cli-page-object": "1.15.0-beta.3",
|
||||
"ember-cli-pretender": "^1.0.1",
|
||||
"ember-cli-qunit": "^4.3.2",
|
||||
@@ -87,7 +87,6 @@
|
||||
"ember-load-initializers": "^1.1.0",
|
||||
"ember-maybe-import-regenerator": "^0.1.6",
|
||||
"ember-maybe-in-element": "^0.1.3",
|
||||
"ember-moment": "^7.7.0",
|
||||
"ember-radio-button": "^1.1.1",
|
||||
"ember-resolver": "^5.0.1",
|
||||
"ember-responsive": "^3.0.0-beta.3",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import moment from 'moment';
|
||||
import { addMinutes } from 'date-fns';
|
||||
import { module, test } from 'qunit';
|
||||
import { setupRenderingTest } from 'ember-qunit';
|
||||
import { render } from '@ember/test-helpers';
|
||||
@@ -26,9 +26,10 @@ module('Integration | Component | license info', function(hooks) {
|
||||
const LICENSE_WARNING_TEXT = `Warning Your temporary license expires in 30 minutes and your vault will seal. Please enter a valid license below.`;
|
||||
|
||||
test('it renders properly for temporary license', async function(assert) {
|
||||
const now = Date.now();
|
||||
this.set('licenseId', 'temporary');
|
||||
this.set('expirationTime', moment(moment.now()).add(30, 'minutes'));
|
||||
this.set('startTime', moment.now());
|
||||
this.set('expirationTime', addMinutes(now, 30));
|
||||
this.set('startTime', now);
|
||||
this.set('features', ['HSM', 'Namespaces']);
|
||||
await render(
|
||||
hbs`<LicenseInfo @licenseId={{this.licenseId}} @expirationTime={{this.expirationTime}} @startTime={{this.startTime}} @features={{this.features}}/>`
|
||||
@@ -52,9 +53,10 @@ module('Integration | Component | license info', function(hooks) {
|
||||
});
|
||||
|
||||
test('it renders feature status properly for features associated with license', async function(assert) {
|
||||
const now = Date.now();
|
||||
this.set('licenseId', 'temporary');
|
||||
this.set('expirationTime', moment(moment.now()).add(30, 'minutes'));
|
||||
this.set('startTime', moment.now());
|
||||
this.set('expirationTime', addMinutes(now, 30));
|
||||
this.set('startTime', now);
|
||||
this.set('features', ['HSM', 'Namespaces']);
|
||||
await render(
|
||||
hbs`<LicenseInfo @licenseId={{this.licenseId}} @expirationTime={{this.expirationTime}} @startTime={{this.startTime}} @features={{this.features}}/>`
|
||||
@@ -65,9 +67,10 @@ module('Integration | Component | license info', function(hooks) {
|
||||
});
|
||||
|
||||
test('it renders properly for non-temporary license', async function(assert) {
|
||||
const now = Date.now();
|
||||
this.set('licenseId', 'test');
|
||||
this.set('expirationTime', moment(moment.now()).add(30, 'minutes'));
|
||||
this.set('startTime', moment.now());
|
||||
this.set('expirationTime', addMinutes(now, 30));
|
||||
this.set('startTime', now);
|
||||
this.set('features', ['HSM', 'Namespaces']);
|
||||
await render(
|
||||
hbs`<LicenseInfo @licenseId={{this.licenseId}} @expirationTime={{this.expirationTime}} @startTime={{this.startTime}} @features={{this.features}}/>`
|
||||
@@ -79,9 +82,10 @@ module('Integration | Component | license info', function(hooks) {
|
||||
});
|
||||
|
||||
test('it shows and hides license form when enter and cancel buttons are clicked', async function(assert) {
|
||||
const now = Date.now();
|
||||
this.set('licenseId', 'test');
|
||||
this.set('expirationTime', moment(moment.now()).add(30, 'minutes'));
|
||||
this.set('startTime', moment.now());
|
||||
this.set('expirationTime', addMinutes(now, 30));
|
||||
this.set('startTime', now);
|
||||
this.set('features', ['HSM', 'Namespaces']);
|
||||
await render(
|
||||
hbs`<LicenseInfo @licenseId={{this.licenseId}} @expirationTime={{this.expirationTime}} @startTime={{this.startTime}} @features={{this.features}}/>`
|
||||
@@ -97,9 +101,10 @@ module('Integration | Component | license info', function(hooks) {
|
||||
});
|
||||
|
||||
test('it calls saveModel when save button is clicked', async function(assert) {
|
||||
const now = Date.now();
|
||||
this.set('licenseId', 'temporary');
|
||||
this.set('expirationTime', moment(moment.now()).add(30, 'minutes'));
|
||||
this.set('startTime', moment.now());
|
||||
this.set('expirationTime', addMinutes(now, 30));
|
||||
this.set('startTime', now);
|
||||
this.set('features', ['HSM', 'Namespaces']);
|
||||
this.set('saveModel', sinon.spy());
|
||||
await render(
|
||||
|
||||
32
ui/tests/integration/components/token-expire-warning-test.js
Normal file
32
ui/tests/integration/components/token-expire-warning-test.js
Normal file
@@ -0,0 +1,32 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupRenderingTest } from 'ember-qunit';
|
||||
import { render } from '@ember/test-helpers';
|
||||
import hbs from 'htmlbars-inline-precompile';
|
||||
import { addMinutes } from 'date-fns';
|
||||
|
||||
module('Integration | Component | token-expire-warning', function(hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
test('it renders a warning when the token is expired', async function(assert) {
|
||||
const expirationDate = Date.now();
|
||||
this.set('expirationDate', expirationDate);
|
||||
|
||||
await render(hbs`<TokenExpireWarning @expirationDate={{expirationDate}}/>`);
|
||||
|
||||
assert.dom().includesText('Your auth token expired on');
|
||||
});
|
||||
|
||||
test('it does not render a warning when the token is not expired', async function(assert) {
|
||||
const expirationDate = addMinutes(Date.now(), 30);
|
||||
this.set('expirationDate', expirationDate);
|
||||
|
||||
await render(hbs`
|
||||
<TokenExpireWarning @expirationDate={{expirationDate}}>
|
||||
<p>Do not worry, your token has not expired.</p>
|
||||
</TokenExpireWarning>
|
||||
`);
|
||||
|
||||
assert.dom().doesNotIncludeText('Your auth token expired on');
|
||||
assert.dom().includesText('Do not worry');
|
||||
});
|
||||
});
|
||||
27
ui/tests/integration/helpers/date-format-test.js
Normal file
27
ui/tests/integration/helpers/date-format-test.js
Normal file
@@ -0,0 +1,27 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupRenderingTest } from 'ember-qunit';
|
||||
import { dateFormat } from '../../../helpers/date-format';
|
||||
|
||||
module('Integration | Helper | date-format', function(hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
test('it is able to format a date object', function(assert) {
|
||||
let today = new Date();
|
||||
let result = dateFormat([today, 'YYYY']);
|
||||
assert.ok(typeof result === 'string');
|
||||
assert.ok(result !== 'Invalid Date', 'it is not an invalid date');
|
||||
assert.ok(Number(result) >= 2017);
|
||||
});
|
||||
|
||||
test('it supports date timestamps', function(assert) {
|
||||
let today = new Date().getTime();
|
||||
let result = dateFormat([today, 'YYYY']);
|
||||
assert.ok(Number(result) >= 2017);
|
||||
});
|
||||
|
||||
test('it supports date strings', function(assert) {
|
||||
let today = new Date().toString();
|
||||
let result = dateFormat([today, 'YYYY']);
|
||||
assert.ok(Number(result) >= 2017);
|
||||
});
|
||||
});
|
||||
17
ui/tests/integration/helpers/date-from-now-test.js
Normal file
17
ui/tests/integration/helpers/date-from-now-test.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupRenderingTest } from 'ember-qunit';
|
||||
import { dateFromNow } from '../../../helpers/date-from-now';
|
||||
|
||||
module('Integration | Helper | date-from-now', function(hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
test('it works', function(assert) {
|
||||
let result = dateFromNow([1481022124443]);
|
||||
assert.ok(typeof result === 'string', 'it is a string');
|
||||
});
|
||||
|
||||
test('you can include a suffix', function(assert) {
|
||||
let result = dateFromNow([1481022124443], { addSuffix: true });
|
||||
assert.ok(result.includes(' ago'));
|
||||
});
|
||||
});
|
||||
87
ui/yarn.lock
87
ui/yarn.lock
@@ -2988,7 +2988,7 @@ browserslist@^2.11.3:
|
||||
caniuse-lite "^1.0.30000792"
|
||||
electron-to-chromium "^1.3.30"
|
||||
|
||||
browserslist@^3.1.1, browserslist@^3.2.6:
|
||||
browserslist@^3.2.6:
|
||||
version "3.2.8"
|
||||
resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-3.2.8.tgz#b0005361d6471f0f5952797a76fc985f1f978fc6"
|
||||
integrity sha512-WHVocJYavUwVgVViC0ORikPHQquXwVh939TaelZ4WDqpWgTX/FsGhl/+P4qBUAGcRvtOgDgC+xftNWWp2RUTAQ==
|
||||
@@ -4149,7 +4149,7 @@ dashdash@^1.12.0:
|
||||
dependencies:
|
||||
assert-plus "^1.0.0"
|
||||
|
||||
date-fns@^1.27.2:
|
||||
date-fns@^1.27.2, date-fns@^1.29.0:
|
||||
version "1.29.0"
|
||||
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-1.29.0.tgz#12e609cdcb935127311d04d33334e2960a2a54e6"
|
||||
integrity sha512-lbTXWZ6M20cWH8N9S6afb0SBm6tMk+uUg6z3MqHPKE9atmsY3kJkTm8vKe93izJ2B2+q5MV990sM2CHgtAZaOw==
|
||||
@@ -4653,7 +4653,7 @@ ember-cli-autoprefixer@^0.8.1:
|
||||
broccoli-autoprefixer "^5.0.0"
|
||||
lodash "^4.0.0"
|
||||
|
||||
ember-cli-babel@^6.0.0, ember-cli-babel@^6.0.0-beta.4, ember-cli-babel@^6.0.0-beta.7, ember-cli-babel@^6.0.0-beta.9, ember-cli-babel@^6.10.0, ember-cli-babel@^6.11.0, ember-cli-babel@^6.12.0, ember-cli-babel@^6.3.0, ember-cli-babel@^6.6.0, ember-cli-babel@^6.7.2, ember-cli-babel@^6.8.0, ember-cli-babel@^6.8.1, ember-cli-babel@^6.8.2, ember-cli-babel@^6.9.0, ember-cli-babel@^6.9.2:
|
||||
ember-cli-babel@^6.0.0, ember-cli-babel@^6.0.0-beta.4, ember-cli-babel@^6.0.0-beta.7, ember-cli-babel@^6.0.0-beta.9, ember-cli-babel@^6.10.0, ember-cli-babel@^6.11.0, ember-cli-babel@^6.12.0, ember-cli-babel@^6.3.0, ember-cli-babel@^6.6.0, ember-cli-babel@^6.8.0, ember-cli-babel@^6.8.1, ember-cli-babel@^6.8.2, ember-cli-babel@^6.9.0, ember-cli-babel@^6.9.2:
|
||||
version "6.17.0"
|
||||
resolved "https://registry.yarnpkg.com/ember-cli-babel/-/ember-cli-babel-6.17.0.tgz#1f3e8ed9f4e2338caef6bc2c3d08d3c9928d0ddd"
|
||||
integrity sha512-esI5tQ9lxCiYmZdRY1oB6KFvRxFAZQQEnFOUVYzeGJRaZOz/LIGR69jh9y4Rm0Ejm10OxoL8Js8vCnN5tMnUug==
|
||||
@@ -4830,11 +4830,6 @@ ember-cli-htmlbars@^3.0.0:
|
||||
json-stable-stringify "^1.0.0"
|
||||
strip-bom "^3.0.0"
|
||||
|
||||
ember-cli-import-polyfill@^0.2.0:
|
||||
version "0.2.0"
|
||||
resolved "https://registry.yarnpkg.com/ember-cli-import-polyfill/-/ember-cli-import-polyfill-0.2.0.tgz#c1a08a8affb45c97b675926272fe78cf4ca166f2"
|
||||
integrity sha1-waCKiv+0XJe2dZJicv54z0yhZvI=
|
||||
|
||||
ember-cli-inject-live-reload@^1.8.2:
|
||||
version "1.8.2"
|
||||
resolved "https://registry.yarnpkg.com/ember-cli-inject-live-reload/-/ember-cli-inject-live-reload-1.8.2.tgz#29f875ad921e9a1dec65d2d75018891972d240bc"
|
||||
@@ -4857,22 +4852,6 @@ ember-cli-lodash-subset@^2.0.1:
|
||||
resolved "https://registry.yarnpkg.com/ember-cli-lodash-subset/-/ember-cli-lodash-subset-2.0.1.tgz#20cb68a790fe0fde2488ddfd8efbb7df6fe766f2"
|
||||
integrity sha1-IMtop5D+D94kiN39jvu332/nZvI=
|
||||
|
||||
ember-cli-moment-shim@^3.7.1:
|
||||
version "3.7.1"
|
||||
resolved "https://registry.yarnpkg.com/ember-cli-moment-shim/-/ember-cli-moment-shim-3.7.1.tgz#3ad691c5027c1f38a4890fe47d74b5224cc98e32"
|
||||
integrity sha512-U3HHuEU7sXQ78v25ifmIa9w4nQPQ7vK/LZ2bt18pN3aKNvIDYiLe/MDeXGmqfFIq3OfruKG+CF+7dOLqxuzSlQ==
|
||||
dependencies:
|
||||
broccoli-funnel "^2.0.0"
|
||||
broccoli-merge-trees "^2.0.0"
|
||||
broccoli-source "^1.1.0"
|
||||
broccoli-stew "^1.5.0"
|
||||
chalk "^1.1.3"
|
||||
ember-cli-babel "^6.6.0"
|
||||
ember-cli-import-polyfill "^0.2.0"
|
||||
lodash.defaults "^4.2.0"
|
||||
moment "^2.19.3"
|
||||
moment-timezone "^0.5.13"
|
||||
|
||||
ember-cli-node-assets@^0.2.2:
|
||||
version "0.2.2"
|
||||
resolved "https://registry.yarnpkg.com/ember-cli-node-assets/-/ember-cli-node-assets-0.2.2.tgz#d2d55626e7cc6619f882d7fe55751f9266022708"
|
||||
@@ -5217,13 +5196,6 @@ ember-export-application-global@^2.0.0:
|
||||
dependencies:
|
||||
ember-cli-babel "^6.0.0-beta.7"
|
||||
|
||||
ember-factory-for-polyfill@^1.3.1:
|
||||
version "1.3.1"
|
||||
resolved "https://registry.yarnpkg.com/ember-factory-for-polyfill/-/ember-factory-for-polyfill-1.3.1.tgz#b446ed64916d293c847a4955240eb2c993b86eae"
|
||||
integrity sha512-y3iG2iCzH96lZMTWQw6LWNLAfOmDC4pXKbZP6FxG8lt7GGaNFkZjwsf+Z5GAe7kxfD7UG4lVkF7x37K82rySGA==
|
||||
dependencies:
|
||||
ember-cli-version-checker "^2.1.0"
|
||||
|
||||
ember-fetch@^3.4.3:
|
||||
version "3.4.5"
|
||||
resolved "https://registry.yarnpkg.com/ember-fetch/-/ember-fetch-3.4.5.tgz#2967df9cbdbe0993402588216332580be3950b92"
|
||||
@@ -5236,14 +5208,6 @@ ember-fetch@^3.4.3:
|
||||
node-fetch "^2.0.0-alpha.9"
|
||||
whatwg-fetch "^2.0.3"
|
||||
|
||||
ember-getowner-polyfill@^2.0.1:
|
||||
version "2.2.0"
|
||||
resolved "https://registry.yarnpkg.com/ember-getowner-polyfill/-/ember-getowner-polyfill-2.2.0.tgz#38e7dccbcac69d5ec694000329ec0b2be651d2b2"
|
||||
integrity sha512-rwGMJgbGzxIAiWYjdpAh04Abvt0s3HuS/VjHzUFhVyVg2pzAuz45B9AzOxYXzkp88vFC7FPaiA4kE8NxNk4A4Q==
|
||||
dependencies:
|
||||
ember-cli-version-checker "^2.1.0"
|
||||
ember-factory-for-polyfill "^1.3.1"
|
||||
|
||||
ember-inflector@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/ember-inflector/-/ember-inflector-3.0.0.tgz#7e1ee8aaa0fa773ba0905d8b7c0786354d890ee1"
|
||||
@@ -5265,16 +5229,6 @@ ember-load-initializers@^1.1.0:
|
||||
dependencies:
|
||||
ember-cli-babel "^6.6.0"
|
||||
|
||||
ember-macro-helpers@^0.17.0:
|
||||
version "0.17.1"
|
||||
resolved "https://registry.yarnpkg.com/ember-macro-helpers/-/ember-macro-helpers-0.17.1.tgz#34836e9158cc260ee1c540935371d11f52ec98d9"
|
||||
integrity sha1-NINukVjMJg7hxUCTU3HRH1LsmNk=
|
||||
dependencies:
|
||||
ember-cli-babel "^6.6.0"
|
||||
ember-cli-string-utils "^1.1.0"
|
||||
ember-cli-test-info "^1.0.0"
|
||||
ember-weakmap "^3.0.0"
|
||||
|
||||
ember-maybe-import-regenerator@^0.1.5, ember-maybe-import-regenerator@^0.1.6:
|
||||
version "0.1.6"
|
||||
resolved "https://registry.yarnpkg.com/ember-maybe-import-regenerator/-/ember-maybe-import-regenerator-0.1.6.tgz#35d41828afa6d6a59bc0da3ce47f34c573d776ca"
|
||||
@@ -5292,15 +5246,6 @@ ember-maybe-in-element@^0.1.3:
|
||||
dependencies:
|
||||
ember-cli-babel "^6.11.0"
|
||||
|
||||
ember-moment@^7.7.0:
|
||||
version "7.7.0"
|
||||
resolved "https://registry.yarnpkg.com/ember-moment/-/ember-moment-7.7.0.tgz#febf7cc5bfc665c8f1d45fa24e5c7a5f5f91afa5"
|
||||
integrity sha512-o+FLIOAiIWVs+q6OPE7+SzNTHIdmK6HaOJwiZsB0nIseHPASBTsf8s/qj936dVsgfNfsPnHKgbwbnbA6+vDNdA==
|
||||
dependencies:
|
||||
ember-cli-babel "^6.7.2"
|
||||
ember-getowner-polyfill "^2.0.1"
|
||||
ember-macro-helpers "^0.17.0"
|
||||
|
||||
ember-native-dom-helpers@^0.5.3:
|
||||
version "0.5.10"
|
||||
resolved "https://registry.yarnpkg.com/ember-native-dom-helpers/-/ember-native-dom-helpers-0.5.10.tgz#9c7172e4ddfa5dd86830c46a936e2f8eca3e5896"
|
||||
@@ -5437,15 +5382,6 @@ ember-truth-helpers@^2.1.0:
|
||||
dependencies:
|
||||
ember-cli-babel "^6.6.0"
|
||||
|
||||
ember-weakmap@^3.0.0:
|
||||
version "3.3.1"
|
||||
resolved "https://registry.yarnpkg.com/ember-weakmap/-/ember-weakmap-3.3.1.tgz#5188b035f5bfb17397067ea635300ae4e1205e11"
|
||||
integrity sha512-pClKGFyByX03R2Y9ZogXHWXreeHzFZcuZj8EOOqj7fVYx0QDNiXBWo+jGhTl/pINlvjw4Z6fMFHlItrq1tZFxA==
|
||||
dependencies:
|
||||
browserslist "^3.1.1"
|
||||
debug "^3.1.0"
|
||||
ember-cli-babel "^6.6.0"
|
||||
|
||||
emojis-list@^2.0.0:
|
||||
version "2.1.0"
|
||||
resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-2.1.0.tgz#4daa4d9db00f9819880c79fa457ae5b09a1fd389"
|
||||
@@ -8774,11 +8710,6 @@ lodash.debounce@^4.0.8:
|
||||
resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af"
|
||||
integrity sha1-gteb/zCmfEAF/9XiUVMArZyk168=
|
||||
|
||||
lodash.defaults@^4.2.0:
|
||||
version "4.2.0"
|
||||
resolved "https://registry.yarnpkg.com/lodash.defaults/-/lodash.defaults-4.2.0.tgz#d09178716ffea4dde9e5fb7b37f6f0802274580c"
|
||||
integrity sha1-0JF4cW/+pN3p5ft7N/bwgCJ0WAw=
|
||||
|
||||
lodash.defaults@~2.3.0:
|
||||
version "2.3.0"
|
||||
resolved "https://registry.yarnpkg.com/lodash.defaults/-/lodash.defaults-2.3.0.tgz#a832b001f138f3bb9721c2819a2a7cc5ae21ed25"
|
||||
@@ -9697,18 +9628,6 @@ modify-values@^1.0.0:
|
||||
resolved "https://registry.yarnpkg.com/modify-values/-/modify-values-1.0.1.tgz#b3939fa605546474e3e3e3c63d64bd43b4ee6022"
|
||||
integrity sha512-xV2bxeN6F7oYjZWTe/YPAy6MN2M+sL4u/Rlm2AHCIVGfo2p1yGmBHQ6vHehl4bRTZBdHu3TSkWdYgkwpYzAGSw==
|
||||
|
||||
moment-timezone@^0.5.13:
|
||||
version "0.5.21"
|
||||
resolved "https://registry.yarnpkg.com/moment-timezone/-/moment-timezone-0.5.21.tgz#3cba247d84492174dbf71de2a9848fa13207b845"
|
||||
integrity sha512-j96bAh4otsgj3lKydm3K7kdtA3iKf2m6MY2iSYCzCm5a1zmHo1g+aK3068dDEeocLZQIS9kU8bsdQHLqEvgW0A==
|
||||
dependencies:
|
||||
moment ">= 2.9.0"
|
||||
|
||||
"moment@>= 2.9.0", moment@^2.19.3:
|
||||
version "2.22.2"
|
||||
resolved "https://registry.yarnpkg.com/moment/-/moment-2.22.2.tgz#3c257f9839fc0e93ff53149632239eb90783ff66"
|
||||
integrity sha1-PCV/mDn8DpP/UxSWMiOeuQeD/2Y=
|
||||
|
||||
moo-server@*, moo-server@1.3.x:
|
||||
version "1.3.0"
|
||||
resolved "https://registry.yarnpkg.com/moo-server/-/moo-server-1.3.0.tgz#5dc79569565a10d6efed5439491e69d2392e58f1"
|
||||
|
||||
Reference in New Issue
Block a user