Commit 0efe495c authored by Jan Provaznik's avatar Jan Provaznik

Merge branch 'expose-is-auditor' into 'master'

Expose is_auditor user role via API [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!61058
parents 3036a86c 07a4a381
......@@ -190,7 +190,7 @@ GET /users
]
```
Users on GitLab [Premium or higher](https://about.gitlab.com/pricing/) also see the `shared_runners_minutes_limit`, `extra_shared_runners_minutes_limit`, and `using_license_seat` parameters.
Users on GitLab [Premium or higher](https://about.gitlab.com/pricing/) also see the `shared_runners_minutes_limit`, `extra_shared_runners_minutes_limit`, `is_auditor`, and `using_license_seat` parameters.
```json
[
......@@ -199,6 +199,7 @@ Users on GitLab [Premium or higher](https://about.gitlab.com/pricing/) also see
...
"shared_runners_minutes_limit": 133,
"extra_shared_runners_minutes_limit": 133,
"is_auditor": false,
"using_license_seat": true
...
}
......@@ -359,12 +360,13 @@ NOTE:
The `plan` and `trial` parameters are only available on GitLab Enterprise Edition.
Users on GitLab [Premium or higher](https://about.gitlab.com/pricing/) also see
the `shared_runners_minutes_limit`, and `extra_shared_runners_minutes_limit` parameters.
the `shared_runners_minutes_limit`, `is_auditor`, and `extra_shared_runners_minutes_limit` parameters.
```json
{
"id": 1,
"username": "john_smith",
"is_auditor": false,
"shared_runners_minutes_limit": 133,
"extra_shared_runners_minutes_limit": 133,
...
......@@ -628,6 +630,8 @@ GET /user
}
```
Users on GitLab [Premium or higher](https://about.gitlab.com/pricing/) also see the `shared_runners_minutes_limit`, `extra_shared_runners_minutes_limit`, `is_auditor`, and `using_license_seat` parameters.
## User status
Get the status of the currently signed in user.
......
---
title: Expose is_auditor user role via API
merge_request: 61058
author:
type: changed
......@@ -8,6 +8,7 @@ module EE
prepended do
expose :using_license_seat?, as: :using_license_seat
expose :auditor, as: :is_auditor, if: ->(_instance, _opts) { ::License.feature_available?(:auditor_user) }
end
end
end
......
......@@ -23,4 +23,30 @@ RSpec.describe ::EE::API::Entities::UserWithAdmin do
end
end
end
context 'is_auditor' do
context 'when auditor_user is available' do
it 'returns false when user is not an auditor' do
expect(subject[:is_auditor]).to be false
end
context 'when user is an auditor' do
let(:user) { create(:user, :auditor) }
it 'returns true' do
expect(subject[:is_auditor]).to be true
end
end
end
context 'when auditor_user is not available' do
before do
stub_licensed_features(auditor_user: false)
end
it 'does not have the is_auditor param' do
expect(subject[:is_auditor]).to be nil
end
end
end
end
......@@ -197,6 +197,12 @@ RSpec.describe API::Users do
expect(json_response).to include('plan' => 'ultimate', 'trial' => true)
end
end
it 'contains is_auditor parameter' do
get api("/users/#{user.id}", admin)
expect(json_response).to have_key('is_auditor')
end
end
context 'and user has no plan' do
......@@ -215,6 +221,12 @@ RSpec.describe API::Users do
expect(json_response).not_to have_key('plan')
expect(json_response).not_to have_key('trial')
end
it 'does not contain is_auditor parameter' do
get api("/users/#{user.id}", user)
expect(json_response).not_to have_key('is_auditor')
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