Gate remoteStorage by serviceEnabled instead of Flipper #251
No files matched your search
@@ -1,7 +1,7 @@
|
||||
class Services::RemotestorageController < Services::BaseController
|
||||
before_action :authenticate_user!
|
||||
before_action :require_service_available
|
||||
before_action :require_feature_enabled
|
||||
before_action :require_service_enabled
|
||||
|
||||
# Dashboard
|
||||
def show
|
||||
@@ -17,8 +17,8 @@ class Services::RemotestorageController < Services::BaseController
|
||||
http_status :not_found unless Setting.remotestorage_enabled?
|
||||
end
|
||||
|
||||
def require_feature_enabled
|
||||
unless Flipper.enabled?(:remotestorage, current_user)
|
||||
def require_service_enabled
|
||||
unless current_user.service_enabled?(:remotestorage)
|
||||
http_status :forbidden
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
class Services::RsAuthsController < Services::BaseController
|
||||
before_action :authenticate_user!
|
||||
before_action :require_feature_enabled
|
||||
before_action :require_service_enabled
|
||||
before_action :require_service_available
|
||||
# before_action :require_service_enabled
|
||||
before_action :find_rs_auth, only: [:destroy, :launch_app]
|
||||
|
||||
def index
|
||||
@@ -34,8 +33,8 @@ class Services::RsAuthsController < Services::BaseController
|
||||
|
||||
private
|
||||
|
||||
def require_feature_enabled
|
||||
unless Flipper.enabled?(:remotestorage, current_user)
|
||||
def require_service_enabled
|
||||
unless current_user.service_enabled?(:remotestorage)
|
||||
http_status :forbidden
|
||||
end
|
||||
end
|
||||
|
||||
@@ -305,7 +305,7 @@
|
||||
<td>remoteStorage</td>
|
||||
<td>
|
||||
<%= render FormElements::ToggleComponent.new(
|
||||
enabled: Flipper.enabled?(:remotestorage, current_user) && @services_enabled.include?("remotestorage"),
|
||||
enabled: @services_enabled.include?("remotestorage"),
|
||||
input_enabled: false
|
||||
) %>
|
||||
</td>
|
||||
|
||||
@@ -43,8 +43,7 @@
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if Setting.remotestorage_enabled? &&
|
||||
Flipper.enabled?(:remotestorage, current_user) %>
|
||||
<% if Setting.remotestorage_enabled? %>
|
||||
<div class="border border-gray-300 rounded-md hover:border-gray-400
|
||||
bg-[length:80%] bg-[center_top_-156px] bg-no-repeat
|
||||
bg-[url(/img/logos/icon_remotestorage.svg)]">
|
||||
|
||||
@@ -25,8 +25,7 @@
|
||||
active: @settings_section.to_s == "lightning"
|
||||
) %>
|
||||
<% end %>
|
||||
<% if Setting.remotestorage_enabled? &&
|
||||
Flipper.enabled?(:remotestorage, current_user) %>
|
||||
<% if Setting.remotestorage_enabled? %>
|
||||
<%= render SidenavLinkComponent.new(
|
||||
name: "Storage", path: setting_path(:remotestorage), icon: "remotestorage",
|
||||
active: @settings_section.to_s == "remotestorage"
|
||||
|
||||
@@ -6,7 +6,9 @@ RSpec.describe Services::RsAuthsController, type: :controller do
|
||||
before do
|
||||
allow_any_instance_of(AppCatalog::WebApp).to receive(:update_metadata).and_return(true)
|
||||
allow_any_instance_of(RemoteStorageAuthorization).to receive(:remove_token_expiry_job).and_return(nil)
|
||||
allow_any_instance_of(Flipper).to receive(:enabled?).and_return(true)
|
||||
allow_any_instance_of(LdapService).to receive(:fetch_users).and_return([
|
||||
{ services_enabled: ["remotestorage"] }
|
||||
])
|
||||
end
|
||||
|
||||
describe "GET /services/storage/rs_auths/:id/launch_app" do
|
||||
@@ -35,6 +37,20 @@ RSpec.describe Services::RsAuthsController, type: :controller do
|
||||
expect(response).to redirect_to(launch_url)
|
||||
end
|
||||
end
|
||||
|
||||
context "when remoteStorage is not enabled for the user" do
|
||||
before do
|
||||
allow_any_instance_of(LdapService).to receive(:fetch_users).and_return([
|
||||
{ services_enabled: [] }
|
||||
])
|
||||
|
||||
get :launch_app, params: { id: 1 }
|
||||
end
|
||||
|
||||
it "responds with forbidden" do
|
||||
expect(response).to have_http_status(:forbidden)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user