diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2017-08-24 22:05:31 +0200 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2017-08-24 22:05:31 +0200 |
| commit | dc3fdd74ee240227a23a5fd4e7ce45b17cfe7cbb (patch) | |
| tree | d7353b3beba6ef6470b68c6077e60af11e39c927 | |
| parent | adc86a0de57367d0243a4f7dc08c87840f421b39 (diff) | |
| parent | 81cc03093c05d54d79804595dd0354b1f878cdcd (diff) | |
| download | mullvadvpn-dc3fdd74ee240227a23a5fd4e7ce45b17cfe7cbb.tar.xz mullvadvpn-dc3fdd74ee240227a23a5fd4e7ce45b17cfe7cbb.zip | |
Merge branch 'rename-to-expiry'
| -rw-r--r-- | app/components/Account.js | 8 | ||||
| -rw-r--r-- | app/components/Connect.js | 6 | ||||
| -rw-r--r-- | app/components/Settings.js | 14 | ||||
| -rw-r--r-- | app/containers/ConnectPage.js | 2 | ||||
| -rw-r--r-- | app/lib/backend.js | 4 | ||||
| -rw-r--r-- | app/lib/ipc-facade.js | 6 | ||||
| -rw-r--r-- | app/redux/account/actions.js | 6 | ||||
| -rw-r--r-- | app/redux/account/reducers.js | 8 | ||||
| -rw-r--r-- | test/autologin.spec.js | 6 | ||||
| -rw-r--r-- | test/components/Account.spec.js | 4 | ||||
| -rw-r--r-- | test/components/Connect.spec.js | 3 | ||||
| -rw-r--r-- | test/components/Login.spec.js | 2 | ||||
| -rw-r--r-- | test/components/Settings.spec.js | 6 | ||||
| -rw-r--r-- | test/login.spec.js | 4 | ||||
| -rw-r--r-- | test/logout.spec.js | 4 | ||||
| -rw-r--r-- | test/mocks/ipc.js | 2 |
16 files changed, 42 insertions, 43 deletions
diff --git a/app/components/Account.js b/app/components/Account.js index 41b26fdfbf..12ef0c1938 100644 --- a/app/components/Account.js +++ b/app/components/Account.js @@ -19,10 +19,10 @@ export default class Account extends Component { props: AccountProps; render(): React.Element<*> { - const paidUntil = moment(this.props.account.paidUntil); + const expiry = moment(this.props.account.expiry); const formattedAccountId = formatAccount(this.props.account.accountNumber || ''); - const formattedPaidUntil = paidUntil.format('hA, D MMMM YYYY').toUpperCase(); - const isOutOfTime = paidUntil.isSameOrBefore(moment()); + const formattedExpiry = expiry.format('hA, D MMMM YYYY').toUpperCase(); + const isOutOfTime = expiry.isSameOrBefore(moment()); return ( <Layout> @@ -54,7 +54,7 @@ export default class Account extends Component { <div className="account__out-of-time account__row-value account__row-value--error">OUT OF TIME</div> </Then> <Else> - <div className="account__row-value">{ formattedPaidUntil }</div> + <div className="account__row-value">{ formattedExpiry }</div> </Else> </If> </div> diff --git a/app/components/Connect.js b/app/components/Connect.js index c67e72f696..ba74fb311a 100644 --- a/app/components/Connect.js +++ b/app/components/Connect.js @@ -13,7 +13,7 @@ import type { HeaderBarStyle } from './HeaderBar'; import type { ConnectionReduxState } from '../redux/connection/reducers'; export type ConnectProps = { - accountPaidUntil: string, + accountExpiry: string, connection: ConnectionReduxState, preferredServer: string, onSettings: () => void, @@ -367,8 +367,8 @@ export default class Connect extends Component { } // No credit? - const paidUntil = this.props.accountPaidUntil; - if(paidUntil && moment(paidUntil).isSameOrBefore(moment())) { + const expiry = this.props.accountExpiry; + if(expiry && moment(expiry).isSameOrBefore(moment())) { return new BackendError('NO_CREDIT'); } diff --git a/app/components/Settings.js b/app/components/Settings.js index df6947a258..7e71c8dbd2 100644 --- a/app/components/Settings.js +++ b/app/components/Settings.js @@ -32,13 +32,13 @@ export default class Settings extends Component { render(): React.Element<*> { const isLoggedIn = this.props.account.status === 'ok'; - let isOutOfTime = false, formattedPaidUntil = ''; - let paidUntilIso = this.props.account.paidUntil; + let isOutOfTime = false, formattedExpiry = ''; + let expiryIso = this.props.account.expiry; - if(isLoggedIn && paidUntilIso) { - let paidUntil = moment(this.props.account.paidUntil); - isOutOfTime = paidUntil.isSameOrBefore(moment()); - formattedPaidUntil = paidUntil.fromNow(true) + ' left'; + if(isLoggedIn && expiryIso) { + let expiry = moment(this.props.account.expiry); + isOutOfTime = expiry.isSameOrBefore(moment()); + formattedExpiry = expiry.fromNow(true) + ' left'; } return ( @@ -68,7 +68,7 @@ export default class Settings extends Component { <span className="settings__account-paid-until-label settings__account-paid-until-label--error">OUT OF TIME</span> </Then> <Else> - <span className="settings__account-paid-until-label">{ formattedPaidUntil }</span> + <span className="settings__account-paid-until-label">{ formattedExpiry }</span> </Else> </If> </div> diff --git a/app/containers/ConnectPage.js b/app/containers/ConnectPage.js index 495d1c6672..ceb16054ce 100644 --- a/app/containers/ConnectPage.js +++ b/app/containers/ConnectPage.js @@ -8,7 +8,7 @@ import connectActions from '../redux/connection/actions'; const mapStateToProps = (state) => { return { - accountPaidUntil: state.account.paidUntil, + accountExpiry: state.account.expiry, connection: state.connection, preferredServer: state.settings.preferredServer, }; diff --git a/app/lib/backend.js b/app/lib/backend.js index 6d5c4ebd14..ee11feee9d 100644 --- a/app/lib/backend.js +++ b/app/lib/backend.js @@ -163,7 +163,7 @@ export class Backend { }).then( accountData => { log.info('Log in complete'); - this._store.dispatch(accountActions.loginSuccessful(accountData.paid_until)); + this._store.dispatch(accountActions.loginSuccessful(accountData.expiry)); // Redirect the user after some time to allow for // the 'Login Successful' screen to be visible @@ -197,7 +197,7 @@ export class Backend { .then( accountData => { log.info('The stored account number still exists', accountData); - this._store.dispatch(accountActions.loginSuccessful(accountData.paid_until)); + this._store.dispatch(accountActions.loginSuccessful(accountData.expiry)); this._store.dispatch(push('/connect')); }) diff --git a/app/lib/ipc-facade.js b/app/lib/ipc-facade.js index 2620f7958c..798b4d2805 100644 --- a/app/lib/ipc-facade.js +++ b/app/lib/ipc-facade.js @@ -6,7 +6,7 @@ import { validate } from 'validated/object'; import type { Coordinate2d } from '../types'; -export type AccountData = {paid_until: string}; +export type AccountData = {expiry: string}; export type AccountNumber = string; export type Ip = string; export type Location = { @@ -55,10 +55,10 @@ export class RealIpc implements IpcFacade { getAccountData(accountNumber: AccountNumber): Promise<AccountData> { return this._ipc.send('get_account_data', accountNumber) .then(raw => { - if (typeof raw === 'object' && raw && raw.paid_until) { + if (typeof raw === 'object' && raw && raw.expiry) { return raw; } else { - throw new InvalidReply(raw, 'Expected an object with paid_until'); + throw new InvalidReply(raw, 'Expected an object with expiry'); } }); } diff --git a/app/redux/account/actions.js b/app/redux/account/actions.js index fb45109471..cae9b22187 100644 --- a/app/redux/account/actions.js +++ b/app/redux/account/actions.js @@ -8,7 +8,7 @@ type StartLoginAction = { }; type LoginSuccessfulAction = { type: 'LOGIN_SUCCESSFUL', - paidUntil: string, + expiry: string, }; type LoginFailedAction = { type: 'LOGIN_FAILED', @@ -31,10 +31,10 @@ function startLogin(accountNumber?: string): StartLoginAction { }; } -function loginSuccessful(paidUntil: string): LoginSuccessfulAction { +function loginSuccessful(expiry: string): LoginSuccessfulAction { return { type: 'LOGIN_SUCCESSFUL', - paidUntil: paidUntil, + expiry: expiry, }; } diff --git a/app/redux/account/reducers.js b/app/redux/account/reducers.js index d6458e20dd..504cbe4e15 100644 --- a/app/redux/account/reducers.js +++ b/app/redux/account/reducers.js @@ -6,14 +6,14 @@ import type { BackendError } from '../../lib/backend'; export type LoginState = 'none' | 'logging in' | 'failed' | 'ok'; export type AccountReduxState = { accountNumber: ?string, - paidUntil: ?string, // ISO8601 + expiry: ?string, // ISO8601 status: LoginState, error: ?BackendError }; const initialState: AccountReduxState = { accountNumber: null, - paidUntil: null, + expiry: null, status: 'none', error: null }; @@ -33,7 +33,7 @@ export default function(state: AccountReduxState = initialState, action: ReduxAc return { ...state, ...{ status: 'ok', error: null, - paidUntil: action.paidUntil, + expiry: action.expiry, }}; case 'LOGIN_FAILED': return { ...state, ...{ @@ -45,7 +45,7 @@ export default function(state: AccountReduxState = initialState, action: ReduxAc return { ...state, ...{ status: 'none', accountNumber: null, - paidUntil: null, + expiry: null, error: null, }}; } diff --git a/test/autologin.spec.js b/test/autologin.spec.js index 0c031b15ca..b8051d800b 100644 --- a/test/autologin.spec.js +++ b/test/autologin.spec.js @@ -84,7 +84,7 @@ describe('autologin', () => { const { store, backend, mockIpc } = setupBackendAndStore(); mockIpc.getAccount = () => new Promise(r => r('123')); mockIpc.getAccountData = () => new Promise(r => r({ - paid_until: '2001-01-01T00:00:00', + expiry: '2001-01-01T00:00:00Z', })); return backend.autologin() @@ -92,7 +92,7 @@ describe('autologin', () => { const state = store.getState().account; expect(state.status).to.equal('ok'); expect(state.accountNumber).to.equal('123'); - expect(state.paidUntil).to.equal('2001-01-01T00:00:00'); + expect(state.expiry).to.equal('2001-01-01T00:00:00Z'); }); }); @@ -101,7 +101,7 @@ describe('autologin', () => { mockIpc.getAccount = () => new Promise(r => r('123')); mockIpc.getAccountData = () => new Promise(r => r({ - paid_until: '2001-01-01T00:00:00', + expiry: '2001-01-01T00:00:00Z', })); return backend.autologin() diff --git a/test/components/Account.spec.js b/test/components/Account.spec.js index 4372ac957e..6ebd4785e2 100644 --- a/test/components/Account.spec.js +++ b/test/components/Account.spec.js @@ -11,7 +11,7 @@ import type { AccountProps } from '../../app/components/Account'; describe('components/Account', () => { const state: AccountReduxState = { accountNumber: '1234', - paidUntil: (new Date('2038-01-01')).toISOString(), + expiry: (new Date('2038-01-01')).toISOString(), status: 'none', error: null }; @@ -59,7 +59,7 @@ describe('components/Account', () => { it('should display "out of time" message when account expired', () => { const expiredState: AccountReduxState = { accountNumber: '1234', - paidUntil: (new Date('2001-01-01')).toISOString(), + expiry: (new Date('2001-01-01')).toISOString(), status: 'none', error: null }; diff --git a/test/components/Connect.spec.js b/test/components/Connect.spec.js index 13700e8cca..d7a20daf2d 100644 --- a/test/components/Connect.spec.js +++ b/test/components/Connect.spec.js @@ -49,8 +49,7 @@ const defaultProps = { onExternalLink: noop, getServerInfo: (_) => { return defaultServer; }, - accountPaidUntil: '', + accountExpiry: '', preferredServer: '', connection: defaultConnection, }; - diff --git a/test/components/Login.spec.js b/test/components/Login.spec.js index d0874d4b74..3af6cb041b 100644 --- a/test/components/Login.spec.js +++ b/test/components/Login.spec.js @@ -85,7 +85,7 @@ describe('components/Login', () => { const defaultAccount = { accountNumber: null, - paidUntil: null, + expiry: null, status: 'none', error: null, }; diff --git a/test/components/Settings.spec.js b/test/components/Settings.spec.js index 705da60098..fd670931e8 100644 --- a/test/components/Settings.spec.js +++ b/test/components/Settings.spec.js @@ -13,21 +13,21 @@ import type { SettingsProps } from '../../app/components/Settings'; describe('components/Settings', () => { const loggedOutAccountState: AccountReduxState = { accountNumber: null, - paidUntil: null, + expiry: null, status: 'none', error: null }; const loggedInAccountState: AccountReduxState = { accountNumber: '1234', - paidUntil: (new Date('2038-01-01')).toISOString(), + expiry: (new Date('2038-01-01')).toISOString(), status: 'ok', error: null }; const unpaidAccountState: AccountReduxState = { accountNumber: '1234', - paidUntil: (new Date('2001-01-01')).toISOString(), + expiry: (new Date('2001-01-01')).toISOString(), status: 'ok', error: null }; diff --git a/test/login.spec.js b/test/login.spec.js index 5c7e0fe540..21564da822 100644 --- a/test/login.spec.js +++ b/test/login.spec.js @@ -31,7 +31,7 @@ describe('Logging in', () => { it('should put the account data in the state', () => { const { store, backend, mockIpc } = setupBackendAndStore(); mockIpc.getAccountData = () => new Promise(r => r({ - paid_until: '2001-01-01T00:00:00', + expiry: '2001-01-01T00:00:00Z', })); return backend.login('123') @@ -39,7 +39,7 @@ describe('Logging in', () => { const state = store.getState().account; expect(state.status).to.equal('ok'); expect(state.accountNumber).to.equal('123'); - expect(state.paidUntil).to.equal('2001-01-01T00:00:00'); + expect(state.expiry).to.equal('2001-01-01T00:00:00Z'); }); }); diff --git a/test/logout.spec.js b/test/logout.spec.js index f88df1bbc6..a5c8b29975 100644 --- a/test/logout.spec.js +++ b/test/logout.spec.js @@ -28,7 +28,7 @@ describe('logging out', () => { const { store, backend, mockIpc } = setupBackendAndStore(); mockIpc.getAccountData = () => new Promise(r => r({ - paid_until: '2001-01-01T00:00:00', + expiry: '2001-01-01T00:00:00.000Z', })); const action: any = accountActions.login(backend, '123'); store.dispatch(action); @@ -36,7 +36,7 @@ describe('logging out', () => { const expectedLogoutState = { status: 'none', accountNumber: null, - paidUntil: null, + expiry: null, error: null, }; diff --git a/test/mocks/ipc.js b/test/mocks/ipc.js index c182d45d21..3acdc2f76d 100644 --- a/test/mocks/ipc.js +++ b/test/mocks/ipc.js @@ -18,7 +18,7 @@ export function newMockIpc() { getAccountData: (accountNumber) => { return new Promise(r => r({ accountNumber: accountNumber, - paid_until: '', + expiry: '', })); }, getAccount: () => { |
