1
0
Fork 0
mirror of https://github.com/nishiki/manage-password.git synced 2025-02-20 01:50:04 +00:00

add test cli for export and import

This commit is contained in:
Adrien Waksberg 2017-05-20 13:26:12 +02:00
parent 811c576aae
commit efff66b12e
2 changed files with 50 additions and 3 deletions

View file

@ -0,0 +1,19 @@
---
1:
host: fric.com
user: 230403
group: Bank
password: 5XdiTQOubRDw9B0aJoMlcEyL
protocol: https
port:
otp_key: 330223432
comment: I love my bank
2:
host: assurance.com
user: user_2132
group: Assurance
password: DMyK6B3v4bWO52VzU7aTHIem
protocol: https
port: 443
otp_key:
comment:

View file

@ -101,7 +101,35 @@ class TestConfig < Test::Unit::TestCase
assert_match(I18n.t('display.nothing'), output)
end
def test_05_setup_wallet
def test_05_import_export
file_import = './test/files/fixtures-import.yml'
file_export = '/tmp/test-mpw.yml'
output = %x(echo #{@password} | mpw import --file #{file_import})
assert_match(I18n.t('form.import.valid', file: file_import), output)
output = %x(echo #{@password} | mpw export --file #{file_export})
assert_match(I18n.t('form.export.valid', file: file_export), output)
assert(File.exist?(file_export))
assert_equal(YAML.load_file(file_export).length, 2)
YAML.load_file(file_import).each_value do |import|
error = true
YAML.load_file(file_export).each_value do |export|
next if import['host'] != export['host']
%w[user group password protocol port otp_key comment].each do |key|
assert_equal(import[key].to_s, export[key].to_s)
end
error = false
end
assert(!error)
end
end
def test_06_setup_wallet
path = '/tmp/'
gpg_key = 'test2@example.com'
@ -145,7 +173,7 @@ class TestConfig < Test::Unit::TestCase
assert_no_match(/path_wallet_default/, output)
end
def test_06_setup_config
def test_07_setup_config
gpg_key = 'user@example2.com'
gpg_exe = '/usr/bin/gpg2'
wallet_dir = '/tmp/mpw'
@ -198,7 +226,7 @@ class TestConfig < Test::Unit::TestCase
end
end
def test_07_generate_password
def test_08_generate_password
length = 24
output = %x(