Commit 82bf4022 authored by Aishwarya Subramanian's avatar Aishwarya Subramanian

Removed support for Revoke button check

Since revoke button is now available for
gma and admin credential dashboard, we do not
require the revoke_available? method anymore.
parent f716b308
...@@ -6,7 +6,7 @@ class Admin::CredentialsController < Admin::ApplicationController ...@@ -6,7 +6,7 @@ class Admin::CredentialsController < Admin::ApplicationController
include Analytics::UniqueVisitsHelper include Analytics::UniqueVisitsHelper
helper_method :credentials_inventory_path, :user_detail_path, :personal_access_token_revoke_path, helper_method :credentials_inventory_path, :user_detail_path, :personal_access_token_revoke_path,
:revoke_button_available?, :ssh_key_delete_path, :gpg_keys_available? :ssh_key_delete_path, :gpg_keys_available?
before_action :check_license_credentials_inventory_available!, only: [:index, :revoke, :destroy] before_action :check_license_credentials_inventory_available!, only: [:index, :revoke, :destroy]
before_action :check_gpg_keys_list_enabled!, only: [:index] before_action :check_gpg_keys_list_enabled!, only: [:index]
...@@ -50,11 +50,6 @@ class Admin::CredentialsController < Admin::ApplicationController ...@@ -50,11 +50,6 @@ class Admin::CredentialsController < Admin::ApplicationController
revoke_admin_credential_path(token) revoke_admin_credential_path(token)
end end
override :revoke_button_available?
def revoke_button_available?
true
end
override :gpg_keys_available? override :gpg_keys_available?
def gpg_keys_available? def gpg_keys_available?
Feature.enabled?(:credential_inventory_gpg_keys, default_enabled: :yaml) Feature.enabled?(:credential_inventory_gpg_keys, default_enabled: :yaml)
......
...@@ -8,7 +8,7 @@ class Groups::Security::CredentialsController < Groups::ApplicationController ...@@ -8,7 +8,7 @@ class Groups::Security::CredentialsController < Groups::ApplicationController
include Groups::SecurityFeaturesHelper include Groups::SecurityFeaturesHelper
helper_method :credentials_inventory_path, :user_detail_path, :personal_access_token_revoke_path, helper_method :credentials_inventory_path, :user_detail_path, :personal_access_token_revoke_path,
:revoke_button_available?, :ssh_key_delete_path :ssh_key_delete_path
before_action :validate_group_level_credentials_inventory_available!, only: [:index, :revoke, :destroy] before_action :validate_group_level_credentials_inventory_available!, only: [:index, :revoke, :destroy]
before_action :check_gpg_keys_list_enabled!, only: [:index] before_action :check_gpg_keys_list_enabled!, only: [:index]
...@@ -45,11 +45,6 @@ class Groups::Security::CredentialsController < Groups::ApplicationController ...@@ -45,11 +45,6 @@ class Groups::Security::CredentialsController < Groups::ApplicationController
revoke_group_security_credential_path(group, token) revoke_group_security_credential_path(group, token)
end end
override :revoke_button_available?
def revoke_button_available?
true
end
override :users override :users
def users def users
group.managed_users group.managed_users
......
...@@ -21,10 +21,6 @@ module CredentialsInventoryHelper ...@@ -21,10 +21,6 @@ module CredentialsInventoryHelper
License.feature_available?(:credentials_inventory) License.feature_available?(:credentials_inventory)
end end
def revoke_button_available?
false
end
def gpg_keys_available? def gpg_keys_available?
false false
end end
......
...@@ -27,5 +27,5 @@ ...@@ -27,5 +27,5 @@
- if personal_access_token.revoked? - if personal_access_token.revoked?
-# We're inferring the revoked date from the last updated_at, see https://gitlab.com/gitlab-org/gitlab/-/issues/218046#note_362875952 -# We're inferring the revoked date from the last updated_at, see https://gitlab.com/gitlab-org/gitlab/-/issues/218046#note_362875952
= personal_access_token.updated_at.to_date = personal_access_token.updated_at.to_date
- elsif revoke_button_available? && personal_access_token.active? - elsif personal_access_token.active?
= link_to _('Revoke'), personal_access_token_revoke_path(personal_access_token), method: :put, data: { confirm: _('Are you sure you want to revoke this personal access token? This action cannot be undone.') }, class: 'btn btn-danger btn-danger-secondary btn-md btn-secondary gl-button' = link_to _('Revoke'), personal_access_token_revoke_path(personal_access_token), method: :put, data: { confirm: _('Are you sure you want to revoke this personal access token? This action cannot be undone.') }, class: 'btn btn-danger btn-danger-secondary btn-md btn-secondary gl-button'
...@@ -12,7 +12,6 @@ RSpec.describe('shared/credentials_inventory/personal_access_tokens/_personal_ac ...@@ -12,7 +12,6 @@ RSpec.describe('shared/credentials_inventory/personal_access_tokens/_personal_ac
allow(view).to receive(:user_detail_path).and_return('abcd') allow(view).to receive(:user_detail_path).and_return('abcd')
allow(view).to receive(:personal_access_token_revoke_path).and_return('revoke') allow(view).to receive(:personal_access_token_revoke_path).and_return('revoke')
allow(view).to receive(:revoke_button_available?).and_return(false)
render 'shared/credentials_inventory/personal_access_tokens/personal_access_token', personal_access_token: personal_access_token render 'shared/credentials_inventory/personal_access_tokens/personal_access_token', personal_access_token: personal_access_token
end end
...@@ -36,61 +35,31 @@ RSpec.describe('shared/credentials_inventory/personal_access_tokens/_personal_ac ...@@ -36,61 +35,31 @@ RSpec.describe('shared/credentials_inventory/personal_access_tokens/_personal_ac
context 'revoked date' do context 'revoked date' do
let_it_be(:updated_at_date) { 10.days.ago } let_it_be(:updated_at_date) { 10.days.ago }
context 'without revoke button available' do before do
context 'when revoked is set' do render 'shared/credentials_inventory/personal_access_tokens/personal_access_token', personal_access_token: personal_access_token
let_it_be(:personal_access_token) { build_stubbed(:personal_access_token, user: user, updated_at: updated_at_date, revoked: true)} end
it 'shows the revoked on date' do context 'when revoked is set' do
expect(rendered).to have_text(updated_at_date.to_date.to_s) let_it_be(:personal_access_token) { build_stubbed(:personal_access_token, user: user, updated_at: updated_at_date, revoked: true)}
end
it 'does not show the revoke button' do it 'shows the revoked on date' do
expect(rendered).not_to have_css('a.btn', text: 'Revoke') expect(rendered).to have_text(updated_at_date.to_date.to_s)
end
end end
context 'when revoked is not set' do it 'does not show the revoke button' do
let_it_be(:personal_access_token) { build_stubbed(:personal_access_token, user: user, updated_at: updated_at_date)} expect(rendered).not_to have_css('a.btn', text: 'Revoke')
it 'does not show the revoked on date' do
expect(rendered).not_to have_text(updated_at_date.to_date.to_s)
end
it 'does not show the revoke button' do
expect(rendered).not_to have_css('a.btn', text: 'Revoke')
end
end end
end end
context 'with revoke button available' do context 'when revoked is not set' do
before do let_it_be(:personal_access_token) { build_stubbed(:personal_access_token, user: user, updated_at: updated_at_date)}
allow(view).to receive(:revoke_button_available?).and_return(true)
render 'shared/credentials_inventory/personal_access_tokens/personal_access_token', personal_access_token: personal_access_token it 'does not show the revoked on date' do
expect(rendered).not_to have_text(updated_at_date.to_date.to_s)
end end
context 'when revoked is set' do it 'shows the revoke button' do
let_it_be(:personal_access_token) { build_stubbed(:personal_access_token, user: user, updated_at: updated_at_date, revoked: true)} expect(rendered).to have_css('a.btn', text: 'Revoke')
it 'shows the revoked on date' do
expect(rendered).to have_text(updated_at_date.to_date.to_s)
end
it 'does not show the revoke button' do
expect(rendered).not_to have_css('a.btn', text: 'Revoke')
end
end
context 'when revoked is not set' do
let_it_be(:personal_access_token) { build_stubbed(:personal_access_token, user: user, updated_at: updated_at_date)}
it 'does not show the revoked on date' do
expect(rendered).not_to have_text(updated_at_date.to_date.to_s)
end
it 'shows the revoke button' do
expect(rendered).to have_css('a.btn', text: 'Revoke')
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