osp 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 46891f45eba94adf6d8a85f41ae72fad47af6238
4
- data.tar.gz: e46f551edf7948e3625cea51260a2103af8cd6ac
3
+ metadata.gz: 4654dbc7d8acad6ea9ec6a2c0f49111b379e38f1
4
+ data.tar.gz: 16a9675d9a2118b38ec2e28cf889031a4dfb7136
5
5
  SHA512:
6
- metadata.gz: 6b48c4218a002df463bae78e2986e5cfe9471ab96545534113f57f2acfb6fbe74b144e0dd632c436751bb902bf240fa381813cce02400df9126a49fa78070ef8
7
- data.tar.gz: 6471f2c637e7ecc0a161f61138c29d57ac3e4ce9edd15b78f23ebe114bcafa2c24ba92133ddf0e3cb5335fedf52c2168e63f37f73b839e7286b2ec269d908551
6
+ metadata.gz: 2e6b89878f707725f3c191a646f6f5d2446562150b0ee7d3dae77df950caa66397cc0fa476571c9912f0c577baa2fb4a26a9a3450d0c77626615597ef19f6874
7
+ data.tar.gz: 7d926eda3f8d98cae260b0589223c217ccaa225f10b99052f6d71916c7187a75250db0f49117cd29f99fb87aea5a808a28037004ad2a13349eefd53d42583c70
data/.editorconfig ADDED
@@ -0,0 +1,14 @@
1
+ # editorconfig.org
2
+
3
+ root = true
4
+
5
+ [*]
6
+ indent_style = tab
7
+ indent_size = 4
8
+ end_of_line = lf
9
+ charset = utf-8
10
+ trim_trailing_whitespace = false
11
+ insert_final_newline = true
12
+
13
+ [*.yml]
14
+ indent_style = space
data/.gitignore CHANGED
@@ -2,5 +2,8 @@
2
2
  .setup
3
3
  /bin/dev
4
4
  CHANGELOG-*.txt
5
+ /coverage/
5
6
  Gemfile.lock
6
- /releases/
7
+ /releases/
8
+ *.osp
9
+ *.osp~*
data/.gitlab-ci.yml ADDED
@@ -0,0 +1,47 @@
1
+ before_script:
2
+ - gem update --system
3
+ - gem install bundler -v '~>1.13'
4
+ - bundler --version
5
+ - make
6
+
7
+ stages:
8
+ - test
9
+ - release
10
+
11
+ test_21:
12
+ image: ruby:2.1
13
+ stage: test
14
+ environment: test
15
+ only:
16
+ - tags
17
+ script:
18
+ - make test
19
+
20
+ test_22:
21
+ image: ruby:2.2
22
+ stage: test
23
+ environment: test
24
+ only:
25
+ - tags
26
+ script:
27
+ - make test
28
+
29
+ test_23:
30
+ image: ruby:2.3
31
+ stage: test
32
+ environment: test
33
+ only:
34
+ - tags
35
+ script:
36
+ - make test
37
+
38
+ release_gem:
39
+ image: ruby:2.3
40
+ stage: release
41
+ environment: gem
42
+ only:
43
+ - tags
44
+ script:
45
+ - mkdir -p ~/.gem
46
+ - 'printf "%s\n:rubygems_api_key: %s" "---" "${RUBYGEMSORG_API_KEY}" > ~/.gem/credentials; chmod 0600 ~/.gem/credentials'
47
+ - make release
data/.travis.yml CHANGED
@@ -2,10 +2,13 @@ language: ruby
2
2
  rvm:
3
3
  - 2.1
4
4
  - 2.2
5
+ - 2.3
6
+ - 2.4.0
7
+ - ruby-head
5
8
  sudo: required
6
9
  before_install:
7
10
  - gem update --system
8
- - gem install bundler -v '~>1.11'
11
+ - gem install bundler -v '~>1.13'
9
12
  - bundler --version
10
13
  install:
11
14
  - make
@@ -16,4 +19,4 @@ script:
16
19
  - make test
17
20
  - cd
18
21
  - which -a osp
19
- - osp --version
22
+ - osp --version
data/Makefile CHANGED
@@ -6,8 +6,16 @@ include Makefile.common
6
6
  # Email: example@example.com
7
7
  # Password: password
8
8
  dev:
9
- RUBYOPT=-rbundler/setup ruby --debug ./bin/osp -d passwords.osp
9
+ RUBYOPT=--debug $(BUNDLER) exec ./bin/osp -d passwords.osp
10
10
 
11
11
  .PHONY: test
12
12
  test:
13
- RUBYOPT=-w $(BUNDLER) exec ./tests/ts_all.rb
13
+ RUBYOPT=-w $(BUNDLER) exec ./test/suite_all.rb
14
+
15
+ .PHONY: cov
16
+ cov:
17
+ RUBYOPT=-w COVERAGE=1 $(BUNDLER) exec ./test/suite_all.rb -v
18
+
19
+ .PHONY: cov_local
20
+ cov_local:
21
+ RUBYOPT=-w SIMPLECOV_PHPUNIT_LOAD_PATH=../simplecov-phpunit COVERAGE=1 $(BUNDLER) exec ./test/suite_all.rb -v
data/Makefile.common CHANGED
@@ -1,12 +1,11 @@
1
1
 
2
- # Ruby Common Big
3
- # 2016-04-09
2
+ # Ruby Common Big 2016-11-08
4
3
 
5
4
  MV = mv -nv
6
- RM = rm -rf
5
+ RM = rm -rfd
7
6
  MKDIR = mkdir -p
8
7
  CHMOD = chmod
9
- BUNDLER = bundle
8
+ BUNDLER = bundler
10
9
  BUNDLER_OPTIONS = --jobs=5 --retry=3
11
10
  GEMSPEC_FILE = $(GEM_NAME).gemspec
12
11
 
@@ -17,18 +16,21 @@ all: setup $(ALL_TARGETS_EXT)
17
16
  setup: .setup
18
17
 
19
18
  .setup:
19
+ which ruby &> /dev/null
20
+ which $(BUNDLER) &> /dev/null
21
+ ruby -v
20
22
  $(BUNDLER) install $(BUNDLER_OPTIONS)
21
23
  touch $@
22
24
 
23
25
  .PHONY: install
24
26
  install:
25
- gem_file=$$(gem build $(GEMSPEC_FILE) | grep 'File:' | tail -1 | awk '{ print $$2 }'); \
26
- sudo gem install $$gem_file; \
27
+ gem_file=$$(gem build $(GEMSPEC_FILE) 2> /dev/null | grep 'File:' | tail -1 | awk '{ print $$2 }'); \
28
+ gem install $$gem_file; \
27
29
  $(RM) $$gem_file
28
30
 
29
31
  .PHONY: uninstall
30
32
  uninstall:
31
- sudo gem uninstall $(GEM_NAME)
33
+ gem uninstall $(GEM_NAME)
32
34
 
33
35
  .PHONY: update
34
36
  update:
@@ -36,9 +38,7 @@ update:
36
38
 
37
39
  .PHONY: clean
38
40
  clean:
39
- $(RM) .bundle
40
- $(RM) .setup
41
- $(RM) Gemfile.lock
41
+ $(RM) .bundle .setup Gemfile.lock
42
42
 
43
43
  .PHONY: release
44
44
  release: | releases
data/README.md CHANGED
@@ -9,7 +9,7 @@ The preferred method of installation is via RubyGems.org:
9
9
 
10
10
  or via `Gemfile`:
11
11
 
12
- gem 'osp', '~>0.4'
12
+ gem 'osp', '~>0.5'
13
13
 
14
14
  ## Project Links
15
15
 
@@ -26,7 +26,8 @@ or via `Gemfile`:
26
26
  - [Ruby AES Encryption using OpenSSL](https://gist.github.com/byu/99651)
27
27
 
28
28
  ## License
29
- Copyright (C) 2015 Christian Mayer <http://fox21.at>
29
+
30
+ Copyright (C) 2015 Christian Mayer <https://fox21.at>
30
31
 
31
32
  This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
32
33
 
data/bin/osp CHANGED
@@ -2,23 +2,23 @@
2
2
  # coding: UTF-8
3
3
 
4
4
  require 'optparse'
5
- require 'fileutils'
5
+ require 'pathname'
6
6
  require 'highline'
7
7
  require 'msgpack'
8
8
  require 'osp'
9
9
 
10
10
 
11
11
  @options = {
12
- :database_path => "#{Dir.home}/.osp",
13
- :database_lock_path => "#{Dir.home}/.osp~lock",
12
+ :database_path => Pathname.new('.osp').expand_path(Dir.home),
13
+ :database_lock_path => Pathname.new('.osp~lock').expand_path(Dir.home),
14
14
  }
15
15
  opts = OptionParser.new do |o|
16
16
  o.banner = 'Usage: osp [options]'
17
17
  o.separator('')
18
18
 
19
19
  o.on('-d', '--database <path>', 'Path to the database file.') do |path|
20
- @options[:database_path] = path
21
- @options[:database_lock_path] = "#{path}~lock"
20
+ @options[:database_path] = Pathname.new(path).expand_path
21
+ @options[:database_lock_path] = Pathname.new("#{@options[:database_path]}~lock").expand_path
22
22
  end
23
23
 
24
24
  o.on_tail('-V', '--version', 'Show version.') do
@@ -33,7 +33,7 @@ opts = OptionParser.new do |o|
33
33
  exit 3
34
34
  end
35
35
  end
36
- args = opts.parse(ARGV)
36
+ opts.parse(ARGV)
37
37
 
38
38
 
39
39
  if !STDIN.tty?
@@ -42,11 +42,11 @@ end
42
42
 
43
43
  @cli = HighLine.new
44
44
 
45
- puts "OSP - OneShallPass #{TheFox::OSP::VERSION}"
45
+ puts "OSP - OneShallPass v#{TheFox::OSP::VERSION}"
46
46
  puts TheFox::OSP::HOMEPAGE
47
47
  puts
48
48
 
49
- if File.exist?(@options[:database_lock_path])
49
+ if @options[:database_lock_path].exist?
50
50
  puts "WARNING: lock file exist: '#{@options[:database_lock_path]}'"
51
51
  overwrite = @cli.ask('Overwrite? '){ |q| q.default = 'n' }.downcase
52
52
  if overwrite == 'n'
@@ -55,7 +55,7 @@ if File.exist?(@options[:database_lock_path])
55
55
  end
56
56
  end
57
57
  File.write(@options[:database_lock_path], 'tmp')
58
- File.chmod(0600, @options[:database_lock_path])
58
+ @options[:database_lock_path].chmod(0600)
59
59
  File.binwrite(@options[:database_lock_path], Process.pid)
60
60
 
61
61
  puts 'Master Login'
@@ -91,8 +91,8 @@ def database_write_step(step, msg)
91
91
  end
92
92
 
93
93
  def remove_lock
94
- if File.exist?(@options[:database_lock_path])
95
- FileUtils.rm(@options[:database_lock_path])
94
+ if @options[:database_lock_path].exist?
95
+ @options[:database_lock_path].unlink
96
96
  end
97
97
  end
98
98
 
@@ -136,7 +136,7 @@ def host_edit(host = nil)
136
136
  puts 'New Host'
137
137
  puts
138
138
 
139
- tmp = @cli.ask(' Hostname: ' + (!host.name.nil? ? "[#{host.name}]" : '') + ' ').strip.to_s
139
+ tmp = @cli.ask(' Hostname: ' + (host.name.nil? ? '[]' : "[#{host.name}]") + ' ').strip.to_s
140
140
  host.name = tmp if tmp != ''
141
141
  host.name = nil if host.name == ''
142
142
  if host.name.nil?
data/lib/osp/database.rb CHANGED
@@ -1,4 +1,6 @@
1
1
 
2
+ require 'pathname'
3
+
2
4
  module TheFox
3
5
  module OSP
4
6
 
@@ -19,7 +21,7 @@ module TheFox
19
21
  'created_at' => DateTime.now.to_s,
20
22
  'updated_at' => DateTime.now.to_s,
21
23
  },
22
- 'hosts' => {}
24
+ 'hosts' => Hash.new,
23
25
  }
24
26
  end
25
27
 
@@ -28,13 +30,15 @@ module TheFox
28
30
  end
29
31
 
30
32
  def load_callback(*o)
31
- @load_callback_method.call(*o) if !@load_callback_method.nil?
33
+ if !@load_callback_method.nil?
34
+ @load_callback_method.call(*o)
35
+ end
32
36
  end
33
37
 
34
38
  def load
35
39
  load_callback(1000, 'Check for existing database file.')
36
40
 
37
- if File.exist?(@file_path)
41
+ if @file_path.exist?
38
42
  load_callback(1050, "Use database file: #{@file_path}")
39
43
 
40
44
  load_callback(1100, "Read file '#{@file_path}'.")
@@ -87,14 +91,16 @@ module TheFox
87
91
  end
88
92
 
89
93
  def write_callback(*o)
90
- @write_callback_method.call(*o) if !@write_callback_method.nil?
94
+ unless @write_callback_method.nil?
95
+ @write_callback_method.call(*o)
96
+ end
91
97
  end
92
98
 
93
99
  def write
94
100
  write_callback(1000, 'Check database for changes.')
95
101
 
96
102
  if @has_changed
97
- tmp = "#{@file_path}~"
103
+ tmp = Pathname.new("#{@file_path}~").expand_path
98
104
 
99
105
  # http://stackoverflow.com/questions/9049789/aes-encryption-key-versus-iv
100
106
  # http://keepass.info/help/base/security.html
@@ -130,21 +136,21 @@ module TheFox
130
136
 
131
137
  write_callback(1300, "Write temp file to '#{tmp}'.")
132
138
  File.write(tmp, 'tmp')
133
- File.chmod(0600, tmp)
139
+ tmp.chmod(0600)
134
140
  File.binwrite(tmp, db_out)
135
141
 
136
142
  backup_dts = Time.now.strftime('%Y%m%d-%H%M%S')
137
- backup = "#{@file_path}~backup_#{backup_dts}_" + Digest::SHA256.file(tmp).hexdigest[0..7]
143
+ backup = Pathname.new("#{@file_path}~backup_#{backup_dts}_" << Digest::SHA256.file(tmp.to_s).hexdigest[0..7])
138
144
 
139
145
  write_callback(1350, "Backup temp file to '#{backup}'.")
140
146
  File.write(backup, 'tmp')
141
- File.chmod(0600, backup)
147
+ backup.chmod(0600)
142
148
  FileUtils.cp(tmp, backup)
143
149
 
144
150
  write_callback(1390, "Finally, move temp file to '#{@file_path}'.")
145
151
  File.write(@file_path, 'tmp')
146
- File.chmod(0600, @file_path)
147
- FileUtils.mv(tmp, @file_path)
152
+ @file_path.chmod(0600)
153
+ tmp.rename(@file_path)
148
154
 
149
155
  @has_changed = false
150
156
  else
data/lib/osp/host.rb CHANGED
@@ -8,6 +8,10 @@ module TheFox
8
8
 
9
9
  attr_accessor :created_at
10
10
  attr_accessor :updated_at
11
+ attr_reader :osp
12
+ attr_reader :name
13
+ attr_reader :hashes
14
+ attr_writer :password
11
15
 
12
16
  def initialize(osp = nil)
13
17
  @osp = osp
@@ -20,20 +24,18 @@ module TheFox
20
24
  @generation = 1
21
25
  @length = 16
22
26
  @symbols = 1
23
- @hashes = !@osp.nil? ? @osp.hashes : nil
27
+ @hashes = @osp.nil? ? nil : @osp.hashes
24
28
  @password = nil
25
29
  end
26
30
 
27
31
  def osp=(v)
28
- raise ArgumentError, 'Wrong type.' if !v.is_a?(TheFox::OSP::OSP)
32
+ if !v.is_a?(OSP)
33
+ raise ArgumentError, "Wrong type -- #{v.class}"
34
+ end
29
35
 
30
36
  @osp = v
31
37
  end
32
38
 
33
- def osp
34
- @osp
35
- end
36
-
37
39
  def version=(v)
38
40
  @version = v.to_i
39
41
  end
@@ -43,12 +45,7 @@ module TheFox
43
45
  end
44
46
 
45
47
  def name=(v)
46
- v = nil if v == ''
47
- @name = v
48
- end
49
-
50
- def name
51
- @name
48
+ @name = v == '' ? nil : v
52
49
  end
53
50
 
54
51
  def generation=(v)
@@ -79,10 +76,6 @@ module TheFox
79
76
  @hashes = v
80
77
  end
81
78
 
82
- def hashes
83
- @hashes
84
- end
85
-
86
79
  def generate_password(regenerate = false)
87
80
  if @password.nil? && !@osp.nil? || regenerate
88
81
  @password = @osp.password(@name, @length, @generation, @symbols)
@@ -126,4 +119,3 @@ module TheFox
126
119
  end
127
120
  end
128
121
  end
129
-
data/lib/osp/osp.rb CHANGED
@@ -4,7 +4,6 @@ require 'openssl'
4
4
  require 'msgpack'
5
5
  require 'thefox-ext'
6
6
 
7
-
8
7
  module TheFox
9
8
  module OSP
10
9
 
@@ -33,7 +32,9 @@ module TheFox
33
32
  end
34
33
 
35
34
  def password(host_name, length = 16, generation = 1, symbols = self.class::SYMBOLS)
36
- raise ArgumentError, "'host_name' can't be '' or nil" if host_name.nil? || host_name == '' || !host_name
35
+ if host_name.nil? || host_name == '' || !host_name
36
+ raise ArgumentError, "'host_name' can't be '' or nil"
37
+ end
37
38
 
38
39
  key_derivation if @dk.nil?
39
40
 
@@ -46,7 +47,9 @@ module TheFox
46
47
  hmac_b64 = Base64.strict_encode64(hmac_p)
47
48
  pw = hmac_b64 if is_ok_pw(hmac_b64)
48
49
 
49
- @password_callback_method.call(step, hmac_b64) if !@password_callback_method.nil?
50
+ unless @password_callback_method.nil?
51
+ @password_callback_method.call(step, hmac_b64)
52
+ end
50
53
  step += 1
51
54
  end
52
55
 
@@ -55,7 +58,7 @@ module TheFox
55
58
 
56
59
  _b64map = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
57
60
 
58
- indices = []
61
+ indices = Array.new
59
62
  (0..self.class::PASSWORD_MIN_SIZE).each do |n|
60
63
  c = pw[n]
61
64
  if c.method(sub_method).call
@@ -70,7 +73,7 @@ module TheFox
70
73
  _map_len = _map.length
71
74
 
72
75
  last = 0
73
- arr = []
76
+ arr = Array.new
74
77
  indices.each do |index|
75
78
  arr << pw[last...index]
76
79
  c = pw[index]
@@ -117,7 +120,7 @@ module TheFox
117
120
  end
118
121
 
119
122
  (self.class::PASSWORD_MIN_SIZE...self.class::PASSWORD_MAX_SIZE).each do |n|
120
- if !pw[n].is_valid?
123
+ unless pw[n].is_valid?
121
124
  return false
122
125
  end
123
126
  end
@@ -141,15 +144,13 @@ module TheFox
141
144
  end
142
145
  end
143
146
 
144
- rv = ''
145
147
  if lowers >= caps && lowers >= digits then
146
- rv = 'is_lower?'
148
+ 'is_lower?'
147
149
  elsif digits > lowers && digits >= caps
148
- rv = 'is_digit?'
150
+ 'is_digit?'
149
151
  else
150
- rv = 'is_upper?'
152
+ 'is_upper?'
151
153
  end
152
- rv
153
154
  end
154
155
 
155
156
  end
data/lib/osp/version.rb CHANGED
@@ -1,9 +1,8 @@
1
1
 
2
2
  module TheFox
3
3
  module OSP
4
- RELEASE_ID = 7
5
- VERSION = '0.5.0'
6
- DATE = '2016-05-21'
4
+ VERSION = '0.6.0'
5
+ DATE = '2017-01-01'
7
6
  HOMEPAGE = 'https://github.com/TheFox/osp'
8
7
  end
9
8
  end
data/osp.gemspec CHANGED
@@ -24,9 +24,11 @@ Gem::Specification.new do |spec|
24
24
  spec.required_ruby_version = '>=2.1.0'
25
25
 
26
26
  spec.add_development_dependency 'minitest', '~>5.8'
27
+ spec.add_development_dependency 'simplecov', '~>0.12'
28
+ spec.add_development_dependency 'simplecov-phpunit', '~>1.0'
27
29
 
28
- spec.add_dependency 'highline', '~>1.7'
29
- spec.add_dependency 'msgpack', '~>0.7'
30
+ spec.add_runtime_dependency 'highline', '~>1.7'
31
+ spec.add_runtime_dependency 'msgpack', '~>1.0'
30
32
 
31
- spec.add_dependency 'thefox-ext', '~>1.2'
33
+ spec.add_runtime_dependency 'thefox-ext', '~>1.2'
32
34
  end
data/osp.sublime-project CHANGED
@@ -3,8 +3,8 @@
3
3
  {
4
4
  "path": ".",
5
5
  "name": "OneShallPass",
6
- "folder_exclude_patterns": [ ],
6
+ "folder_exclude_patterns": [ "coverage" ],
7
7
  "file_exclude_patterns": [ ]
8
8
  }
9
9
  ]
10
- }
10
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: osp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Mayer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-21 00:00:00.000000000 Z
11
+ date: 2017-01-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -24,6 +24,34 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '5.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: simplecov
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.12'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.12'
41
+ - !ruby/object:Gem::Dependency
42
+ name: simplecov-phpunit
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.0'
27
55
  - !ruby/object:Gem::Dependency
28
56
  name: highline
29
57
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +72,14 @@ dependencies:
44
72
  requirements:
45
73
  - - "~>"
46
74
  - !ruby/object:Gem::Version
47
- version: '0.7'
75
+ version: '1.0'
48
76
  type: :runtime
49
77
  prerelease: false
50
78
  version_requirements: !ruby/object:Gem::Requirement
51
79
  requirements:
52
80
  - - "~>"
53
81
  - !ruby/object:Gem::Version
54
- version: '0.7'
82
+ version: '1.0'
55
83
  - !ruby/object:Gem::Dependency
56
84
  name: thefox-ext
57
85
  requirement: !ruby/object:Gem::Requirement
@@ -73,7 +101,9 @@ executables:
73
101
  extensions: []
74
102
  extra_rdoc_files: []
75
103
  files:
104
+ - ".editorconfig"
76
105
  - ".gitignore"
106
+ - ".gitlab-ci.yml"
77
107
  - ".travis.yml"
78
108
  - Gemfile
79
109
  - Makefile
@@ -90,9 +120,6 @@ files:
90
120
  - lib/osp/version.rb
91
121
  - osp.gemspec
92
122
  - osp.sublime-project
93
- - tests/tc_host.rb
94
- - tests/tc_osp.rb
95
- - tests/ts_all.rb
96
123
  homepage: https://github.com/TheFox/osp
97
124
  licenses:
98
125
  - GPL-3.0
@@ -113,9 +140,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
140
  version: '0'
114
141
  requirements: []
115
142
  rubyforge_project:
116
- rubygems_version: 2.4.7
143
+ rubygems_version: 2.6.8
117
144
  signing_key:
118
145
  specification_version: 4
119
146
  summary: One Shall Pass
120
147
  test_files: []
121
- has_rdoc:
data/tests/tc_host.rb DELETED
@@ -1,120 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'minitest/autorun'
4
- require 'osp'
5
-
6
-
7
- class TestHost < MiniTest::Test
8
- def test_base
9
- osp = TheFox::OSP::Host.new
10
-
11
- assert_equal('TheFox::OSP::Host', osp.class.to_s)
12
- end
13
-
14
- def test_initialize
15
- host = TheFox::OSP::Host.new
16
-
17
- assert_equal(nil, host.osp)
18
- assert_equal(1, host.version)
19
- # assert_equal(, host.created_at)
20
- # assert_equal(, host.updated_at)
21
- assert_equal(nil, host.name)
22
- assert_equal(1, host.generation)
23
- assert_equal(16, host.length)
24
- assert_equal(1, host.symbols)
25
- assert_equal(nil, host.hashes)
26
- assert_equal(nil, host.password)
27
- end
28
-
29
- def test_version
30
- host = TheFox::OSP::Host.new
31
-
32
- host.version = 2
33
- assert_equal(2, host.version)
34
-
35
- host.version = '3'
36
- assert_equal(3, host.version)
37
- end
38
-
39
- def test_created_at
40
- host = TheFox::OSP::Host.new
41
-
42
- now = DateTime.now
43
- host.created_at = now
44
- assert_equal(now, host.created_at)
45
- end
46
-
47
- def test_updated_at
48
- host = TheFox::OSP::Host.new
49
-
50
- now = DateTime.now
51
- host.updated_at = now
52
- assert_equal(now, host.updated_at)
53
- end
54
-
55
- def test_name
56
- host = TheFox::OSP::Host.new
57
-
58
- host.name = ''
59
- assert_equal(nil, host.name)
60
-
61
- host.name = 'host1'
62
- assert_equal('host1', host.name)
63
- end
64
-
65
- def test_generation
66
- host = TheFox::OSP::Host.new
67
-
68
- host.generation = 2
69
- assert_equal(2, host.generation)
70
-
71
- host.generation = '3'
72
- assert_equal(3, host.generation)
73
- end
74
-
75
- def test_length
76
- host = TheFox::OSP::Host.new
77
-
78
- host.length = 2
79
- assert_equal(2, host.length)
80
-
81
- host.length = '3'
82
- assert_equal(3, host.length)
83
- end
84
-
85
- def test_symbols
86
- host = TheFox::OSP::Host.new
87
-
88
- host.symbols = 2
89
- assert_equal(2, host.symbols)
90
-
91
- host.symbols = '3'
92
- assert_equal(3, host.symbols)
93
- end
94
-
95
- def test_hashes
96
- host = TheFox::OSP::Host.new
97
-
98
- host.hashes = nil
99
- assert_equal(nil, host.hashes)
100
-
101
- host.hashes = 2
102
- assert_equal(2, host.hashes)
103
-
104
- host.hashes = '3'
105
- assert_equal('3', host.hashes)
106
- end
107
-
108
- def test_password
109
- host = TheFox::OSP::Host.new
110
-
111
- host.password = nil
112
- assert_equal(nil, host.password)
113
-
114
- host.password = 2
115
- assert_equal(2, host.password)
116
-
117
- host.password = '3'
118
- assert_equal('3', host.password)
119
- end
120
- end
data/tests/tc_osp.rb DELETED
@@ -1,136 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'minitest/autorun'
4
- require 'osp'
5
-
6
-
7
- class TestOsp < MiniTest::Test
8
- def test_that_it_has_a_version_number
9
- refute_nil ::TheFox::OSP::VERSION
10
- end
11
-
12
- def test_base
13
- osp = TheFox::OSP::OSP.new('example@example.com', 'test1', 2 ** 10)
14
-
15
- assert_equal('TheFox::OSP::OSP', osp.class.to_s)
16
- end
17
-
18
- def test_hashes
19
- osp = TheFox::OSP::OSP.new('example@example.com', 'test1', 2 ** 10)
20
- assert_equal(2 ** 10, osp.hashes)
21
-
22
- osp = TheFox::OSP::OSP.new('example@example.com', 'test1', 2 ** 20)
23
- assert_equal(2 ** 20, osp.hashes)
24
- end
25
-
26
- def test_password1
27
- osp = TheFox::OSP::OSPDotCom.new('example@example.com', 'test1', 2 ** 10)
28
- osp.key_derivation
29
-
30
- assert_equal('TA24hNn0', osp.password('host1', 8, 1, 0))
31
- assert_equal('TA>4hNn0', osp.password('host1', 8, 1, 1))
32
- assert_equal('TA>?hNn0', osp.password('host1', 8, 1, 2))
33
- assert_equal('TA>?hNn,', osp.password('host1', 8, 1, 3))
34
-
35
- assert_equal('DHKzN7uY', osp.password('host2', 8, 1, 0))
36
- assert_equal('@HKzN7uY', osp.password('host2', 8, 1, 1))
37
- assert_equal('@^KzN7uY', osp.password('host2', 8, 1, 2))
38
- assert_equal('@^(zN7uY', osp.password('host2', 8, 1, 3))
39
-
40
- assert_equal('Qf4lvgE7', osp.password('host3', 8, 1, 0))
41
- assert_equal('Q!4lvgE7', osp.password('host3', 8, 1, 1))
42
- assert_equal('Q!4&vgE7', osp.password('host3', 8, 1, 2))
43
- assert_equal('Q!4&[gE7', osp.password('host3', 8, 1, 3))
44
-
45
- assert_equal('DHKzN7uYUBc3l0wi', osp.password('host2', 16, 1, 0))
46
- assert_equal('@HKzN7uYUBc3l0wi', osp.password('host2', 16, 1, 1))
47
- assert_equal('@^KzN7uYUBc3l0wi', osp.password('host2', 16, 1, 2))
48
- assert_equal('@^(zN7uYUBc3l0wi', osp.password('host2', 16, 1, 3))
49
-
50
- assert_equal('wU0t38KE4tDQb3c0', osp.password('host2', 16, 2, 0))
51
- assert_equal('wU,t38KE4tDQb3c0', osp.password('host2', 16, 2, 1))
52
- assert_equal('wU,t.8KE4tDQb3c0', osp.password('host2', 16, 2, 2))
53
- assert_equal('wU,t.!KE4tDQb3c0', osp.password('host2', 16, 2, 3))
54
-
55
- assert_equal('OezcZk881M3Jxw9Z', osp.password('host2', 16, 3, 0))
56
- assert_equal('O~zcZk881M3Jxw9Z', osp.password('host2', 16, 3, 1))
57
- assert_equal('O~:cZk881M3Jxw9Z', osp.password('host2', 16, 3, 2))
58
- assert_equal('O~:/Zk881M3Jxw9Z', osp.password('host2', 16, 3, 3))
59
- end
60
-
61
- # def test_password2
62
- # #PASSWORD_MIN_SIZE = 8
63
- # #PASSWORD_MAX_SIZE = 16
64
-
65
- # osp = TheFox::OSP::OSP.new('example@example.com', 'test1', 2 ** 10)
66
- # osp.key_derivation
67
-
68
- # assert_equal('cXyE2Dq1', osp.password('host1', 8, 1, 0))
69
- # assert_equal('/XyE2Dq1', osp.password('host1', 8, 1, 1))
70
- # assert_equal('/X;E2Dq1', osp.password('host1', 8, 1, 2))
71
- # assert_equal('/X;E2D_1', osp.password('host1', 8, 1, 3))
72
-
73
- # assert_equal('kT455AIH', osp.password('host2', 8, 1, 0))
74
- # assert_equal('k]455AIH', osp.password('host2', 8, 1, 1))
75
- # assert_equal('k]455`IH', osp.password('host2', 8, 1, 2))
76
- # assert_equal('k]455`&H', osp.password('host2', 8, 1, 3))
77
-
78
- # assert_equal('RN1vFCCx', osp.password('host3', 8, 1, 0))
79
- # assert_equal('}N1vFCCx', osp.password('host3', 8, 1, 1))
80
- # assert_equal('}_1vFCCx', osp.password('host3', 8, 1, 2))
81
- # assert_equal('}_1v$CCx', osp.password('host3', 8, 1, 3))
82
-
83
- # assert_equal('kT455AIHkWRmXRN9', osp.password('host2', 16, 1, 0))
84
- # assert_equal('k]455AIHkWRmXRN9', osp.password('host2', 16, 1, 1))
85
- # assert_equal('k]455`IHkWRmXRN9', osp.password('host2', 16, 1, 2))
86
- # assert_equal('k]455`&HkWRmXRN9', osp.password('host2', 16, 1, 3))
87
-
88
- # assert_equal('SDBNsS7tMF4HjpPz', osp.password('host2', 16, 2, 0))
89
- # assert_equal('[DBNsS7tMF4HjpPz', osp.password('host2', 16, 2, 1))
90
- # assert_equal('[@BNsS7tMF4HjpPz', osp.password('host2', 16, 2, 2))
91
- # assert_equal('[@~NsS7tMF4HjpPz', osp.password('host2', 16, 2, 3))
92
-
93
- # assert_equal('GZ8SAox0xBvFM9QL', osp.password('host2', 16, 3, 0))
94
- # assert_equal('%Z8SAox0xBvFM9QL', osp.password('host2', 16, 3, 1))
95
- # assert_equal('%>8SAox0xBvFM9QL', osp.password('host2', 16, 3, 2))
96
- # assert_equal('%>8[Aox0xBvFM9QL', osp.password('host2', 16, 3, 3))
97
- # end
98
-
99
- def test_password3
100
- #PASSWORD_MIN_SIZE = 8
101
- #PASSWORD_MAX_SIZE = 32
102
-
103
- osp = TheFox::OSP::OSP.new('example@example.com', 'test1', 2 ** 10)
104
- osp.key_derivation
105
-
106
- assert_equal('cXyE2Dq1', osp.password('host1', 8, 1, 0))
107
- assert_equal('/XyE2Dq1', osp.password('host1', 8, 1, 1))
108
- assert_equal('/X;E2Dq1', osp.password('host1', 8, 1, 2))
109
- assert_equal('/X;E2D_1', osp.password('host1', 8, 1, 3))
110
-
111
- assert_equal('ar7JQegF', osp.password('host2', 8, 1, 0))
112
- assert_equal('.r7JQegF', osp.password('host2', 8, 1, 1))
113
- assert_equal('.+7JQegF', osp.password('host2', 8, 1, 2))
114
- assert_equal('.+7JQ~gF', osp.password('host2', 8, 1, 3))
115
-
116
- assert_equal('RN1vFCCx', osp.password('host3', 8, 1, 0))
117
- assert_equal('}N1vFCCx', osp.password('host3', 8, 1, 1))
118
- assert_equal('}_1vFCCx', osp.password('host3', 8, 1, 2))
119
- assert_equal('}_1v$CCx', osp.password('host3', 8, 1, 3))
120
-
121
- assert_equal('ar7JQegFyBk737gQ', osp.password('host2', 16, 1, 0))
122
- assert_equal('.r7JQegFyBk737gQ', osp.password('host2', 16, 1, 1))
123
- assert_equal('.+7JQegFyBk737gQ', osp.password('host2', 16, 1, 2))
124
- assert_equal('.+7JQ~gFyBk737gQ', osp.password('host2', 16, 1, 3))
125
-
126
- assert_equal('E3uJvG0rGFKwgpHD', osp.password('host2', 16, 2, 0))
127
- assert_equal('E3}JvG0rGFKwgpHD', osp.password('host2', 16, 2, 1))
128
- assert_equal('E3}J[G0rGFKwgpHD', osp.password('host2', 16, 2, 2))
129
- assert_equal('E3}J[G0+GFKwgpHD', osp.password('host2', 16, 2, 3))
130
-
131
- assert_equal('7p51OI3QRAKGUcUc', osp.password('host2', 16, 3, 0))
132
- assert_equal('~p51OI3QRAKGUcUc', osp.password('host2', 16, 3, 1))
133
- assert_equal('~p/1OI3QRAKGUcUc', osp.password('host2', 16, 3, 2))
134
- assert_equal('~p/<OI3QRAKGUcUc', osp.password('host2', 16, 3, 3))
135
- end
136
- end
data/tests/ts_all.rb DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require_relative 'tc_osp'
4
- require_relative 'tc_host'