Skip to content

Commit

Permalink
re-factor integration steps
Browse files Browse the repository at this point in the history
  • Loading branch information
vlewin committed Jun 10, 2015
1 parent 6d41596 commit 8fcddc3
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions features/step_definition/integration_steps.rb
Expand Up @@ -3,6 +3,10 @@
@url = ENV['URL'] || SUSE::Connect::Config::DEFAULT_URL
end

Then(/^Prepare SUSEConnect client with a valid regcode/) do
step 'Set regcode and url options'
@client = SUSE::Connect::Client.new(SUSE::Connect::Config.new.merge!(url: @url, regcode: @regcode))
end
### SUSEConnect cmd steps
Then(/^I call SUSEConnect with '(.*)' arguments$/) do |args|
options = Hash[*args.gsub('--', '').split(' ')]
Expand Down Expand Up @@ -63,30 +67,24 @@

### SUSEConnect library steps
Then(/^SUSEConnect library should respect API headers$/) do
step 'Set regcode and url options'
step 'Prepare SUSEConnect client with a valid regcode'

client = SUSE::Connect::Client.new(SUSE::Connect::Config.new.merge!(url: @url, regcode: @regcode))
response = SUSE::Connect::Api.new(client).announce_system("Token token=#{@regcode}")

expect(response.headers['scc-api-version'].first).to eq(SUSE::Connect::Api::VERSION)
end

Then(/^I cleanly deregister the system removing local credentials$/) do
step 'Set regcode and url options'

client = SUSE::Connect::Client.new(SUSE::Connect::Config.new.merge!(url: @url, regcode: @regcode))
step 'Prepare SUSEConnect client with a valid regcode'
client.deregister!
end

Then(/^I deregister the system only$/) do
step 'Set regcode and url options'
client = SUSE::Connect::Client.new(SUSE::Connect::Config.new.merge!(url: @url, regcode: @regcode))
step 'Prepare SUSEConnect client with a valid regcode'
client.instance_eval { @api.deregister(system_auth) }
end

Then(/^I remove local credentials$/) do
step 'Set regcode and url options'
client = SUSE::Connect::Client.new(SUSE::Connect::Config.new.merge!(url: @url, regcode: @regcode))
step 'Prepare SUSEConnect client with a valid regcode'
client.instance_eval { SUSE::Connect::System.remove_credentials }
end

Expand All @@ -100,10 +98,9 @@
end

Then(/^SUSEConnect library should be able to retrieve the product information$/) do
step 'Set regcode and url options'
step 'Prepare SUSEConnect client with a valid regcode'

remote_product = SUSE::Connect::Remote::Product.new(identifier: 'SLES', version: '12', arch: 'x86_64')
client = SUSE::Connect::Client.new(SUSE::Connect::Config.new.merge!(url: @url, regcode: @regcode))
products = client.show_product(remote_product).extensions.map(&:friendly_name).sort

products.each {|product| puts "- #{product}" }
Expand Down

0 comments on commit 8fcddc3

Please sign in to comment.