merge with develop branch

This commit is contained in:
Victor Baranov 2018-09-06 19:14:23 +03:00
commit af7919f39a
17 changed files with 307 additions and 334 deletions

View File

@ -25,11 +25,11 @@ workflows:
requires:
- prep-deps-npm
- prep-build
# - test-e2e-firefox:
# requires:
# - prep-deps-npm
# - prep-deps-firefox
# - prep-build
- test-e2e-firefox:
requires:
- prep-deps-npm
- prep-deps-firefox
- prep-build
- test-unit:
requires:
- prep-deps-npm
@ -56,7 +56,7 @@ workflows:
- test-lint
- test-unit
- test-e2e-chrome
# - test-e2e-firefox
- test-e2e-firefox
- test-integration-mascara-chrome
- test-integration-mascara-firefox
- test-integration-flat-chrome
@ -115,12 +115,12 @@ jobs:
steps:
- checkout
- restore_cache:
key: v1.0-dependency-cache-firefox-
key: dependency-cache-firefox-{{ .Revision }}
- run:
name: Download Firefox
command: ./.circleci/scripts/firefox-download.sh
- save_cache:
key: v1.0-dependency-cache-firefox-
key: dependency-cache-firefox-{{ .Revision }}
paths:
- firefox
@ -221,7 +221,7 @@ jobs:
steps:
- checkout
- restore_cache:
key: v1.0-dependency-cache-firefox-
key: dependency-cache-firefox-{{ .Revision }}
- run:
name: Install firefox
command: ./.circleci/scripts/firefox-install.sh
@ -258,7 +258,7 @@ jobs:
steps:
- checkout
- restore_cache:
key: v1.0-dependency-cache-firefox-
key: dependency-cache-firefox-{{ .Revision }}
- run:
name: Install firefox
command: ./.circleci/scripts/firefox-install.sh
@ -372,7 +372,7 @@ jobs:
steps:
- checkout
- restore_cache:
key: v1.0-dependency-cache-firefox-
key: dependency-cache-firefox-{{ .Revision }}
- run:
name: Install firefox
command: ./.circleci/scripts/firefox-install.sh
@ -415,7 +415,7 @@ jobs:
steps:
- checkout
- restore_cache:
key: v1.0-dependency-cache-firefox-
key: dependency-cache-firefox-{{ .Revision }}
- run:
name: Install firefox
command: ./.circleci/scripts/firefox-install.sh

View File

@ -4,7 +4,7 @@ if [ -d "firefox" ]
then
echo "Firefox found. No need to download"
else
FIREFOX_VERSION="61.0.1"
FIREFOX_VERSION="61.0.2"
FIREFOX_BINARY="firefox-$FIREFOX_VERSION.tar.bz2"
echo "Downloading firefox..."
wget "https://ftp.mozilla.org/pub/firefox/releases/$FIREFOX_VERSION/linux-x86_64/en-US/$FIREFOX_BINARY" \

View File

@ -3,7 +3,7 @@
"short_name": "__MSG_appName__",
"version": "4.8.5",
"manifest_version": 2,
"author": "https://metamask.io",
"author": "POA Network",
"description": "__MSG_appDescription__",
"commands": {
"_execute_browser_action": {
@ -21,7 +21,7 @@
},
"applications": {
"gecko": {
"id": "webextension@metamask.io"
"id": "webextension@niftywallet.io"
}
},
"default_locale": "en",

View File

@ -1,13 +1,5 @@
const ethUtil = require('ethereumjs-util')
const normalize = require('eth-sig-util').normalize
const {
MAINNET_RPC_URL,
ROPSTEN_RPC_URL,
KOVAN_RPC_URL,
RINKEBY_RPC_URL,
POA_SOKOL_RPC_URL,
POA_RPC_URL,
} = require('../controllers/network/enums')
/* The config-manager is a convenience object
* wrapping a pojo-migrator.
@ -149,34 +141,6 @@ ConfigManager.prototype.getProvider = function () {
return config.provider
}
ConfigManager.prototype.getCurrentRpcAddress = function () {
var provider = this.getProvider()
if (!provider) return null
switch (provider.type) {
case 'mainnet':
return MAINNET_RPC_URL
case 'ropsten':
return ROPSTEN_RPC_URL
case 'kovan':
return KOVAN_RPC_URL
case 'rinkeby':
return RINKEBY_RPC_URL
case 'sokol':
return POA_SOKOL_RPC_URL
case 'poa':
return POA_RPC_URL
default:
return provider && provider.rpcTarget ? provider.rpcTarget : POA_SOKOL_RPC_URL
}
}
//
// Tx
//

View File

@ -375,7 +375,10 @@ App.prototype.renderNetworkDropdown = function () {
{
key: 'default',
closeMenu: () => this.setState({ isNetworkMenuOpen: !isOpen }),
onClick: () => props.dispatch(actions.setProviderType('localhost')),
onClick: () => {
props.dispatch(actions.setRpcTarget('http://localhost:8545'))
props.dispatch(actions.setProviderType('localhost'))
},
style: {
paddingLeft: '20px',
fontSize: '16px',
@ -387,7 +390,7 @@ App.prototype.renderNetworkDropdown = function () {
]
),
this.renderCustomOption(props.provider),
this.renderSelectedCustomOption(props.provider),
this.renderCommonRpc(rpcList, props.provider),
h(
@ -669,10 +672,9 @@ App.prototype.toggleMetamaskActive = function () {
}
}
App.prototype.renderCustomOption = function (provider) {
App.prototype.renderSelectedCustomOption = function (provider) {
const { rpcTarget, type } = provider
const props = this.props
if (type !== 'rpc') return null
// Concatenate long URLs
@ -683,9 +685,6 @@ App.prototype.renderCustomOption = function (provider) {
switch (rpcTarget) {
case 'http://localhost:8545':
return null
default:
return h(
DropdownMenuItem,
@ -721,10 +720,10 @@ App.prototype.getNetworkName = function () {
App.prototype.renderCommonRpc = function (rpcList, provider) {
const props = this.props
const rpcTarget = provider.rpcTarget
const { rpcTarget, type } = provider
return rpcList.map((rpc) => {
if ((rpc === 'http://localhost:8545') || (provider.type === 'rpc' && rpc === rpcTarget)) {
if (type === 'rpc' && rpc === rpcTarget) {
return null
} else {
return h(

View File

@ -117,31 +117,36 @@ ConfirmChangePassword.prototype.createOnEnter = function (event) {
}
ConfirmChangePassword.prototype.ChangePassword = function () {
const oldPasswordBox = this.refs.OldPasswordBox
const { props, refs } = this
const oldPasswordBox = refs.OldPasswordBox
const oldPassword = oldPasswordBox.value
const newPasswordBox = this.refs.NewPasswordBox
const newPasswordBox = refs.NewPasswordBox
const newPassword = newPasswordBox.value
const newPasswordConfirmBox = this.refs.PasswordBoxConfirm
const newPasswordConfirmBox = refs.PasswordBoxConfirm
const newPasswordConfirm = newPasswordConfirmBox.value
if (newPassword.length < 8) {
this.warning = 'Password not long enough'
this.props.dispatch(actions.displayWarning(this.warning))
props.dispatch(actions.displayWarning(this.warning))
return
}
if (newPassword !== newPasswordConfirm) {
this.warning = 'Passwords don\'t match'
this.props.dispatch(actions.displayWarning(this.warning))
props.dispatch(actions.displayWarning(this.warning))
return
}
if (newPassword === oldPassword) {
this.warning = 'New password should differ from the current one'
this.props.dispatch(actions.displayWarning(this.warning))
props.dispatch(actions.displayWarning(this.warning))
return
}
this.props.dispatch(actions.changePassword(oldPassword, newPassword))
props.dispatch(actions.changePassword(oldPassword, newPassword))
.then(() => {
this.props.dispatch(actions.showConfigPage())
props.dispatch(actions.showConfigPage())
})
.catch((err) => {
this.warning = err
props.dispatch(actions.displayWarning(this.warning))
})
}

View File

@ -61,8 +61,8 @@ Network.prototype.render = function () {
displayName = 'POA Network'
hoverText = ethNetProps.props.getNetworkDisplayName(networkNumber)
} else {
hoverText = (provider.type === 'rpc') ? `Private Network (${provider.rpcTarget})` : `Private Network (${provider.type})`
displayName = 'Private Network'
hoverText = `Private Network (${provider.rpcTarget})`
}
}

View File

@ -26,6 +26,7 @@ html, body {
html {
min-height: 500px;
overflow: -moz-scrollbars-none;
}
.account-detail-section::-webkit-scrollbar {
@ -331,7 +332,7 @@ p.exchanges {
height: 14px;
}
.arrow-right {
.arrow-right::before {
content: url('../images/arrow-right.svg');
width: 14px;
height: 14px;
@ -593,7 +594,8 @@ input.large-input {
display: flex;
flex-wrap: wrap;
overflow-x: hidden;
overflow-y: auto;
/*overflow-y: auto;*/
overflow-y: -moz-scrollbars-none;
max-height: 585px;
flex-direction: inherit;
}
@ -994,13 +996,13 @@ div.message-container > div:first-child {
word-wrap: break-word;
}
.contract {
.contract::after {
content: url('../images/contract.svg');
width: 36px;
height: 42px;
}
.contract-small {
.contract-small::after {
content: url('../images/contract-small.svg');
width: 19px;
height: 22px;

View File

@ -4,6 +4,7 @@ const h = require('react-hyperscript')
const connect = require('react-redux').connect
const actions = require('../../ui/app/actions')
const getCaretCoordinates = require('textarea-caret')
const log = require('loglevel')
const EventEmitter = require('events').EventEmitter
// const Mascot = require('./components/mascot')
@ -93,10 +94,14 @@ UnlockScreen.prototype.componentDidMount = function () {
document.getElementById('password-box').focus()
}
UnlockScreen.prototype.onSubmit = function (event) {
UnlockScreen.prototype.onSubmit = async function (event) {
const input = document.getElementById('password-box')
const password = input.value
this.props.dispatch(actions.tryUnlockMetamask(password))
try {
await this.props.dispatch(actions.tryUnlockMetamask(password))
} catch (e) {
log.error(e)
}
}
UnlockScreen.prototype.onKeyPress = function (event) {
@ -105,12 +110,16 @@ UnlockScreen.prototype.onKeyPress = function (event) {
}
}
UnlockScreen.prototype.submitPassword = function (event) {
UnlockScreen.prototype.submitPassword = async function (event) {
var element = event.target
var password = element.value
// reset input
element.value = ''
this.props.dispatch(actions.tryUnlockMetamask(password))
try {
await this.props.dispatch(actions.tryUnlockMetamask(password))
} catch (e) {
log.error(e)
}
}
UnlockScreen.prototype.inputChanged = function (event) {

31
package-lock.json generated
View File

@ -8579,9 +8579,9 @@
}
},
"eth-keychain-controller": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/eth-keychain-controller/-/eth-keychain-controller-4.0.1.tgz",
"integrity": "sha512-4SR3+JxSrlCjyM6FfAlH73vr9zZ3n1nWuspAlF0B40fDDipjPouc+KqxKeqXHgQoAYm3Rub2OUVUfj9V0KqiBA==",
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/eth-keychain-controller/-/eth-keychain-controller-4.0.2.tgz",
"integrity": "sha512-1NbyfdrmniEwcXdYhVeKRbw9JkqZRRexBM2QRydf613htE0jxzmQZaTMvMKV4rNL/S3fxYPd1AbLhQ3lZRiffw==",
"dev": true,
"requires": {
"bip39": "^2.4.0",
@ -8826,24 +8826,13 @@
},
"dependencies": {
"eth-sig-util": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/eth-sig-util/-/eth-sig-util-2.0.1.tgz",
"integrity": "sha512-lxHZOQspexk3DaGj4RBbWy4C/qNOWRnxpaJzNnYD3WEmC8shcJ4tHs7Xv878rzvILfJnSFSCCiKQhng1m80oBQ==",
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/eth-sig-util/-/eth-sig-util-2.0.2.tgz",
"integrity": "sha512-tB6E8jf/aZQ943bo3+iojl8xRe3Jzcl+9OT6v8K7kWis6PdIX19SB2vYvN849cB9G9m/XLjYFK381SgdbsnpTA==",
"dev": true,
"requires": {
"ethereumjs-abi": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
"ethereumjs-abi": "0.6.5",
"ethereumjs-util": "^5.1.1"
},
"dependencies": {
"ethereumjs-abi": {
"version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git",
"dev": true,
"requires": {
"bn.js": "^4.10.0",
"ethereumjs-util": "^5.0.0"
}
}
}
},
"ethereumjs-util": {
@ -27902,9 +27891,9 @@
}
},
"selenium-webdriver": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/selenium-webdriver/-/selenium-webdriver-3.6.0.tgz",
"integrity": "sha512-WH7Aldse+2P5bbFBO4Gle/nuQOdVwpHMTL6raL3uuBj/vPG07k6uzt3aiahu352ONBr5xXh0hDlM3LhtXPOC4Q==",
"version": "4.0.0-alpha.1",
"resolved": "https://registry.npmjs.org/selenium-webdriver/-/selenium-webdriver-4.0.0-alpha.1.tgz",
"integrity": "sha512-z88rdjHAv3jmTZ7KSGUkTvo4rGzcDGMq0oXWHNIDK96Gs31JKVdu9+FMtT4KBrVoibg8dUicJDok6GnqqttO5Q==",
"dev": true,
"requires": {
"jszip": "^3.1.3",

View File

@ -247,7 +247,7 @@
"eslint-plugin-mocha": "^5.0.0",
"eslint-plugin-react": "^7.4.0",
"eth-json-rpc-middleware": "^1.6.0",
"eth-keychain-controller": "^4.0.1",
"eth-keychain-controller": "^4.0.2",
"file-loader": "^1.1.11",
"fs-promise": "^2.0.3",
"ganache-cli": "^6.1.0",
@ -306,7 +306,7 @@
"resolve-url-loader": "^2.3.0",
"rimraf": "^2.6.2",
"sass-loader": "^7.0.1",
"selenium-webdriver": "^3.5.0",
"selenium-webdriver": "^4.0.0-alpha.1",
"shell-parallel": "^1.0.3",
"sinon": "^5.0.0",
"source-map": "^0.7.2",

View File

@ -123,14 +123,22 @@ module.exports = {
changePassword: {
title: By.className('page-subtitle'),
titleText: 'Change Password',
fieldOldPassword: By.id('old-password-box'),
fieldNewPassword: By.id('new-password-box'),
fieldConfirmNewPassword: By.id('password-box-confirm'),
buttonNo: By.css('#app-content > div > div.app-primary.from-right > div > div.flex-row.flex-right > button.btn-violet'),
buttonYes: By.css('#app-content > div > div.app-primary.from-right > div > div.flex-row.flex-right > button:nth-child(2)'),
label: By.className('confirm-label'),
arrowLeft: By.className('fa fa-arrow-left fa-lg cursor-pointer'),
error: By.className('error'),
ById: {
fieldOldPassword: 'old-password-box',
fieldNewPassword: 'new-password-box',
fieldConfirmNewPassword: 'password-box-confirm',
},
ByCss: {
buttonNo: '#app-content > div > div.app-primary.from-right > div > div.flex-row.flex-right > button.btn-violet',
buttonYes: '#app-content > div > div.app-primary.from-right > div > div.flex-row.flex-right > button:nth-child(2)',
subtitle: '#app-content > div > div.app-primary.from-right > div > div.section-title.flex-row.flex-center > h2',
label: '#app-content > div > div.app-primary.from-right > div > p',
},
ByClassName: {
label: 'confirm-label',
arrowLeft: 'fa fa-arrow-left fa-lg cursor-pointer',
error: 'error',
},
labelText: 'Are you sure you want to change the password for unlocking of your wallet?',
errorText: {
differ: 'New password should differ from the current one',

View File

@ -61,7 +61,7 @@ async function installWebExt (driver, extension) {
await driver.getExecutor()
.defineCommand(cmd.getName(), 'POST', '/session/:sessionId/moz/addon/install')
return await driver.schedule(cmd, 'installWebExt(' + extension + ')')
return await driver.execute(cmd, 'installWebExt(' + extension + ')')
}
async function clearField (field, number) {

View File

@ -158,221 +158,230 @@ describe('Metamask popup page', async function () {
})
})
describe('Change password', async () => {
const newPassword = {
correct: 'abcDEF123!@#',
short: '123',
incorrect: '1234567890',
}
let fieldNewPassword
let fieldConfirmNewPassword
let fieldOldPassword
let buttonYes
// it doesn't work for Firefox in Circle CI
if (process.env.SELENIUM_BROWSER === 'chrome') {
describe('Change password', async () => {
const newPassword = {
correct: 'abcDEF123!@#',
short: '123',
incorrect: '1234567890',
}
let fieldNewPassword
let fieldConfirmNewPassword
let fieldOldPassword
let buttonYes
describe('Check screen "Settings" -> "Change password" ', async () => {
describe('Check screen "Settings" -> "Change password" ', async () => {
it('checks if "Change password" button is present and enabled', async () => {
await driver.findElement(menus.sandwich.menu).click()
it('checks if "Change password" button is present and enabled', async () => {
await driver.findElement(By.css(menus.sandwich.menu)).click()
await delay(500)
await driver.findElement(By.css(menus.sandwich.settings)).click()
await delay(500)
const buttons = await driver.findElements(By.css(screens.settings.buttons.changePassword))
assert.equal(buttons.length, 1, 'Button "Change password" is not present')
assert.equal(await buttons[0].isEnabled(), true, 'Button "Change password" is disabled')
})
it('screen contains correct title', async () => {
const button = await driver.findElement(By.css(screens.settings.buttons.changePassword))
await delay(500)
await driver.executeScript('arguments[0].scrollIntoView(true)', button)
await delay(700)
await button.click()
await delay(500)
const title = await driver.findElement(By.css(screens.changePassword.ByCss.subtitle))
assert.equal(await title.getText(), screens.changePassword.titleText, '"Change password" screen contains incorrect title')
})
it('screen contains correct label', async () => {
const labels = await driver.findElements(By.css(screens.changePassword.ByCss.label))
assert.equal(labels.length, 1, 'screen "Change password" doesn\'t contain label')
assert.equal(await labels[0].getText(), screens.changePassword.labelText, 'label contains incorrect title')
})
it('clicking the button "No" bring back to "Setting" screen ', async () => {
const button = await driver.findElement(By.css(screens.changePassword.ByCss.buttonNo))
await button.click()
const title = await driver.findElement(By.css(screens.settings.title))
assert.equal(await title.getText(), screens.settings.titleText, 'button "No" doesnt open settings screen')
const buttonChangePass = await driver.findElement(By.css(screens.settings.buttons.changePassword))
await buttonChangePass.click()
})
})
describe('Validation of errors ', async () => {
before(async () => {
fieldOldPassword = await driver.findElement(By.id(screens.changePassword.ById.fieldOldPassword))
await fieldOldPassword.sendKeys(password)
fieldNewPassword = await driver.findElement(By.id(screens.changePassword.ById.fieldNewPassword))
fieldConfirmNewPassword = await driver.findElement(By.id(screens.changePassword.ById.fieldConfirmNewPassword))
buttonYes = await driver.findElement(By.css(screens.changePassword.ByCss.buttonYes))
})
it('error if new password shorter than 8 digits', async () => {
await fieldNewPassword.sendKeys(newPassword.short)
await fieldConfirmNewPassword.sendKeys(newPassword.short)
await buttonYes.click()
const errors = await driver.findElements(By.className(screens.changePassword.ByClassName.error))
assert.equal(errors.length > 0, true, 'error isn\'t displayed')
assert.equal(await errors[0].getText(), screens.changePassword.error.notLong, 'Error\'s text incorrect')
})
it('error if new password doesn\'t match confirmation', async () => {
await clearField(fieldNewPassword)
await clearField(fieldConfirmNewPassword)
await fieldNewPassword.sendKeys(newPassword.correct)
await fieldConfirmNewPassword.sendKeys(newPassword.incorrect)
await buttonYes.click()
const errors = await driver.findElements(By.className(screens.changePassword.ByClassName.error))
assert.equal(errors.length > 0, true, 'error isn\'t displayed')
assert.equal(await errors[0].getText(), screens.changePassword.error.dontMatch, 'Error\'s text incorrect')
})
it('error if new password match old password', async () => {
await clearField(fieldNewPassword)
await clearField(fieldConfirmNewPassword)
await fieldNewPassword.sendKeys(password)
await fieldConfirmNewPassword.sendKeys(password)
await buttonYes.click()
const errors = await driver.findElements(By.className(screens.changePassword.ByClassName.error))
assert.equal(errors.length > 0, true, 'error isn\'t displayed')
assert.equal(await errors[0].getText(), screens.changePassword.error.differ, 'Error\'s text incorrect')
})
it.skip('error if old password incorrect, https://github.com/poanetwork/metamask-extension/issues/86 ', async () => {
await clearField(fieldOldPassword)
await fieldOldPassword.sendKeys(newPassword.incorrect)
await buttonYes.click()
const errors = await driver.findElements(By.className(screens.changePassword.ByClassName.error))
assert.equal(errors.length > 0, true, 'error isn\'t displayed')
assert.equal(await errors[0].getText(), screens.changePassword.error.incorrectPassword, 'Error\'s text incorrect')
})
it('no errors if old, new, confirm new passwords are correct; user can change password', async () => {
await clearField(fieldNewPassword)
await clearField(fieldOldPassword)
await clearField(fieldConfirmNewPassword)
await fieldOldPassword.sendKeys(password)
await fieldNewPassword.sendKeys(newPassword.correct)
await fieldConfirmNewPassword.sendKeys(newPassword.correct)
await buttonYes.click()
await driver.wait(until.elementLocated(By.css(screens.settings.buttons.changePassword)))
const buttons = await driver.findElements(By.css(screens.settings.buttons.changePassword))
assert.equal(buttons.length, 1, 'Button "Change password" is not present')
assert.equal(await buttons[0].isEnabled(), true, 'Button "Change password" is disabled')
})
})
describe('Check if new password is accepted', async () => {
it('user can log out', async () => {
await driver.findElement(By.css(menus.sandwich.menu)).click()
await delay(500)
await driver.wait(until.elementLocated(By.css(menus.sandwich.logOut)))
const itemLogOut = await driver.findElement(By.css(menus.sandwich.logOut))
await driver.wait(until.elementIsVisible(itemLogOut))
itemLogOut.click()
await driver.wait(until.elementLocated(By.id(screens.lock.fieldPassword)))
const fields = await driver.findElements(By.id(screens.lock.fieldPassword))
assert.equal(fields.length, 1, 'password box isn\'t present after logout')
})
it.skip('can\'t login with old password', async () => {
const field = await driver.findElement(By.id(screens.lock.fieldPassword))
await field.sendKeys(password)
await driver.findElement(By.className(screens.lock.buttonLogin)).click()
const errors = await driver.findElements(By.className(screens.lock.error))
assert.equal(errors.length, 1, 'error isn\'t displayed if password incorrect')
assert.equal(await errors[0].getText(), screens.lock.errorText, 'error\'s text incorrect')
})
it('accepts new password after lock', async () => {
const field = await driver.findElement(By.id(screens.lock.fieldPassword))
await field.sendKeys(newPassword.correct)
await driver.findElement(By.className(screens.lock.buttonLogin)).click()
await driver.wait(until.elementLocated(By.css(screens.main.buttons.buy)))
const buttons = await driver.findElements(By.css(screens.main.buttons.buy))
assert.equal(buttons.length, 1, 'main screen isn\'t displayed')
password = newPassword.correct
})
})
})
}
// it doesn't work for Firefox in Circle CI
if (process.env.SELENIUM_BROWSER === 'chrome') {
describe('Import Account', () => {
it('opens import account menu', async function () {
await driver.wait(until.elementLocated(By.css(menus.account.menu)))
await driver.findElement(By.css(menus.account.menu)).click()
await delay(500)
await driver.findElement(menus.sandwich.settings).click()
await driver.findElement(By.css(menus.account.import)).click()
await delay(500)
const buttons = await driver.findElements(screens.settings.buttons.changePassword)
assert.equal(buttons.length, 1, 'Button "Change password" is not present')
assert.equal(await buttons[0].isEnabled(), true, 'Button "Change password" is disabled')
const importAccountTitle = await driver.findElement(By.css(screens.importAccounts.title))
assert.equal(await importAccountTitle.getText(), screens.importAccounts.textTitle)
})
it('screen contains correct title', async () => {
const button = await driver.findElement(screens.settings.buttons.changePassword)
await button.click()
const title = await driver.findElement(screens.changePassword.title)
assert.equal(await title.getText(), screens.changePassword.titleText, '"Change password" screen contains incorrect title')
})
it('screen contains correct label', async () => {
const labels = await driver.findElements(screens.changePassword.label)
assert.equal(labels.length, 1, 'screen "Change password" doesn\'t contain label')
assert.equal(await labels[0].getText(), screens.changePassword.labelText, 'label contains incorrect title')
})
it('clicking the button "No" bring back to "Setting" screen ', async () => {
const button = await driver.findElement(screens.changePassword.buttonNo)
await button.click()
const title = await driver.findElement(screens.settings.title)
assert.equal(await title.getText(), screens.settings.titleText, 'button "No" doesnt open settings screen')
const buttonChangePass = await driver.findElement(screens.settings.buttons.changePassword)
await buttonChangePass.click()
})
})
describe('Validation of errors ', async () => {
before(async () => {
fieldOldPassword = await driver.findElement(screens.changePassword.fieldOldPassword)
await fieldOldPassword.sendKeys(password)
fieldNewPassword = await driver.findElement(screens.changePassword.fieldNewPassword)
fieldConfirmNewPassword = await driver.findElement(screens.changePassword.fieldConfirmNewPassword)
buttonYes = await driver.findElement(screens.changePassword.buttonYes)
})
it('error if new password shorter than 8 digits', async () => {
await fieldNewPassword.sendKeys(newPassword.short)
await fieldConfirmNewPassword.sendKeys(newPassword.short)
await buttonYes.click()
const errors = await driver.findElements(screens.changePassword.error)
assert.equal(errors.length > 0, true, 'error isn\'t displayed')
assert.equal(await errors[0].getText(), screens.changePassword.errorText.notLong, 'Error\'s text incorrect')
})
it('error if new password doesn\'t match confirmation', async () => {
await clearField(fieldNewPassword)
await clearField(fieldConfirmNewPassword)
await fieldNewPassword.sendKeys(newPassword.correct)
await fieldConfirmNewPassword.sendKeys(newPassword.incorrect)
await buttonYes.click()
const errors = await driver.findElements(screens.changePassword.error)
assert.equal(errors.length > 0, true, 'error isn\'t displayed')
assert.equal(await errors[0].getText(), screens.changePassword.errorText.dontMatch, 'Error\'s text incorrect')
})
it('error if new password match old password', async () => {
await clearField(fieldNewPassword)
await clearField(fieldConfirmNewPassword)
await fieldNewPassword.sendKeys(password)
await fieldConfirmNewPassword.sendKeys(password)
await buttonYes.click()
const errors = await driver.findElements(screens.changePassword.error)
assert.equal(errors.length > 0, true, 'error isn\'t displayed')
assert.equal(await errors[0].getText(), screens.changePassword.errorText.differ, 'Error\'s text incorrect')
})
it('error if old password incorrect, https://github.com/poanetwork/metamask-extension/issues/86 ', async () => {
await clearField(fieldOldPassword)
await fieldOldPassword.sendKeys(newPassword.incorrect)
await buttonYes.click()
const errors = await driver.findElements(screens.changePassword.error)
assert.equal(errors.length > 0, true, 'error isn\'t displayed')
assert.equal(await errors[0].getText(), screens.changePassword.errorText.incorrectPassword, 'Error\'s text incorrect')
})
it('no errors if old, new, confirm new passwords are correct; user can change password', async () => {
await clearField(fieldNewPassword)
await clearField(fieldOldPassword)
await clearField(fieldConfirmNewPassword)
await fieldOldPassword.sendKeys(password)
await fieldNewPassword.sendKeys(newPassword.correct)
await fieldConfirmNewPassword.sendKeys(newPassword.correct)
await buttonYes.click()
await driver.wait(until.elementLocated(screens.settings.buttons.changePassword))
const buttons = await driver.findElements(screens.settings.buttons.changePassword)
assert.equal(buttons.length, 1, 'Button "Change password" is not present')
assert.equal(await buttons[0].isEnabled(), true, 'Button "Change password" is disabled')
})
})
describe('Check if new password is accepted', async () => {
it('user can log out', async () => {
await driver.findElement(menus.sandwich.menu).click()
it('imports account', async function () {
const privateKeyBox = await driver.findElement(By.css(screens.importAccounts.fieldPrivateKey))
const importButton = await driver.findElement(By.css(screens.importAccounts.buttonImport))
await privateKeyBox.sendKeys('c6b81c1252415d1acfda94474ab8f662a44c045f96749c805ff12a6074081586')// demo private key
importButton.click()
await delay(500)
await driver.wait(until.elementLocated(menus.sandwich.logOut))
const itemLogOut = await driver.findElement(menus.sandwich.logOut)
await driver.wait(until.elementIsVisible(itemLogOut))
itemLogOut.click()
await driver.wait(until.elementLocated(screens.lock.fieldPassword))
const fields = await driver.findElements(screens.lock.fieldPassword)
assert.equal(fields.length, 1, 'password box isn\'t present after logout')
// check, that account is added
await driver.findElement(By.css(menus.account.menu)).click()
await delay(500)
const importedLabel = await driver.findElement(By.css(menus.account.labelImported))
assert.equal(await importedLabel.getText(), 'IMPORTED')
})
it('can\'t login with old password', async () => {
const field = await driver.findElement(screens.lock.fieldPassword)
await field.sendKeys(password)
await driver.findElement(screens.lock.buttonLogin).click()
const errors = await driver.findElements(screens.lock.error)
assert.equal(errors.length, 1, 'error isn\'t displayed if password incorrect')
assert.equal(await errors[0].getText(), screens.lock.errorText, 'error\'s text incorrect')
})
it('accepts new password after lock', async () => {
const field = await driver.findElement(screens.lock.fieldPassword)
await clearField(field)
await field.sendKeys(newPassword.correct)
await driver.findElement(screens.lock.buttonLogin).click()
await driver.wait(until.elementLocated(screens.main.buttons.buy))
const buttons = await driver.findElements(screens.main.buttons.buy)
assert.equal(buttons.length, 1, 'main screen isn\'t displayed')
password = newPassword.correct
it('opens delete imported account screen', async function () {
await driver.findElement(By.css(menus.account.delete)).click()
await delay(200)
const deleteImportedAccountTitle = await driver.findElement(By.css(screens.deleteImportedAccount.title))
assert.equal(await deleteImportedAccountTitle.getText(), screens.deleteImportedAccount.titleText)
})
it('doesn\'t remove imported account with \'No\' button', async function () {
const NoButton = await driver.findElement(By.css(screens.deleteImportedAccount.buttons.no))
NoButton.click()
await delay(500)
const settingsTitle = await driver.findElement(By.css(screens.settings.title))
assert.equal(await settingsTitle.getText(), 'Settings')
// check, that imported account still exists
await driver.findElement(By.css(menus.account.menu)).click()
await delay(500)
const importedLabel = await driver.findElement(By.css(menus.account.labelImported))
assert.equal(await importedLabel.getText(), 'IMPORTED')
})
it('opens delete imported account screen again', async function () {
await driver.findElement(By.css(menus.account.delete)).click()
await delay(500)
})
it('removes imported account with \'Yes\' button', async function () {
const YesButton = await driver.findElement(By.css(screens.deleteImportedAccount.buttons.yes))
YesButton.click()
await delay(500)
const settingsTitle = await driver.findElement(By.css(screens.settings.title))
assert.equal(await settingsTitle.getText(), 'Settings')
// check, that imported account is removed
await driver.findElement(By.css(menus.account.menu)).click()
await delay(500)
const importedAccounts = await driver.findElements(By.css(menus.account.labelImported))
assert.ok(importedAccounts.length === 0)
await driver.findElement(By.css(menus.account.menu)).click()
await delay(500)
})
})
})
describe('Import Account', () => {
it('opens import account menu', async function () {
await driver.wait(until.elementLocated(menus.account.menu))
await driver.findElement(menus.account.menu).click()
await delay(500)
await driver.findElement(menus.account.import).click()
await delay(500)
const importAccountTitle = await driver.findElement(screens.importAccounts.title)
assert.equal(await importAccountTitle.getText(), screens.importAccounts.textTitle)
})
it('imports account', async function () {
const privateKeyBox = await driver.findElement(screens.importAccounts.fieldPrivateKey)
const importButton = await driver.findElement(screens.importAccounts.buttonImport)
privateKeyBox.sendKeys('c6b81c1252415d1acfda94474ab8f662a44c045f96749c805ff12a6074081586')// demo private key
importButton.click()
await delay(200)
// check, that account is added
await driver.findElement(menus.account.menu).click()
await delay(500)
const importedLabel = await driver.findElement(menus.account.labelImported)
assert.equal(await importedLabel.getText(), 'IMPORTED')
})
it('opens delete imported account screen', async function () {
await driver.findElement(menus.account.delete).click()
await delay(200)
const deleteImportedAccountTitle = await driver.findElement(screens.deleteImportedAccount.title)
assert.equal(await deleteImportedAccountTitle.getText(), screens.deleteImportedAccount.titleText)
})
it('doesn\'t remove imported account with \'No\' button', async function () {
const NoButton = await driver.findElement(screens.deleteImportedAccount.buttons.no)
NoButton.click()
await delay(500)
const settingsTitle = await driver.findElement(screens.settings.title)
assert.equal(await settingsTitle.getText(), 'Settings')
// check, that imported account still exists
await driver.findElement(menus.account.menu).click()
await delay(500)
const importedLabel = await driver.findElement(menus.account.labelImported)
assert.equal(await importedLabel.getText(), 'IMPORTED')
})
it('opens delete imported account screen again', async function () {
await driver.findElement(menus.account.delete).click()
await delay(500)
})
it('removes imported account with \'Yes\' button', async function () {
const YesButton = await driver.findElement(screens.deleteImportedAccount.buttons.yes)
YesButton.click()
await delay(500)
const settingsTitle = await driver.findElement(screens.settings.title)
assert.equal(await settingsTitle.getText(), 'Settings')
// check, that imported account is removed
await driver.findElement(menus.account.menu).click()
await delay(500)
const importedAccounts = await driver.findElements(menus.account.labelImported)
assert.ok(importedAccounts.length === 0)
await driver.findElement(menus.account.menu).click()
await delay(500)
})
})
}
describe('Import Ganache seed phrase', function () {

View File

@ -75,21 +75,6 @@ describe('config-manager', function () {
})
})
describe('rpc manipulations', function () {
it('changing rpc should return a different rpc', function () {
var firstRpc = 'first'
var secondRpc = 'second'
configManager.setRpcTarget(firstRpc)
var firstResult = configManager.getCurrentRpcAddress()
assert.equal(firstResult, firstRpc)
configManager.setRpcTarget(secondRpc)
var secondResult = configManager.getCurrentRpcAddress()
assert.equal(secondResult, secondRpc)
})
})
describe('transactions', function () {
beforeEach(function () {
configManager.setTxList([])

View File

@ -1,9 +1,9 @@
{
"name": "MetaMask",
"short_name": "Metamask",
"name": "Nifty Wallet",
"short_name": "Nifty Wallet",
"version": "4.1.3",
"manifest_version": 2,
"author": "https://metamask.io",
"author": "POA Network",
"description": "Ethereum Browser Extension",
"commands": {
"_execute_browser_action": {
@ -21,7 +21,7 @@
},
"applications": {
"gecko": {
"id": "webextension@metamask.io"
"id": "webextension@niftywallet.io"
}
},
"default_locale": "en",

View File

@ -349,6 +349,10 @@ function tryUnlockMetamask (password) {
dispatch(actions.unlockSucceeded())
return forceUpdateMetamaskState(dispatch)
})
.catch((err) => {
log.error(err)
return Promise.reject(err)
})
.then(() => {
return new Promise((resolve, reject) => {
background.verifySeedPhrase(err => {
@ -564,10 +568,9 @@ function changePassword (oldPassword, newPassword) {
background.changePassword(oldPassword, newPassword, (err, account) => {
dispatch(actions.hideLoadingIndication())
if (err) {
dispatch(actions.displayWarning(err.message))
log.error(err)
return reject(err)
}
log.info('Password is changed for ' + account)
dispatch(actions.showAccountsPage())
resolve(account)