pws 0.9.2 → 1.0.0.pre.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,40 +1,44 @@
1
- pws ![Build status](http://travis-ci.org/janlelis/pws.png)
1
+ pws [![Build status](http://travis-ci.org/janlelis/pws.png)](http://travis-ci.org/janlelis/pws)
2
2
  ===
3
3
  pws is a command-line password safe/manager written in Ruby.
4
4
 
5
- ![Screenshot](http://rbjl.net/pws-example.png)
5
+ *ATTENTION* Refactoring in progress / The latest stable version is 0.9.2
6
+
7
+ Usage
8
+ ---
9
+ [![Screenshot](http://rbjl.net/pws-example.png)](http://rbjl.net/60-pws-the-ruby-powered-command-line-password-manager)
10
+
6
11
 
7
12
  Installation
8
13
  ---
9
14
  You can install pws with
10
15
  `$ gem install pws`
11
16
 
12
- Run `$ pws help` for usage information.
17
+ Run `$ pws --help` for usage information.
13
18
 
14
- Misc
19
+
20
+ 1.0 / Updating from 0.9
15
21
  ---
16
- Trust the code by reading the source!
22
+ You can try out the newest version with:
23
+ `$ gem install pws --pre`
17
24
 
18
- Originally based on [this tutorial](http://rbjl.net/41-tutorial-build-your-own-password-safe-with-ruby)
25
+ The 0.9 password files are not compatible with that version, however, you can convert your safe with:
26
+ `$ pws resave --in 0.9 --out 1.0`
19
27
 
20
- Cucumber specs loosely based on [the ones](https://github.com/thecatwasnot/passwordsafe/blob/master/features/) by thecatwasnot - thanks
21
28
 
22
- Features coming in 1.0
29
+ Reading the source
23
30
  ---
24
- Around March or April 2012
31
+ Trust the code by reading the source! It's originally based on [this tutorial](http://rbjl.net/41-tutorial-build-your-own-password-safe-with-ruby). You might want to start reading in the [0.9.2 tag](https://github.com/janlelis/pws/tree/0.9.2), because it's got less features and therefore is less code.
25
32
 
26
- * Significantly improved crypto methods
27
- * Tests for the crypto stuff
28
- * Different storage format, but will be backwards compatible
29
- * Little UI tweaks
30
33
 
31
34
  Contributions by
32
35
  ---
33
36
  * [brianewing](https://github.com/brianewing/)
34
37
  * [dquimper](https://github.com/dquimper/)
35
38
  * [grapz](https://github.com/grapz/)
39
+ * Cucumber specs loosely based on [the ones](https://github.com/thecatwasnot/passwordsafe/blob/master/features/) by [thecatwasnot](https://github.com/thecatwasnot/)
40
+
36
41
 
37
42
  Copyright
38
43
  ---
39
-
40
44
  © 2010-2012 Jan Lelis, MIT license
data/features/add.feature CHANGED
@@ -3,6 +3,7 @@ Feature: Add
3
3
  As a user
4
4
  I want to add new passwords to my password safe
5
5
 
6
+ @slow-hack
6
7
  Scenario: Add a new password for "github"
7
8
  Given A safe exists with master password "my_master_password"
8
9
  When I run `pws add github` interactively
@@ -12,6 +13,7 @@ Feature: Add
12
13
  And the output should contain "Please enter a password for github:"
13
14
  And the output should contain "The password for github has been added"
14
15
 
16
+ @slow-hack
15
17
  Scenario: Add a new password for "github", already passing it as command line paramenter (not recommended)
16
18
  Given A safe exists with master password "my_master_password"
17
19
  When I run `pws add github github_password` interactively
@@ -33,7 +35,7 @@ Feature: Add
33
35
  And I type ""
34
36
  Then the output should contain "Master password:"
35
37
  And the output should contain "Please enter a password for github:"
36
- And the output should contain "Cannot add an empty password!"
38
+ And the output should contain "Cannot set an empty password!"
37
39
 
38
40
  Scenario: Try to add a new password for "github" (but the master password is wrong)
39
41
  Given A safe exists with master password "my_master_password"
@@ -42,4 +44,14 @@ Feature: Add
42
44
  Then the output should contain "Master password:"
43
45
  And the output should contain "NO ACCESS"
44
46
 
45
-
47
+ @slow-hack
48
+ Scenario: Set a new password for "github", this also sets the timestamp
49
+ Given A safe exists with master password "my_master_password"
50
+ When I run `pws ls` interactively
51
+ And I type "my_master_password"
52
+ Then the output from "pws ls" should not contain the current date
53
+ When I run `pws add github github_password` interactively
54
+ And I type "my_master_password"
55
+ And I run `pws show` interactively
56
+ And I type "my_master_password"
57
+ Then the output from "pws show" should contain the current date
@@ -0,0 +1,23 @@
1
+ Feature: Create
2
+ In order to use the password safe
3
+ As a user
4
+ I want to create a new safe
5
+
6
+ Scenario: Trying to call a pws task (except help or version), but safe does not exist, yet
7
+ When I run `pws` interactively
8
+ And I type "some_new_master_password"
9
+ And I type "some_new_master_password"
10
+ Then the output should match /No password safe detected, creating one at.*pws.*/
11
+ And the output should contain "Please enter the new master password:"
12
+ And the output should contain "Please enter the new master password, again:"
13
+ And the output should contain "There aren't any passwords stored"
14
+
15
+ Scenario: Creating a new safe fails, if password confirmation is wrong
16
+ When I run `pws` interactively
17
+ And I type "some_new_master_password"
18
+ And I type "some_new_master_password_wrong"
19
+ Then the output should match /No password safe detected, creating one at.*pws.*/
20
+ And the output should contain "Please enter the new master password:"
21
+ And the output should contain "Please enter the new master password, again:"
22
+ And the output should contain "don't match"
23
+
@@ -0,0 +1,54 @@
1
+ Feature: --in and --out options
2
+ In order to use the newest pws version
3
+ As a user
4
+ I want to convert my password file into a different file format
5
+
6
+ Scenario: Cannot access a 0.9 safe with the current version without --in 0.9 option
7
+ Given A "0.9" safe exists with master password "password" and a key "github" with password "123456"
8
+ When I run `pws` interactively
9
+ And I type "password"
10
+ And the output should contain "NO ACCESS"
11
+ And the output should contain "you will need to convert"
12
+
13
+ Scenario: Can access a 0.9 safe, if --in 0.9 option is given
14
+ Given A "0.9" safe exists with master password "password" and a key "github" with password "123456"
15
+ When I run `pws --in 0.9` interactively
16
+ And I type "password"
17
+ Then the output should contain "Master password:"
18
+ Then the output should contain "Entries"
19
+ Then the output should contain "github"
20
+
21
+ Scenario: Using --in 0.5 option, but --in 0.5 is not supported
22
+ Given A safe exists with master password "password" and a key "github" with password "123456"
23
+ When I run `pws --in 0.5` interactively
24
+ And I type "password"
25
+ Then the output should contain "Master password:"
26
+ Then the output should contain "Input format <0.5> is not supported"
27
+
28
+ Scenario: Using --in 0.9 option, but safe is not in 0.9 format
29
+ Given A safe exists with master password "password" and a key "github" with password "123456"
30
+ When I run `pws --in 0.9` interactively
31
+ And I type "password"
32
+ Then the output should contain "Master password:"
33
+ Then the output should contain "NO ACCESS"
34
+
35
+ @slow-hack
36
+ Scenario: Succesfully converts from 0.9 to 1.0 with --in 0.9 and out --1.0 options
37
+ Given A "0.9" safe exists with master password "password" and a key "github" with password "123456"
38
+ When I run `pws resave --in 0.9 --out 1.0` interactively
39
+ And I type "password"
40
+ Then the output from "pws resave --in 0.9 --out 1.0" should contain "Master password:"
41
+ Then the output from "pws resave --in 0.9 --out 1.0" should contain "resaved"
42
+ When I run `pws` interactively
43
+ And I type "password"
44
+ Then the output from "pws" should contain "Master password:"
45
+ Then the output from "pws" should contain "Entries"
46
+ Then the output from "pws" should contain "github"
47
+
48
+ Scenario: Trying to convert to 0.9, but --out 0.9 is not supported
49
+ Given A "0.9" safe exists with master password "password" and a key "github" with password "123456"
50
+ When I run `pws resave --in 0.9 --out 0.9` interactively
51
+ And I type "password"
52
+ Then the output should contain "Master password:"
53
+ Then the output should contain "Output format <0.9> is not supported"
54
+
@@ -30,6 +30,7 @@ Feature: Master
30
30
  And the output should contain "again"
31
31
  And the output should contain "don't match"
32
32
 
33
+ @slow-hack
33
34
  Scenario: Change the master password, already passing it as command line parameter (not recommended)
34
35
  Given A safe exists with master password "my_master_password"
35
36
  When I run `pws master my_new_master_password` interactively
@@ -19,4 +19,18 @@ Feature: Misc
19
19
  And the output should contain "Unknown action"
20
20
  And the output should contain "blubb"
21
21
 
22
+ Scenario: I am asking for help
23
+ When I run `pws --help` interactively
24
+ And the output should contain "Usage"
25
+ And the output should contain "pws"
26
+ And the output should contain "action"
27
+ And the output should contain "help"
28
+ And the output should contain "namespace"
29
+ And the output should contain "master"
30
+
31
+ Scenario: I am asking for the version
32
+ When I run `pws --version` interactively
33
+ And the output should contain "pws"
34
+ And the output should contain "J-_-L"
35
+ And the output should contain "github"
22
36
 
@@ -1,14 +1,16 @@
1
- Feature: Namespaces
1
+ Feature: Namespaces and creating new safes
2
2
  In order to keep things separate
3
3
  As a user
4
4
  I want to use different safes
5
5
 
6
- Scenario: Use a pws namespace
7
- Given A safe exists with master password "my_master_password" and a key "github" with password "github_password"
6
+ @slow-hack
7
+ Scenario: Use a pws namespace, creating a new safe
8
8
  When I run `pws -work show` interactively
9
9
  And I type "some_new_master_password"
10
+ And I type "some_new_master_password"
10
11
  Then the output should match /No password safe detected, creating one at.*pws.*-work/
11
- And the output should contain "Please enter a new master password:"
12
+ And the output should contain "Please enter the new master password:"
13
+ And the output should contain "Please enter the new master password, again:"
12
14
  And the output should contain "There aren't any passwords stored"
13
15
 
14
16
  Scenario: Only passing "-" operates on usual main namespace
@@ -3,6 +3,7 @@ Feature: Remove
3
3
  As a user
4
4
  I want to remove passwords from my password safe
5
5
 
6
+ @slow-hack
6
7
  Scenario: Remove password entry "github"
7
8
  Given A safe exists with master password "my_master_password" and a key "github" with password "github_password"
8
9
  When I run `pws remove github` interactively
@@ -0,0 +1,37 @@
1
+ Feature: Resave
2
+ In order to do nothing, but apply options to the safe and always save it
3
+ As a user
4
+ I want resave the save
5
+
6
+ @slow-hack
7
+ Scenario: Usual resave
8
+ Given A safe exists with master password "my_master_password" and keys
9
+ | some | 123 |
10
+ | password | 345 |
11
+ | entries | 678 |
12
+ When I run `pws resave` interactively
13
+ And I type "my_master_password"
14
+ Then the output from "pws resave" should contain "resaved"
15
+ When I run `pws` interactively
16
+ And I type "my_master_password"
17
+ And the output from "pws" should contain "some"
18
+ And the output from "pws" should contain "password"
19
+ And the output from "pws" should contain "entries"
20
+
21
+ @slow-hack
22
+ Scenario: Useful for converting when used together with --in and --out options
23
+ Given A "0.9" safe exists with master password "password" and a key "github" with password "123456"
24
+ When I run `pws show` interactively
25
+ And I type "password"
26
+ Then the output from "pws show" should contain "Master password:"
27
+ Then the output from "pws show" should contain "NO ACCESS"
28
+ Then the output from "pws show" should contain "convert"
29
+ When I run `pws resave --in 0.9 --out 1.0` interactively
30
+ And I type "password"
31
+ Then the output from "pws resave --in 0.9 --out 1.0" should contain "Master password:"
32
+ Then the output from "pws resave --in 0.9 --out 1.0" should contain "resaved"
33
+ When I run `pws` interactively
34
+ And I type "password"
35
+ Then the output from "pws" should contain "Master password:"
36
+ Then the output from "pws" should contain "Entries"
37
+ Then the output from "pws" should contain "github"
@@ -2,7 +2,7 @@ Feature: Show
2
2
  In order to have an overview of my password safe
3
3
  As a user
4
4
  I want show a list of password entry keys
5
-
5
+
6
6
  Scenario: Show the list
7
7
  Given A safe exists with master password "my_master_password" and keys
8
8
  | some | 123 |
@@ -14,7 +14,7 @@ Feature: Show
14
14
  And the output should contain "some"
15
15
  And the output should contain "password"
16
16
  And the output should contain "entries"
17
-
17
+
18
18
  Scenario: Show the list and filter for regex
19
19
  Given A safe exists with master password "my_master_password" and keys
20
20
  | some-abc | 123 |
@@ -34,7 +34,40 @@ Feature: Show
34
34
  When I run `pws show "(("` interactively
35
35
  And I type "my_master_password"
36
36
  Then the output should contain "Invalid regex"
37
-
37
+
38
+ Scenario: Show the list and filter for regex, but no results
39
+ Given A safe exists with master password "my_master_password" and keys
40
+ | some-abc | 123 |
41
+ | password-aDc! | 345 |
42
+ | entries | 678 |
43
+ When I run `pws show unknown` interactively
44
+ And I type "my_master_password"
45
+ Then the output should contain "No passwords found"
46
+
47
+ Scenario: Also shows last change date for each entry
48
+ Given A safe exists with master password "my_master_password" and a key "github" with password "github_password" and timestamp "42424242"
49
+ When I run `pws show` interactively
50
+ And I type "my_master_password"
51
+ Then the output should contain "Entries"
52
+ And the output should contain "github"
53
+ And the output should contain "71-05-07"
54
+
55
+ Scenario: Don't show the last timestamp if it is 0
56
+ Given A safe exists with master password "my_master_password" and a key "github" with password "github_password" and timestamp "0"
57
+ When I run `pws show` interactively
58
+ And I type "my_master_password"
59
+ Then the output should contain "Entries"
60
+ And the output should contain "github"
61
+ And the output should not contain "70-01-01"
62
+
63
+ Scenario: Don't show the last timestamp if there is none
64
+ Given A safe exists with master password "my_master_password" and a key "github" with password "github_password"
65
+ When I run `pws show` interactively
66
+ And I type "my_master_password"
67
+ Then the output should contain "Entries"
68
+ And the output should contain "github"
69
+ And the output should not contain "70-01-01"
70
+
38
71
  Scenario: Show the list (but there is no entry yet)
39
72
  Given A safe exists with master password "my_master_password"
40
73
  When I run `pws show` interactively
@@ -1,13 +1,29 @@
1
- def create_safe(master, key_hash = {})
1
+ require 'fileutils'
2
+
3
+ def create_safe(master, key_hash = {}, timestamp = nil)
2
4
  ENV["PWS_CHARPOOL"] = ENV["PWS_LENGTH"] = ENV["PWS_SECONDS"] = nil
3
5
  restore, $stdout = $stdout, StringIO.new # tmp silence $stdout
4
- pws = PWS.new(password: master)
6
+ pws = PWS.new(password: master, iterations: 5)
5
7
  key_hash.each{ |key, password|
6
8
  pws.add key, password
7
9
  }
10
+
11
+ # only generating global timestamp for every entry
12
+ if timestamp
13
+ pws.instance_variable_get(:@data).each{ |_, entry|
14
+ entry[:timestamp] = timestamp
15
+ }
16
+ pws.resave
17
+ end
18
+
8
19
  $stdout = restore
9
20
  end
10
21
 
22
+ # faking legacy version safe using a fixture, maybe do it properly sometime
23
+ def create_09_safe
24
+ FileUtils.cp File.dirname(__FILE__) + '/../../spec/fixtures/0.9/correct', ENV['PWS']
25
+ end
26
+
11
27
  Given /^A safe exists with master password "([^"]*)"$/ do |master_password|
12
28
  create_safe(master_password)
13
29
  end
@@ -16,10 +32,18 @@ Given /^A safe exists with master password "([^"]*)" and a key "([^"]+)" with pa
16
32
  create_safe(master_password, key => password)
17
33
  end
18
34
 
35
+ Given /^A safe exists with master password "([^"]*)" and a key "([^"]+)" with password "([^"]+)" and timestamp "([^"]+)"$/ do |master_password, key, password, timestamp|
36
+ create_safe(master_password, { key => password }, timestamp)
37
+ end
38
+
19
39
  Given /^A safe exists with master password "([^"]*)" and keys$/ do |master_password, key_table|
20
40
  create_safe(master_password, key_table.rows_hash)
21
41
  end
22
42
 
43
+ Given /^A "0.9" safe exists with master password "password" and a key "github" with password "123456"$/ do
44
+ create_09_safe
45
+ end
46
+
23
47
  Given /^A clipboard content of "([^"]*)"$/ do |content|
24
48
  Clipboard.copy content
25
49
  end
@@ -36,6 +60,22 @@ Then /^the clipboard should match ([^\/].+)$/ do |expected|
36
60
  assert_matching_output(expected, Clipboard.paste)
37
61
  end
38
62
 
63
+ Then /^the output should contain the current date$/ do |cmd|
64
+ assert_partial_output(Time.now.strftime('%y-%m-%d'), all_output)
65
+ end
66
+
67
+ Then /^the output should not contain the current date$/ do |cmd|
68
+ assert_no_partial_output(Time.now.strftime('%y-%m-%d'), all_output)
69
+ end
70
+
71
+ Then /^the output from "([^"]*)" should contain the current date$/ do |cmd|
72
+ assert_partial_output(Time.now.strftime('%y-%m-%d'), output_from(cmd))
73
+ end
74
+
75
+ Then /^the output from "([^"]*)" should not contain the current date$/ do |cmd|
76
+ assert_no_partial_output(Time.now.strftime('%y-%m-%d'), output_from(cmd))
77
+ end
78
+
39
79
  When /^I set env variable "(\w+)" to "([^"]*)"$/ do |var, value|
40
80
  ENV[var] = value
41
81
  end
@@ -18,6 +18,7 @@ BEGIN{
18
18
  END{
19
19
  Clipboard.clear
20
20
  ENV["PWS"] = $original_pws_file
21
+ FileUtils.rm Dir['pws-test-*']
21
22
  }
22
23
 
23
24
  Around do |_, block|
@@ -33,9 +34,9 @@ end
33
34
  # Hacks
34
35
 
35
36
  Before('@slow-hack') do
36
- @aruba_io_wait_seconds = 0.5
37
+ @aruba_io_wait_seconds = 5 # 0.5 would be ok... except for "output from", travis even needs more
37
38
  end
38
39
 
39
40
  Before('@wait-11s') do
40
- @aruba_timeout_seconds = 11
41
+ @aruba_timeout_seconds = 12
41
42
  end
@@ -0,0 +1,60 @@
1
+ Feature: Update
2
+ In order to keep my privacy
3
+ As a user
4
+ I want to update a password entry
5
+
6
+ @slow-hack
7
+ Scenario: Set a new password for "github"
8
+ Given A safe exists with master password "my_master_password" and a key "github" with password "old_password"
9
+ When I run `pws update github` interactively
10
+ And I type "my_master_password"
11
+ And I type "new_password"
12
+ Then the output should contain "Master password:"
13
+ And the output should contain "Please enter a new password for github:"
14
+ And the output should contain "The password for github has been updated"
15
+
16
+ @slow-hack
17
+ Scenario: Set a new password for "github", already passing it as command line paramenter (not recommended)
18
+ Given A safe exists with master password "my_master_password" and a key "github" with password "old_password"
19
+ When I run `pws update github new_password` interactively
20
+ And I type "my_master_password"
21
+ Then the output should contain "Master password:"
22
+ And the output should contain "The password for github has been updated"
23
+
24
+ Scenario: Try to update the password for "github" (but it does not exist)
25
+ Given A safe exists with master password "my_master_password"
26
+ When I run `pws update github` interactively
27
+ And I type "my_master_password"
28
+ Then the output should contain "Master password:"
29
+ And the output should contain "There is no password stored for github, so you cannot update it!"
30
+
31
+ @slow-hack
32
+ Scenario: Try to update the password for "github" (but it's empty)
33
+ Given A safe exists with master password "my_master_password" and a key "github" with password "old_password"
34
+ When I run `pws update github` interactively
35
+ And I type "my_master_password"
36
+ And I type ""
37
+ Then the output should contain "Master password:"
38
+ And the output should contain "Please enter a new password for github:"
39
+ And the output should contain "Cannot set an empty password!"
40
+
41
+ Scenario: Try to update the password for "github" (but the master password is wrong)
42
+ Given A safe exists with master password "my_master_password"
43
+ When I run `pws update github` interactively
44
+ And I type "my_master_password_wrong"
45
+ Then the output should contain "Master password:"
46
+ And the output should contain "NO ACCESS"
47
+
48
+ @slow-hack
49
+ Scenario: Set a new password for "github", this also sets the timestamp
50
+ Given A safe exists with master password "my_master_password" and a key "github" with password "old_password" and timestamp "42424242"
51
+ When I run `pws ls` interactively
52
+ And I type "my_master_password"
53
+ Then the output from "pws ls" should not contain the current date
54
+ When I run `pws update github github_password` interactively
55
+ And I type "my_master_password"
56
+ And I run `pws show` interactively
57
+ And I type "my_master_password"
58
+ Then the output from "pws show" should contain the current date
59
+
60
+