Module: SOF::MCM::TestHelper
- Defined in:
- lib/sof/mcm/test_helper.rb
Instance Method Summary collapse
- #stub_mcm_headers(uri:, auth: "Basic #{Base64.strict_encode64("mcmapp:mcmapp")}", headers: {}) ⇒ Object
- #stub_mcm_list_applications(uri:, results: [], auth: "Basic #{Base64.strict_encode64("mcmapp:mcmapp")}") ⇒ Object
- #stub_mcm_put(edipi, uri:, status: 200, action: "assign_user_to_application", comment: "Assigning user", authorization: "Basic #{Base64.strict_encode64("mcmapp:mcmapp")}", application_uid: "mcmapp", request_body: {}, request_headers: {}, response_body: {}, response_headers: {}) ⇒ Object
Instance Method Details
#stub_mcm_headers(uri:, auth: "Basic #{Base64.strict_encode64("mcmapp:mcmapp")}", headers: {}) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/sof/mcm/test_helper.rb', line 10 def stub_mcm_headers( uri:, auth: "Basic #{Base64.strict_encode64("mcmapp:mcmapp")}", headers: {} ) { "Accept" => "application/json", "Accept-Encoding" => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3", "Authorization" => auth, "Content-Type" => "application/json", "Host" => URI(uri).host, "User-Agent" => "Ruby" }.merge(headers) end |
#stub_mcm_list_applications(uri:, results: [], auth: "Basic #{Base64.strict_encode64("mcmapp:mcmapp")}") ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/sof/mcm/test_helper.rb', line 24 def stub_mcm_list_applications( uri:, results: [], auth: "Basic #{Base64.strict_encode64("mcmapp:mcmapp")}" ) stub_request(:get, "#{uri}/@list_applications") .with( headers: stub_mcm_headers(uri:, auth:) ) .to_return( status: 200, body: { "results" => results }.to_json, headers: {} ) end |
#stub_mcm_put(edipi, uri:, status: 200, action: "assign_user_to_application", comment: "Assigning user", authorization: "Basic #{Base64.strict_encode64("mcmapp:mcmapp")}", application_uid: "mcmapp", request_body: {}, request_headers: {}, response_body: {}, response_headers: {}) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/sof/mcm/test_helper.rb', line 42 def stub_mcm_put( edipi, uri:, status: 200, action: "assign_user_to_application", comment: "Assigning user", authorization: "Basic #{Base64.strict_encode64("mcmapp:mcmapp")}", application_uid: "mcmapp", request_body: {}, request_headers: {}, response_body: {}, response_headers: {} ) headers = stub_mcm_headers( auth: , uri:, headers: request_headers ) body = { user_id: edipi, application_uid:, comment:, role: "Pub Member" }.merge(request_body).to_json stub_request(:put, "#{uri}/@#{action}") .with( body:, headers: ) .to_return(status:, body: response_body.to_json, headers: response_headers) end |