Commit 6897f206 authored by Sanad Liaquat's avatar Sanad Liaquat

Use RestClient directly instead of airborne

parent f6e54708
......@@ -329,6 +329,7 @@ module QA
module Page
autoload :Logging, 'qa/support/page/logging'
end
autoload :Api, 'qa/support/api'
end
end
......
......@@ -40,7 +40,7 @@ module QA
end
private
include Support::Api
attr_writer :api_resource, :api_response
def resource_web_url(resource)
......@@ -82,10 +82,6 @@ module QA
end
end
def parse_body(response)
JSON.parse(response.body, symbolize_names: true)
end
def process_api_response(parsed_response)
self.api_response = parsed_response
self.api_resource = transform_api_resource(parsed_response.deep_dup)
......@@ -94,25 +90,6 @@ module QA
def transform_api_resource(api_resource)
api_resource
end
def post(url, payload)
RestClient::Request.execute(
method: :post,
url: url,
payload: payload,
verify_ssl: false)
rescue RestClient::ExceptionWithResponse => e
e.response
end
def get(url)
RestClient::Request.execute(
method: :get,
url: url,
verify_ssl: false)
rescue RestClient::ExceptionWithResponse => e
e.response
end
end
end
end
......@@ -3,6 +3,8 @@
module QA
context 'Manage', :orchestrated, :ldap_tls, :ldap_no_tls do
describe 'LDAP Group sync' do
include Support::Api
before(:all) do
users = [
{
......@@ -52,7 +54,7 @@ module QA
EE::Page::Group::Menu.perform(&:go_to_members)
verify_users_synced(['ENG User 2', 'ENG User 3'])
verify_users_synced(['ENG User 2', 'ENG ser 3'])
end
it 'Has LDAP user synced using user filter method' do
......@@ -89,8 +91,9 @@ module QA
def add_user_to_sandbox_group_via_api(user)
sandbox_group_path = Resource::Sandbox.fabricate_via_api!.path
api_client = Runtime::API::Client.new(:gitlab, personal_access_token: Runtime::Env.personal_access_token)
get Runtime::API::Request.new(api_client, "/users?username=#{user}").url
post Runtime::API::Request.new(api_client, "/groups/#{sandbox_group_path}/members").url, user_id: json_body.first[:id], access_level: '50'
response = get Runtime::API::Request.new(api_client, "/users?username=#{user}").url
post Runtime::API::Request.new(api_client, "/groups/#{sandbox_group_path}/members").url, { user_id: parse_body(response).first[:id], access_level: '50' }
end
def create_admin_personal_access_token
......
module QA
module Support
module Api
def post(url, payload)
RestClient::Request.execute(
method: :post,
url: url,
payload: payload,
verify_ssl: false)
rescue RestClient::ExceptionWithResponse => e
e.response
end
def get(url)
RestClient::Request.execute(
method: :get,
url: url,
verify_ssl: false)
rescue RestClient::ExceptionWithResponse => e
e.response
end
def parse_body(response)
JSON.parse(response.body, symbolize_names: true)
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment