github-auth 0.1.1 → 0.2.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: 7923f1e812f33164bee01033c7e54e16358c0857
4
- data.tar.gz: 466758b305e513e1542116c15247acf2a4373ddb
3
+ metadata.gz: 925a47ece6e17d63b118306d952b7f05de6334dd
4
+ data.tar.gz: 8994acc3a3c067d7cf60524d2d8da9be40beb77c
5
5
  SHA512:
6
- metadata.gz: 75952cf2d96daf67cf1a296ca5e41ac88ec4009d50a158d8b24543b64aa81786788bdddf97ec57e1128474954788d2114b1045ac261a488b1d5bb3fdcf679148
7
- data.tar.gz: 34e3772b40d381d16159ef81b3d5cdf53e7f5d444a48d3e7dae2865b50bd52166b99484f59c8451e92881d8bb4baf9d8c38db2008ba33660246e765d4bf44514
6
+ metadata.gz: b4d5eeec641cb3da34d54b38735906030bcca3b9814b069455567045d1ccd07424865572447eb6a4c2538aa4e1dc2b53912d53202d52e7335b850bcf1d474e70
7
+ data.tar.gz: 291fb365b5d28120baee5ced839a191bf07efbeb263f674dff564732410f48859b84643101d164a0571cc72045eb37b8efdc4018ccb5913daded3098645ed480
@@ -49,7 +49,7 @@ module Github::Auth
49
49
 
50
50
  def keys_file_content_without(keys)
51
51
  keys_file_content.tap do |content|
52
- Array(keys).each { |key| content.gsub! key, '' }
52
+ Array(keys).each { |k| content.gsub! /#{Regexp.escape(k)}( .*)?/, '' }
53
53
  content.strip!
54
54
  end
55
55
  end
@@ -1,5 +1,5 @@
1
1
  module Github
2
2
  module Auth
3
- VERSION = "0.1.1"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -3,10 +3,10 @@ require 'support/mock_github_server'
3
3
  require 'github/auth'
4
4
 
5
5
  describe Github::Auth::CLI do
6
- with_mock_github_server do |mock_server_hostname|
6
+ with_mock_github_server do |mock_server_hostname, mock_keys|
7
7
  let(:hostname) { mock_server_hostname }
8
8
  let(:keys_file) { Tempfile.new 'authorized_keys' }
9
- let(:keys) { Github::Auth::MockGithubServer::KEYS }
9
+ let(:keys) { mock_keys }
10
10
 
11
11
  after { keys_file.unlink }
12
12
 
@@ -6,17 +6,22 @@ describe Github::Auth::KeysFile do
6
6
  it 'writes and deletes keys from the keys file' do
7
7
  tempfile = Tempfile.new 'authorized_keys'
8
8
  keys_file = described_class.new path: tempfile.path
9
- keys = %w(abc123 def456)
9
+ keys = %w(abc123 def456)
10
10
 
11
11
  keys_file.write! keys
12
12
  expect(tempfile.read).to include keys.join("\n")
13
13
 
14
+ tempfile.rewind
15
+
14
16
  keys_file.delete! keys.first
15
- expect(tempfile.read).to_not include keys.first
17
+ tempfile.read.tap do |tempfile_content|
18
+ expect(tempfile_content).to_not include keys.first
19
+ expect(tempfile_content).to include keys.last
20
+ end
16
21
 
17
- keys_file.delete! keys.last
18
- expect(tempfile.read).to_not include keys.last
22
+ tempfile.rewind
19
23
 
24
+ keys_file.delete! keys.last
20
25
  expect(tempfile.read).to be_empty
21
26
  end
22
27
  end
@@ -134,5 +134,27 @@ describe Github::Auth::KeysFile do
134
134
  expect(keys_file.read).to eq original_keys_file
135
135
  end
136
136
  end
137
+
138
+ context 'when the key has a comment' do
139
+ let(:key) { 'WW6dx9mW/paKl9pznYypl+X617WHP' }
140
+ let(:comment) { 'this is a comment' }
141
+ let(:keys) { ["#{key} #{comment}", 'def456'] }
142
+ let(:other_key) { keys[1] }
143
+
144
+ it 'removes the key from the keys file' do
145
+ subject.delete! key
146
+ expect(keys_file.read).to_not include key
147
+ end
148
+
149
+ it 'removes the comment from the keys file' do
150
+ subject.delete! key
151
+ expect(keys_file.read).to_not include comment
152
+ end
153
+
154
+ it 'does not remove the other key from the keys file' do
155
+ subject.delete! key
156
+ expect(keys_file.read).to include other_key
157
+ end
158
+ end
137
159
  end
138
160
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github-auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Hunt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-15 00:00:00.000000000 Z
11
+ date: 2013-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler