nexus 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/lib/commands/abstract_command.rb +37 -28
- data/lib/nexus/config.rb +110 -0
- data/lib/nexus/version.rb +1 -1
- data/test/abstract_command_test.rb +67 -10
- data/test/config_test.rb +164 -0
- metadata +14 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9afe169e757af4c376e9127b7880a1b8e427ffc
|
4
|
+
data.tar.gz: ec412e696190f225462c3ab626cd9eaf53f23c8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5faef784a2e11d149e20f731fe6d6ae302ae13471957cb22a81b66b528683c567dc5ca4adad5dc59eb05eb1516429412ad7fb78e99b0c9d061f69ee1c98b8fee
|
7
|
+
data.tar.gz: 655818bb467f597bb8ea5665c023cfeb15c8196d44e05e30e196b7b3f3ccf78341e3a6020e20f1adce25639d4199153153060d76bba86a957b7e88484334c8ad
|
data/Rakefile
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'rubygems/local_remote_options'
|
2
2
|
require 'net/http'
|
3
3
|
require 'base64'
|
4
|
+
require 'nexus/config'
|
4
5
|
|
5
6
|
class Gem::AbstractCommand < Gem::Command
|
6
7
|
include Gem::LocalRemoteOptions
|
@@ -8,18 +9,29 @@ class Gem::AbstractCommand < Gem::Command
|
|
8
9
|
def initialize( name, summary )
|
9
10
|
super
|
10
11
|
|
11
|
-
add_option('-c', '--nexus-clear',
|
12
|
-
|
13
|
-
options[:nexus_clear] = value
|
12
|
+
add_option( '-c', '--nexus-clear',
|
13
|
+
'Clears the nexus config' ) do |value, options|
|
14
|
+
options[ :nexus_clear ] = value
|
14
15
|
end
|
15
|
-
|
16
|
-
|
17
|
-
|
16
|
+
|
17
|
+
add_option( '--nexus-config FILE',
|
18
|
+
'File location of nexus config' ) do |value, options|
|
19
|
+
options[ :nexus_config ] = File.expand_path( value )
|
20
|
+
end
|
21
|
+
|
22
|
+
add_option( '--repo KEY',
|
23
|
+
'pick the config under that key' ) do |value, options|
|
24
|
+
options[ :nexus_repo ] = value
|
25
|
+
end
|
26
|
+
|
27
|
+
add_option( '--secrets FILE',
|
28
|
+
'use and store secrets in the given instead of local config file. file location will be stored in the local config file.' ) do |value, options|
|
29
|
+
options[ :nexus_secrets ] = File.expand_path( value )
|
18
30
|
end
|
19
31
|
end
|
20
32
|
|
21
33
|
def url
|
22
|
-
url = config[:url]
|
34
|
+
url = config[ :url ]
|
23
35
|
# no leading slash
|
24
36
|
url.sub!(/\/$/,'') if url
|
25
37
|
url
|
@@ -30,9 +42,13 @@ class Gem::AbstractCommand < Gem::Command
|
|
30
42
|
|
31
43
|
url = ask("URL: ")
|
32
44
|
|
33
|
-
|
45
|
+
if URI.parse( "#{url}" ).host != nil
|
46
|
+
config[ :url ] = url
|
34
47
|
|
35
|
-
|
48
|
+
say 'The Nexus URL has been stored in ~/.gem/nexus'
|
49
|
+
else
|
50
|
+
raise 'no URL given'
|
51
|
+
end
|
36
52
|
end
|
37
53
|
|
38
54
|
def setup
|
@@ -49,35 +65,28 @@ class Gem::AbstractCommand < Gem::Command
|
|
49
65
|
# mimic strict_encode64 which is not there on ruby1.8
|
50
66
|
token = "#{username}:#{password}"
|
51
67
|
if token != ':'
|
52
|
-
|
53
|
-
|
68
|
+
config[ :authorization ] =
|
69
|
+
"Basic #{Base64.encode64(username + ':' + password).gsub(/\s+/, '')}"
|
54
70
|
else
|
55
|
-
|
71
|
+
config[ :authorization ] = nil
|
56
72
|
end
|
57
73
|
|
58
74
|
say "Your Nexus credentials has been stored in ~/.gem/nexus"
|
59
75
|
end
|
60
76
|
|
61
|
-
def
|
62
|
-
options[:
|
77
|
+
def this_config
|
78
|
+
Nexus::Config.new( options[ :nexus_repo ],
|
79
|
+
options[ :nexus_config ],
|
80
|
+
options[ :nexus_secrets ] )
|
63
81
|
end
|
64
|
-
|
82
|
+
private :this_config
|
83
|
+
|
65
84
|
def config
|
66
|
-
@config ||=
|
85
|
+
@config ||= this_config
|
67
86
|
end
|
68
87
|
|
69
88
|
def authorization
|
70
|
-
config[:authorization]
|
71
|
-
end
|
72
|
-
|
73
|
-
def store_config(key, value)
|
74
|
-
config.merge!(key => value)
|
75
|
-
dirname = File.dirname(config_path)
|
76
|
-
Dir.mkdir(dirname) unless File.exists?(dirname)
|
77
|
-
|
78
|
-
File.open(config_path, 'w') do |f|
|
79
|
-
f.write config.to_yaml
|
80
|
-
end
|
89
|
+
config[ :authorization ]
|
81
90
|
end
|
82
91
|
|
83
92
|
def make_request(method, path)
|
@@ -122,7 +131,7 @@ class Gem::AbstractCommand < Gem::Command
|
|
122
131
|
warn 'no authorization'
|
123
132
|
end
|
124
133
|
|
125
|
-
warn "use proxy at #{http.proxy_address}" if http.proxy_address
|
134
|
+
warn "use proxy at #{http.proxy_address}:#{http.proxy_port}" if http.proxy_address
|
126
135
|
end
|
127
136
|
|
128
137
|
http.request(request)
|
data/lib/nexus/config.rb
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
require 'rubygems/local_remote_options'
|
2
|
+
require 'net/http'
|
3
|
+
require 'base64'
|
4
|
+
|
5
|
+
module Nexus
|
6
|
+
class Config
|
7
|
+
|
8
|
+
class File
|
9
|
+
def initialize( file, repo )
|
10
|
+
if file.is_a?( String )
|
11
|
+
@file = file
|
12
|
+
|
13
|
+
if file && ::File.exists?( file )
|
14
|
+
@all = YAML.load( ::File.read( file ) )
|
15
|
+
end
|
16
|
+
elsif file
|
17
|
+
@file = file.instance_variable_get( '@file'.to_sym )
|
18
|
+
@all = file.instance_variable_get( '@all'.to_sym )
|
19
|
+
end
|
20
|
+
@all ||= {}
|
21
|
+
|
22
|
+
@data = ( @all[ repo ] ||= {} ) if repo
|
23
|
+
@data ||= @all
|
24
|
+
end
|
25
|
+
|
26
|
+
def key?( key )
|
27
|
+
@data.key? key
|
28
|
+
end
|
29
|
+
|
30
|
+
def []( key )
|
31
|
+
@data[ key ]
|
32
|
+
end
|
33
|
+
|
34
|
+
def []=( key, value )
|
35
|
+
if value
|
36
|
+
@data[ key ] = value
|
37
|
+
else
|
38
|
+
@data.delete( key )
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def store
|
43
|
+
if @file
|
44
|
+
dirname = ::File.dirname( @file )
|
45
|
+
Dir.mkdir( dirname ) unless ::File.exists?( dirname )
|
46
|
+
new = !::File.exists?( @file )
|
47
|
+
|
48
|
+
::File.open( @file, 'w') do |f|
|
49
|
+
f.write @all.to_yaml
|
50
|
+
end
|
51
|
+
if new
|
52
|
+
::File.chmod( 0100600, @file ) rescue nil
|
53
|
+
end
|
54
|
+
true
|
55
|
+
else
|
56
|
+
false
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.default_file
|
62
|
+
::File.join( Gem.user_home, '.gem', 'nexus' )
|
63
|
+
end
|
64
|
+
|
65
|
+
def initialize( repo = nil, config = nil, secrets = nil )
|
66
|
+
config ||= self.class.default_file
|
67
|
+
conf = File.new( config, nil )
|
68
|
+
if secrets
|
69
|
+
conf[ :secrets ] = secrets
|
70
|
+
conf.store
|
71
|
+
end
|
72
|
+
@conf = File.new( conf, repo )
|
73
|
+
@secr = File.new( secrets || conf[ :secrets ], repo )
|
74
|
+
end
|
75
|
+
|
76
|
+
def key?( key )
|
77
|
+
@conf.key?( key ) || @secr.key?( key )
|
78
|
+
end
|
79
|
+
|
80
|
+
def []( key )
|
81
|
+
if key == :authorization && @conf[ key ]
|
82
|
+
copy_authorization
|
83
|
+
end
|
84
|
+
@conf[ key ] || @secr[ key ]
|
85
|
+
end
|
86
|
+
|
87
|
+
def copy_authorization
|
88
|
+
@secr[ :authorization ] = @conf[ :authorization ]
|
89
|
+
if @secr.store
|
90
|
+
@conf[ :authorization ] = nil
|
91
|
+
@conf.store
|
92
|
+
end
|
93
|
+
end
|
94
|
+
private :copy_authorization
|
95
|
+
|
96
|
+
def []=( key, value )
|
97
|
+
stored = false
|
98
|
+
if key == :authorization
|
99
|
+
@secr[ key ] = value
|
100
|
+
stored = @secr.store
|
101
|
+
end
|
102
|
+
|
103
|
+
unless stored
|
104
|
+
@conf[ key ] = value
|
105
|
+
@conf.store
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
110
|
+
end
|
data/lib/nexus/version.rb
CHANGED
@@ -71,6 +71,9 @@ class AbstractCommandTest < CommandTest
|
|
71
71
|
end
|
72
72
|
|
73
73
|
should "always return stored authorization and url" do
|
74
|
+
config_path = File.join( 'pkg', 'configsomething')
|
75
|
+
FileUtils.rm_f( config_path )
|
76
|
+
@command.options[ :nexus_config ] = config_path
|
74
77
|
@command.config[ :url ] = 'something'
|
75
78
|
@command.config[ :authorization ] = 'something'
|
76
79
|
stub(@command).options { {:nexus_clear => true} }
|
@@ -100,7 +103,55 @@ class AbstractCommandTest < CommandTest
|
|
100
103
|
assert_equal @proxy_class, @command.proxy_class
|
101
104
|
end
|
102
105
|
end
|
103
|
-
|
106
|
+
|
107
|
+
context 'separeted config per repo key' do
|
108
|
+
should 'store the config on per key' do
|
109
|
+
config_path = File.join( 'pkg', 'configrepo')
|
110
|
+
FileUtils.rm_f( config_path )
|
111
|
+
@command.options[ :nexus_config ] = config_path
|
112
|
+
@command.options[ :nexus_repo ] = :first
|
113
|
+
@command.config[ :some ] = :thing
|
114
|
+
@command.options[ :nexus_repo ] = :second
|
115
|
+
@command.send :instance_variable_set, '@config'.to_sym, nil
|
116
|
+
@command.config[ :some ] = :otherthing
|
117
|
+
@command.options[ :nexus_repo ] = nil
|
118
|
+
@command.send :instance_variable_set, '@config'.to_sym, nil
|
119
|
+
@command.config[ :some ] = :nothing
|
120
|
+
|
121
|
+
assert_equal( Gem.configuration.load_file(config_path),
|
122
|
+
{ :first=>{:some=>:thing},
|
123
|
+
:second=>{:some=>:otherthing},
|
124
|
+
:some=>:nothing } )
|
125
|
+
end
|
126
|
+
|
127
|
+
should 'use only the config for the given key' do
|
128
|
+
config_path = File.join( 'pkg', 'configrepo')
|
129
|
+
FileUtils.rm_f( config_path )
|
130
|
+
@command.options[ :nexus_config ] = config_path
|
131
|
+
@command.options[ :nexus_repo ] = :first
|
132
|
+
@command.config[ :some ] = :thing
|
133
|
+
@command.options[ :nexus_repo ] = :second
|
134
|
+
@command.send :instance_variable_set, '@config'.to_sym, nil
|
135
|
+
assert_nil( @command.config[ :some ] )
|
136
|
+
@command.config[ :some ] = :otherthing
|
137
|
+
@command.options[ :nexus_repo ] = nil
|
138
|
+
@command.send :instance_variable_set, '@config'.to_sym, nil
|
139
|
+
assert_nil( @command.config[ :some ] )
|
140
|
+
@command.config[ :some ] = :nothing
|
141
|
+
|
142
|
+
@command.options[ :nexus_repo ] = :first
|
143
|
+
@command.send :instance_variable_set, '@config'.to_sym, nil
|
144
|
+
assert_equal( @command.config[ :some ], :thing )
|
145
|
+
@command.options[ :nexus_repo ] = :second
|
146
|
+
@command.send :instance_variable_set, '@config'.to_sym, nil
|
147
|
+
assert_equal( @command.config[ :some ], :otherthing )
|
148
|
+
@command.options[ :nexus_repo ] = nil
|
149
|
+
@command.send :instance_variable_set, '@config'.to_sym, nil
|
150
|
+
assert_equal( @command.config[ :some ], :nothing )
|
151
|
+
end
|
152
|
+
|
153
|
+
end
|
154
|
+
|
104
155
|
context "clear username + password" do
|
105
156
|
|
106
157
|
should "clear stored authorization" do
|
@@ -109,7 +160,7 @@ class AbstractCommandTest < CommandTest
|
|
109
160
|
stub(@command).say
|
110
161
|
stub(@command).ask { nil }
|
111
162
|
stub(@command).ask_for_password { nil }
|
112
|
-
@command.config[ :authorization ] = '
|
163
|
+
@command.config[ :authorization ] = 'some authentication'
|
113
164
|
|
114
165
|
@command.sign_in
|
115
166
|
assert_nil @command.authorization
|
@@ -125,44 +176,50 @@ class AbstractCommandTest < CommandTest
|
|
125
176
|
stub(@command).say
|
126
177
|
stub(@command).ask { @username }
|
127
178
|
stub(@command).ask_for_password { @password }
|
128
|
-
stub(@command).
|
179
|
+
stub(@command).options { {:nexus_config => File.join( 'pkg',
|
180
|
+
'configsign') } }
|
181
|
+
@command.config[ :authorization ] = @key
|
129
182
|
end
|
130
183
|
|
131
184
|
should "ask for username and password" do
|
132
185
|
@command.sign_in
|
133
186
|
assert_received(@command) { |command| command.ask("Username: ") }
|
134
187
|
assert_received(@command) { |command| command.ask_for_password("Password: ") }
|
135
|
-
|
188
|
+
assert_equal( @command.config[ :authorization ],
|
189
|
+
"Basic dXNlcm5hbWU6cGFzc3dvcmQgMDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODk=" )
|
136
190
|
end
|
137
191
|
|
138
192
|
should "say that we signed in" do
|
139
193
|
@command.sign_in
|
140
194
|
assert_received(@command) { |command| command.say("Enter your Nexus credentials") }
|
141
195
|
assert_received(@command) { |command| command.say("Your Nexus credentials has been stored in ~/.gem/nexus") }
|
142
|
-
|
196
|
+
assert_equal( @command.config[ :authorization ],
|
197
|
+
"Basic dXNlcm5hbWU6cGFzc3dvcmQgMDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODk=" )
|
143
198
|
end
|
144
199
|
end
|
145
200
|
|
146
201
|
context "configure nexus url" do
|
147
202
|
setup do
|
148
|
-
@url = "url"
|
149
|
-
|
203
|
+
@url = "http://url"
|
204
|
+
|
150
205
|
stub(@command).say
|
151
206
|
stub(@command).ask { @url }
|
152
|
-
stub(@command).
|
207
|
+
stub(@command).options { {:nexus_config => File.join( 'pkg',
|
208
|
+
'configurl') } }
|
209
|
+
@command.config[ :url ] = @url
|
153
210
|
end
|
154
211
|
|
155
212
|
should "ask for nexus url" do
|
156
213
|
@command.configure_url
|
157
214
|
assert_received(@command) { |command| command.ask("URL: ") }
|
158
|
-
|
215
|
+
assert_equal( @command.config[ :url ], "http://url" )
|
159
216
|
end
|
160
217
|
|
161
218
|
should "say that we configured the url" do
|
162
219
|
@command.configure_url
|
163
220
|
assert_received(@command) { |command| command.say("Enter the URL of the rubygems repository on a Nexus server") }
|
164
221
|
assert_received(@command) { |command| command.say("The Nexus URL has been stored in ~/.gem/nexus") }
|
165
|
-
|
222
|
+
assert_equal( @command.config[ :url ], "http://url" )
|
166
223
|
end
|
167
224
|
end
|
168
225
|
end
|
data/test/config_test.rb
ADDED
@@ -0,0 +1,164 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'shoulda'
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
class ConfigTest < ::MiniTest::Unit::TestCase
|
6
|
+
include ShouldaContextLoadable
|
7
|
+
|
8
|
+
context 'file' do
|
9
|
+
|
10
|
+
should 'store key/values with repo' do
|
11
|
+
file = File.join( 'pkg', 'cfg' )
|
12
|
+
FileUtils.rm_f file
|
13
|
+
f = Nexus::Config::File.new( file, 'first' )
|
14
|
+
f[ 'asd' ] = 'dsa'
|
15
|
+
assert_equal( f.store, true )
|
16
|
+
ff = Nexus::Config::File.new( file, 'first' )
|
17
|
+
assert_equal( ff[ 'asd' ], 'dsa' )
|
18
|
+
ff = Nexus::Config::File.new( file, nil )
|
19
|
+
assert_equal( ff[ 'asd' ], nil )
|
20
|
+
end
|
21
|
+
|
22
|
+
should 'store key/values without repo' do
|
23
|
+
file = File.join( 'pkg', 'cfg' )
|
24
|
+
FileUtils.rm_f file
|
25
|
+
f = Nexus::Config::File.new( file, nil )
|
26
|
+
f[ 'asd' ] = 'dsa'
|
27
|
+
assert_equal( f.store, true )
|
28
|
+
ff = Nexus::Config::File.new( file, nil )
|
29
|
+
assert_equal( ff[ 'asd' ], 'dsa' )
|
30
|
+
ff = Nexus::Config::File.new( file, 'first' )
|
31
|
+
assert_equal( ff[ 'asd' ], nil )
|
32
|
+
end
|
33
|
+
|
34
|
+
should 'not store anything' do
|
35
|
+
f = Nexus::Config::File.new( nil, nil )
|
36
|
+
f[ 'asd' ] = 'dsa'
|
37
|
+
assert_equal( f.store, false )
|
38
|
+
ff = Nexus::Config::File.new( nil, 'first' )
|
39
|
+
f[ 'asd' ] = 'dsa'
|
40
|
+
assert_equal( f.store, false )
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'config' do
|
45
|
+
|
46
|
+
should 'not use secrets file' do
|
47
|
+
file = File.join( 'pkg', 'cfg' )
|
48
|
+
FileUtils.rm_f file
|
49
|
+
c = Nexus::Config.new( :second, file, nil )
|
50
|
+
c[ 'asd' ] = 'dsa'
|
51
|
+
assert_equal c.key?( 'asd' ), true
|
52
|
+
|
53
|
+
cc = Nexus::Config::File.new( file, :second )
|
54
|
+
assert_equal cc.key?( 'asd' ), true
|
55
|
+
assert_equal cc[ 'asd' ], 'dsa'
|
56
|
+
|
57
|
+
cc = Nexus::Config::File.new( file, nil )
|
58
|
+
assert_equal cc.key?( 'asd' ), false
|
59
|
+
assert_equal cc[ 'asd' ], nil
|
60
|
+
|
61
|
+
cc = Nexus::Config::File.new( file, 'third' )
|
62
|
+
assert_equal cc.key?( 'asd' ), false
|
63
|
+
assert_equal cc[ 'asd' ], nil
|
64
|
+
|
65
|
+
cc = Nexus::Config.new( :second, file, nil )
|
66
|
+
assert_equal cc.key?( 'asd' ), true
|
67
|
+
assert_equal cc[ 'asd' ], 'dsa'
|
68
|
+
|
69
|
+
cc = Nexus::Config.new( nil, file, nil )
|
70
|
+
assert_equal cc.key?( 'asd' ), false
|
71
|
+
assert_equal cc[ 'asd' ], nil
|
72
|
+
|
73
|
+
cc = Nexus::Config.new( 'third', file, nil )
|
74
|
+
assert_equal cc.key?( 'asd' ), false
|
75
|
+
assert_equal cc[ 'asd' ], nil
|
76
|
+
end
|
77
|
+
|
78
|
+
should 'use secrets file' do
|
79
|
+
file = File.join( 'pkg', 'cfgstub' )
|
80
|
+
sfile = File.join( 'pkg', 'cfgsecrets' )
|
81
|
+
FileUtils.rm_f file
|
82
|
+
FileUtils.rm_f sfile
|
83
|
+
c = Nexus::Config.new( :second, file, sfile )
|
84
|
+
c[ 'asd' ] = 'dsa'
|
85
|
+
c[ :authorization ] = 'BASIC asddsa'
|
86
|
+
|
87
|
+
assert_equal c.key?( :secrets ), false
|
88
|
+
assert_equal c.key?( 'asd' ), true
|
89
|
+
assert_equal c.key?( :authorization ), true
|
90
|
+
|
91
|
+
cc = Nexus::Config::File.new( file, :second )
|
92
|
+
assert_equal cc.key?( :secrets ), false
|
93
|
+
assert_equal cc.key?( :authorization ), false
|
94
|
+
assert_equal cc.key?( 'asd' ), true
|
95
|
+
assert_equal cc[ 'asd' ], 'dsa'
|
96
|
+
|
97
|
+
cc = Nexus::Config::File.new( file, nil )
|
98
|
+
assert_equal cc.key?( :secrets ), true
|
99
|
+
assert_equal cc.key?( :authorization ), false
|
100
|
+
assert_equal cc.key?( 'asd' ), false
|
101
|
+
assert_equal cc[ :secrets ], sfile
|
102
|
+
|
103
|
+
cc = Nexus::Config::File.new( file, 'third' )
|
104
|
+
assert_equal cc.key?( :secrets ), false
|
105
|
+
assert_equal cc.key?( :authorization ), false
|
106
|
+
assert_equal cc.key?( 'asd' ), false
|
107
|
+
|
108
|
+
cc = Nexus::Config.new( :second, file, nil )
|
109
|
+
assert_equal cc.key?( :secrets ), false
|
110
|
+
assert_equal cc.key?( :authorization ), true
|
111
|
+
assert_equal cc.key?( 'asd' ), true
|
112
|
+
assert_equal cc[ 'asd' ], 'dsa'
|
113
|
+
assert_equal cc[ :authorization ], 'BASIC asddsa'
|
114
|
+
|
115
|
+
cc = Nexus::Config.new( nil, file, nil )
|
116
|
+
assert_equal cc.key?( :secrets ), true
|
117
|
+
assert_equal cc.key?( :authorization ), false
|
118
|
+
assert_equal cc.key?( 'asd' ), false
|
119
|
+
assert_equal cc[ :secrets ], sfile
|
120
|
+
|
121
|
+
cc = Nexus::Config.new( 'third', file, nil )
|
122
|
+
assert_equal cc.key?( :secrets ), false
|
123
|
+
assert_equal cc.key?( :authorization ), false
|
124
|
+
assert_equal cc.key?( 'asd' ), false
|
125
|
+
end
|
126
|
+
|
127
|
+
should 'copy authorization when starting to use secrets file' do
|
128
|
+
file = File.join( 'pkg', 'cfgstub' )
|
129
|
+
sfile = File.join( 'pkg', 'cfgsecrets' )
|
130
|
+
FileUtils.rm_f file
|
131
|
+
FileUtils.rm_f sfile
|
132
|
+
c = Nexus::Config.new( nil, file, nil )
|
133
|
+
c[ 'asd' ] = 'dsa'
|
134
|
+
c[ :authorization ] = 'BASIC asddsa'
|
135
|
+
|
136
|
+
assert_equal c.key?( 'asd' ), true
|
137
|
+
assert_equal c.key?( :authorization ), true
|
138
|
+
|
139
|
+
c = Nexus::Config.new( nil, file, sfile )
|
140
|
+
assert_equal c.key?( :secrets ), true
|
141
|
+
assert_equal c.key?( 'asd' ), true
|
142
|
+
assert_equal c.key?( :authorization ), true
|
143
|
+
assert_equal c[ :authorization ], 'BASIC asddsa'
|
144
|
+
assert_equal c[ :secrets ], sfile
|
145
|
+
|
146
|
+
cc = Nexus::Config::File.new( sfile, nil )
|
147
|
+
assert_equal cc.key?( :secrets ), false
|
148
|
+
assert_equal cc.key?( :authorization ), true
|
149
|
+
assert_equal cc.key?( 'asd' ), false
|
150
|
+
assert_equal cc[ :authorization ], 'BASIC asddsa'
|
151
|
+
|
152
|
+
cc = Nexus::Config::File.new( file, nil )
|
153
|
+
assert_equal cc.key?( :secrets ), true
|
154
|
+
assert_equal cc.key?( :authorization ), false
|
155
|
+
assert_equal cc.key?( 'asd' ), true
|
156
|
+
assert_equal cc[ :secrets ], sfile
|
157
|
+
|
158
|
+
cc = Nexus::Config::File.new( file, 'third' )
|
159
|
+
assert_equal cc.key?( :secrets ), false
|
160
|
+
assert_equal cc.key?( :authorization ), false
|
161
|
+
assert_equal cc.key?( 'asd' ), false
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nexus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Quaranto
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-11-
|
12
|
+
date: 2013-11-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -74,11 +74,17 @@ dependencies:
|
|
74
74
|
- - ~>
|
75
75
|
- !ruby/object:Gem::Version
|
76
76
|
version: '1.8'
|
77
|
+
- - <
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '1.16'
|
77
80
|
requirement: !ruby/object:Gem::Requirement
|
78
81
|
requirements:
|
79
82
|
- - ~>
|
80
83
|
- !ruby/object:Gem::Version
|
81
84
|
version: '1.8'
|
85
|
+
- - <
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '1.16'
|
82
88
|
prerelease: false
|
83
89
|
type: :development
|
84
90
|
- !ruby/object:Gem::Dependency
|
@@ -111,11 +117,13 @@ files:
|
|
111
117
|
- lib/bundler/rubygems_mirror.rb
|
112
118
|
- lib/bundler/monkey_patch.rb
|
113
119
|
- lib/nexus/version.rb
|
120
|
+
- lib/nexus/config.rb
|
114
121
|
- lib/commands/abstract_command.rb
|
115
122
|
- lib/commands/nexus.rb
|
116
123
|
- test/command_helper.rb
|
117
124
|
- test/nexus_command_test.rb
|
118
125
|
- test/abstract_command_test.rb
|
126
|
+
- test/config_test.rb
|
119
127
|
homepage: https://github.com/sonatype/nexus-ruby-support/tree/master/nexus-gem
|
120
128
|
licenses:
|
121
129
|
- MIT-LICENSE
|
@@ -123,10 +131,10 @@ metadata: {}
|
|
123
131
|
post_install_message: "\n========================================================================\n\
|
124
132
|
\n Thanks for installing Nexus gem! You can now run:\n\n gem nexus\
|
125
133
|
\ publish your gems onto Nexus server\n\n nbundle a bundler\
|
126
|
-
\ fork with mirror support.
|
127
|
-
\ bundle config mirror.http://rubygems.org http://localhost:8081/nexus/content/repositories/rubygems.org\n\
|
128
|
-
\
|
129
|
-
\n"
|
134
|
+
\ fork with mirror support. for bundler before 1.5.0\n \n\
|
135
|
+
add a mirror with:\n\n bundle config mirror.http://rubygems.org http://localhost:8081/nexus/content/repositories/rubygems.org\n\
|
136
|
+
\nfor bundler before 1.5.0 use 'nbundle' instead of 'bundle' to use the mirror\n\
|
137
|
+
\n========================================================================\n\n"
|
130
138
|
rdoc_options: []
|
131
139
|
require_paths:
|
132
140
|
- lib
|