diff --git a/doc/api/admin/token.md b/doc/api/admin/token.md index cd10ef87d98c2edd95a6e1a1bfeb41a52e063d31..4ae6d1b36cbadd5c473ad948aae27cbd1a49ab5f 100644 --- a/doc/api/admin/token.md +++ b/doc/api/admin/token.md @@ -13,6 +13,7 @@ DETAILS: **Status:** Experiment > - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/165157) in GitLab 17.5 [with a flag](../../administration/feature_flags.md) named `admin_agnostic_token_finder`. Disabled by default. +> - [Feed tokens added](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/169821) in GitLab 17.6. FLAG: The availability of this feature is controlled by a feature flag. @@ -35,6 +36,7 @@ Supported tokens: - [Personal access tokens](../../user/profile/personal_access_tokens.md) - [Deploy tokens](../../user/project/deploy_tokens/index.md) +- [Feed tokens](../../security/tokens/index.md#feed-token) ```plaintext POST /api/v4/admin/token diff --git a/spec/requests/api/admin/token_spec.rb b/spec/requests/api/admin/token_spec.rb index 804384701a1c6247ace9a4d20475f3afde5c9c18..5cc09953497d7221fe1cea101026766796049375 100644 --- a/spec/requests/api/admin/token_spec.rb +++ b/spec/requests/api/admin/token_spec.rb @@ -10,43 +10,40 @@ let_it_be(:personal_access_token) { create(:personal_access_token, user: user) } let_it_be(:deploy_token) { create(:deploy_token) } - let(:token) { nil } - let(:params) { { token: token } } + let(:plaintext) { nil } + let(:params) { { token: plaintext } } subject(:post_token) { post(api(url, api_user, admin_mode: true), params: params) } describe 'POST /admin/token' do context 'when the user is an admin' do - context 'with personal access token' do - let(:token) { personal_access_token.token } - - it 'returns info about the token' do - post_token - - expect(response).to have_gitlab_http_status(:ok) - expect(json_response['id']).to eq(personal_access_token.id) + context 'with a valid token' do + where(:token, :plaintext) do + [ + [ref(:personal_access_token), lazy { personal_access_token.token }], + [ref(:deploy_token), lazy { deploy_token.token }], + [ref(:user), lazy { user.feed_token }] + ] end - end - - context 'with deploy token' do - let(:token) { deploy_token.token } - it 'returns info about the token' do - post_token + with_them do + it 'returns info about the token' do + post_token - expect(response).to have_gitlab_http_status(:ok) - expect(json_response['id']).to eq(deploy_token.id) + expect(response).to have_gitlab_http_status(:ok) + expect(json_response['id']).to eq(token.id) + end end end context 'with non-existing token' do - let(:token) { "#{personal_access_token.token}-non-existing" } + let(:plaintext) { "#{personal_access_token.token}-non-existing" } it_behaves_like 'returning response status', :not_found end context 'with unsupported token type' do - let(:token) { 'unsupported' } + let(:plaintext) { 'unsupported' } it_behaves_like 'returning response status', :unprocessable_entity end