Commit 2b507557 authored by Kamil Trzciński's avatar Kamil Trzciński

Support `/client/features` Unleash endpoint

parent 71f30969
---
title: Support `/client/features` Unleash endpoint
merge_request:
author:
type: fixed
...@@ -19,10 +19,16 @@ module API ...@@ -19,10 +19,16 @@ module API
status :ok status :ok
end end
desc 'Get a list of features (deprecated, v2 client support)'
get 'features' do get 'features' do
present project, with: ::EE::API::Entities::UnleashFeatures present project, with: ::EE::API::Entities::UnleashFeatures
end end
desc 'Get a list of features'
get 'client/features' do
present project, with: ::EE::API::Entities::UnleashFeatures
end
post 'client/register' do post 'client/register' do
# not supported yet # not supported yet
status :ok status :ok
......
...@@ -66,31 +66,35 @@ describe API::Unleash do ...@@ -66,31 +66,35 @@ describe API::Unleash do
end end
end end
describe 'GET /feature_flags/unleash/:project_id/features' do %w(/feature_flags/unleash/:project_id/features /feature_flags/unleash/:project_id/client/features).each do |features_endpoint|
subject { get api("/feature_flags/unleash/#{project_id}/features"), params, headers } describe "GET #{features_endpoint}" do
let(:features_url) { features_endpoint.sub(':project_id', project_id) }
it_behaves_like 'authenticated request' subject { get api("/feature_flags/unleash/#{project_id}/features"), params, headers }
context 'with a list of feature flag' do it_behaves_like 'authenticated request'
let(:client) { create(:operations_feature_flags_client, project: project) }
let(:headers) { { "UNLEASH-INSTANCEID" => client.token }}
let!(:enable_feature_flag) { create(:operations_feature_flag, project: project, name: 'feature1', active: true) }
let!(:disabled_feature_flag) { create(:operations_feature_flag, project: project, name: 'feature2', active: false) }
it 'responds with a list' do context 'with a list of feature flag' do
subject let(:client) { create(:operations_feature_flags_client, project: project) }
let(:headers) { { "UNLEASH-INSTANCEID" => client.token }}
let!(:enable_feature_flag) { create(:operations_feature_flag, project: project, name: 'feature1', active: true) }
let!(:disabled_feature_flag) { create(:operations_feature_flag, project: project, name: 'feature2', active: false) }
expect(response).to have_gitlab_http_status(200) it 'responds with a list' do
expect(json_response['version']).to eq(1) subject
expect(json_response['features']).not_to be_empty
expect(json_response['features'].first['name']).to eq('feature1')
end
it 'matches json schema' do expect(response).to have_gitlab_http_status(200)
subject expect(json_response['version']).to eq(1)
expect(json_response['features']).not_to be_empty
expect(json_response['features'].first['name']).to eq('feature1')
end
expect(response).to have_gitlab_http_status(:ok) it 'matches json schema' do
expect(response).to match_response_schema('unleash/unleash', dir: 'ee') subject
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('unleash/unleash', dir: 'ee')
end
end end
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