Commit b2078b70 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'rc/customers_dot_proxy' into 'master'

Add basic proxy for customers dot

See merge request gitlab-org/gitlab!56577
parents 763f5bf2 520bafe0
# frozen_string_literal: true
module CustomersDot
class ProxyController < ApplicationController
skip_before_action :authenticate_user!
skip_before_action :verify_authenticity_token
feature_category :purchase
BASE_URL = Gitlab::SubscriptionPortal::SUBSCRIPTIONS_URL
def graphql
response = Gitlab::HTTP.post("#{BASE_URL}/graphql",
body: request.raw_post,
headers: { 'Content-Type' => 'application/json' }
)
render json: response.body, status: response.code
end
end
end
...@@ -284,6 +284,7 @@ Rails.application.routes.draw do ...@@ -284,6 +284,7 @@ Rails.application.routes.draw do
draw :git_http draw :git_http
draw :api draw :api
draw :customers_dot
draw :sidekiq draw :sidekiq
draw :help draw :help
draw :google_api draw :google_api
......
# frozen_string_literal: true
scope '-' do
namespace :customers_dot do
post 'proxy/graphql' => 'proxy#graphql'
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe CustomersDot::ProxyController, type: :request do
describe 'POST graphql' do
let_it_be(:customers_dot) { "#{Gitlab::SubscriptionPortal::SUBSCRIPTIONS_URL}/graphql" }
it 'forwards request body to customers dot' do
request_params = '{ "foo" => "bar" }'
stub_request(:post, customers_dot)
post customers_dot_proxy_graphql_path, params: request_params
expect(WebMock).to have_requested(:post, customers_dot).with(body: request_params)
end
it 'responds with customers dot status' do
stub_request(:post, customers_dot).to_return(status: 500)
post customers_dot_proxy_graphql_path
expect(response).to have_gitlab_http_status(:internal_server_error)
end
it 'responds with customers dot response body' do
customers_dot_response = 'foo'
stub_request(:post, customers_dot).to_return(body: customers_dot_response)
post customers_dot_proxy_graphql_path
expect(response.body).to eq(customers_dot_response)
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