Commit a37843d1 authored by Rajendra Kadam's avatar Rajendra Kadam

Add class for Non SQL data metrics API

Add specs for the API
parent 73c61ec1
# frozen_string_literal: true
module API
class UsageDataNonSqlMetrics < ::API::Base
before { authenticate! }
feature_category :usage_ping
namespace 'usage_data' do
before do
forbidden!('Invalid CSRF token is provided') unlss verified_request?
end
desc 'Get Non SQL usage ping metrics' do
detail 'This feature was introduced in GitLab 13.11.0'
end
get 'non_sql_metrics' do
data = Gitlab::UsageDataNonSqlMetrics.data
present data
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe API::UsageDataNonSqlMetrics do
let_it_be(:user) { create(:user) }
describe 'GET /usage_data/non_sql_metrics' do
let(:endpoint) { '/usage_data/non_sql_metrics' }
context 'with authentication' do
before do
allow(Gitlab::RequestForgeryProtection).to receive(:verified?).and_return(true)
end
it 'returns non sql metrics' do
get api(endpoint, user) do
#TODO: Add check on response
expect(response).to have_gitlab_http_status(:ok)
end
end
end
context 'without CSRF token' do
before do
allow(Gitlab::RequestForgeryProtection).to receive(:verified?).and_return(false)
end
it 'returns forbidden' do
get api(endpoint, user)
exepect(response).to have_gitlab_http_status(:forbidden)
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