Skip to content

Commit

Permalink
Refactor CREDENTIALS_FILE
Browse files Browse the repository at this point in the history
  • Loading branch information
kalabiyau committed Mar 14, 2014
1 parent a0349c6 commit c62a191
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ Gemfile.lock
.yardoc/
*.png
suse-connect-*.gem
.vagrant/
2 changes: 1 addition & 1 deletion lib/suse/connect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Connect
UUIDGEN_LOCATION = '/usr/bin/uuidgen'
ZYPPER_CREDENTIALS_DIR = '/etc/zypp/credentials.d'
CREDENTIALS_NAME = 'SCCcredentials'
NCC_CREDENTIALS_FILE = File.join(ZYPPER_CREDENTIALS_DIR, CREDENTIALS_NAME)
CREDENTIALS_FILE = File.join(ZYPPER_CREDENTIALS_DIR, CREDENTIALS_NAME)

require 'suse/connect/version'
require 'suse/connect/logger'
Expand Down
4 changes: 2 additions & 2 deletions lib/suse/connect/system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ def hwinfo
# tuple of username and password or nil for both values
#
def credentials
if File.exist?(NCC_CREDENTIALS_FILE)
if File.exist?(CREDENTIALS_FILE)

file = File.new(NCC_CREDENTIALS_FILE, 'r')
file = File.new(CREDENTIALS_FILE, 'r')

begin
lines = file.readlines.map(&:chomp)
Expand Down
2 changes: 1 addition & 1 deletion lib/suse/toolkit/system_calls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def call_with_output(command)
end

def write_credentials_file(login, password, filename)
credentials_dir = ZYPPER_CREDENTIALS_DIR
credentials_dir = SUSE::Connect::ZYPPER_CREDENTIALS_DIR
Dir.mkdir(credentials_dir) unless Dir.exists?(credentials_dir)
credentials_file = File.join(credentials_dir, filename)

Expand Down
6 changes: 3 additions & 3 deletions spec/connect/system_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@
end

before do
File.should_receive(:exist?).with(NCC_CREDENTIALS_FILE).and_return(true)
File.should_receive(:new).with(NCC_CREDENTIALS_FILE, 'r').and_return(stub_ncc_cred_file)
File.should_receive(:exist?).with(CREDENTIALS_FILE).and_return(true)
File.should_receive(:new).with(CREDENTIALS_FILE, 'r').and_return(stub_ncc_cred_file)
end

it 'should raise MalformedNccCredentialsFile if cannot parse lines' do
Expand All @@ -106,7 +106,7 @@
context :credentials_not_exist do

before(:each) do
File.should_receive(:exist?).with(NCC_CREDENTIALS_FILE).and_return(false)
File.should_receive(:exist?).with(CREDENTIALS_FILE).and_return(false)
end

it 'should produce log message' do
Expand Down

0 comments on commit c62a191

Please sign in to comment.