Project

General

Profile

Revision 400832c6

Added by Thomas McKay over 5 years ago

fixes #16493 - create manifest in portal

View differences:

test/resources/subscriptions_test.rb
2 2
require './lib/hammer_cli_csv'
3 3

  
4 4
module Resources
5
  class TestSubscriptionsUsage < MiniTest::Unit::TestCase
5
  class TestSubscriptions < MiniTest::Unit::TestCase
6 6
    def test_usage
7 7
      start_vcr
8 8
      set_user 'admin'
......
25 25
HELP
26 26
      stop_vcr
27 27
    end
28
  end
29 28

  
30
  class TestSubscriptionsImport < MiniTest::Unit::TestCase
31 29
    def test_manifest_does_not_exist
32 30
      start_vcr
33 31
      set_user 'admin'
......
37 35
      file.write <<-FILE
38 36
Name,Organization,Manifest File,Subscription Name,Quantity,Product SKU,Contract Number,Account Number
39 37
Manifest,Test Corporation,./test/data/doesnotexist.zip
40
# Manifest Name,Test Corporation,ExampleCorp
41
# Manifest URL,Test Corporation,https://access.stage.redhat.com/management/distributors/1234
38
Manifest Name,Test Corporation,TestCorp
39
Manifest URL,Test Corporation,https://access.stage.redhat.com/management/distributors/1234
42 40
FILE
43 41
      file.rewind
44 42

  
......
52 50
      file.unlink
53 51
      stop_vcr
54 52
    end
53

  
54
    def test_portal_incorrect_login
55
      start_vcr
56
      set_user 'admin'
57

  
58
      file = Tempfile.new('subscriptions_test')
59
      # rubocop:disable LineLength
60
      file.write <<-FILE
61
Name,Organization,Manifest File,Subscription Name,Quantity,Product SKU,Contract Number,Account Number
62
Manifest,Test Corporation,./test/data/doesnotexist.zip
63
Manifest Name,Test Corporation,TestCorp
64
Manifest URL,Test Corporation,https://access.stage.redhat.com/management/distributors/1234
65
FILE
66
      # rubocop:enable LineLength
67
      file.rewind
68

  
69
      stdout,stderr = capture {
70
        hammer.run(%W{--reload-cache csv subscriptions --verbose --file #{file.path}
71
                      --in-portal --portal-username username --portal-password password})
72
      }
73
      assert_equal "Checking manifest 'TestCorp'...", stdout
74
      lines = stderr.split("\n")
75
      assert_equal "Error: 401 Unauthorized", lines[0]
76
      file.unlink
77
      stop_vcr
78
    end
79

  
80
    def test_portal_existing_subscription
81
      start_vcr
82
      set_user 'admin'
83

  
84
      username = ENV['PORTALUSERNAME'] || 'username'
85
      password = ENV['PORTALPASSWORD'] || 'password'
86

  
87
      manifestfile = Tempfile.new('subscriptions_test')
88
      file = Tempfile.new('subscriptions_test')
89
      # rubocop:disable LineLength
90
      file.write <<-FILE
91
Name,Organization,Manifest File,Subscription Name,Quantity,Product SKU,Contract Number,Account Number
92
Manifest,Test Corporation,#{manifestfile.path}
93
Manifest Name,Test Corporation,TestCorp
94
Manifest URL,Test Corporation,https://access.stage.redhat.com/management/distributors/1234
95
Subscription,Test Corporation,,"Red Hat Enterprise Linux Server, Standard (Physical or Virtual Nodes)",200,RH00004,10999113,5700573,2016-06-20T04:00:00.000+0000,2017-06-20T03:59:59.000+0000
96
FILE
97
      # rubocop:enable LineLength
98
      file.rewind
99

  
100
      stdout,stderr = capture {
101
        hammer.run(%W{--reload-cache csv subscriptions --verbose --file #{file.path}
102
                      --in-portal --portal-username #{username} --portal-password #{password}
103
                      --portal https://subscription.rhn.stage.redhat.com:443})
104
      }
105
      assert_equal stderr, ''
106
      assert_equal stdout, <<-OUTPUT
107
Checking manifest 'TestCorp'...done
108
'Red Hat Enterprise Linux Server, Standard (Physical or Virtual Nodes)' of quantity 200 already attached
109
Downloading manifest for organization 'Test Corporation...writing to file '#{manifestfile.path}'...done
110
OUTPUT
111
      file.unlink
112
      manifestfile.unlink
113
      stop_vcr
114
    end
55 115
  end
56 116
end

Also available in: Unified diff