Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorImre Farkas <ifarkas@gitlab.com>2019-04-05 14:45:47 +0300
committerAndreas Brandl <abrandl@gitlab.com>2019-04-05 14:45:47 +0300
commitd9d7237d2ebf101ca35ed8ba2740e7c7093437ea (patch)
tree419b0af4bc8de6de5888feec4f502bcc468df400 /spec/support/external_authorization_service_helpers.rb
parent30fa3cbdb74df2dfeebb2929a10dd301a0dde55e (diff)
Move Contribution Analytics related spec in spec/features/groups/group_page_with_external_authorization_service_spec to EE
Diffstat (limited to 'spec/support/external_authorization_service_helpers.rb')
-rw-r--r--spec/support/external_authorization_service_helpers.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/support/external_authorization_service_helpers.rb b/spec/support/external_authorization_service_helpers.rb
new file mode 100644
index 00000000000..79dd9a3d58e
--- /dev/null
+++ b/spec/support/external_authorization_service_helpers.rb
@@ -0,0 +1,33 @@
+module ExternalAuthorizationServiceHelpers
+ def enable_external_authorization_service_check
+ stub_application_setting(external_authorization_service_enabled: true)
+
+ stub_application_setting(external_authorization_service_url: 'https://authorize.me')
+ stub_application_setting(external_authorization_service_default_label: 'default_label')
+ stub_request(:post, "https://authorize.me").to_return(status: 200)
+ end
+
+ def external_service_set_access(allowed, user, project)
+ enable_external_authorization_service_check
+ classification_label = ::Gitlab::CurrentSettings.current_application_settings
+ .external_authorization_service_default_label
+
+ # Reload the project so cached licensed features are reloaded
+ if project
+ classification_label = Project.find(project.id).external_authorization_classification_label
+ end
+
+ allow(::Gitlab::ExternalAuthorization)
+ .to receive(:access_allowed?)
+ .with(user, classification_label, any_args)
+ .and_return(allowed)
+ end
+
+ def external_service_allow_access(user, project = nil)
+ external_service_set_access(true, user, project)
+ end
+
+ def external_service_deny_access(user, project = nil)
+ external_service_set_access(false, user, project)
+ end
+end