From 75687c79df805b57914d79cf217e3f08dbc77cc2 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Tue, 12 Nov 2019 00:06:21 +0000 Subject: [PATCH] Add latest changes from gitlab-org/gitlab@master --- .../project_error_tracking_setting.rb | 3 + .../unreleased/ff-user-ids-per-scope-fe.yml | 5 + doc/api/scim.md | 2 +- doc/api/users.md | 4 +- doc/user/admin_area/index.md | 4 +- doc/user/discussions/index.md | 5 +- .../account/activating_deactivating_users.md | 61 +++ .../account/blocking_unblocking_users.md | 44 ++ doc/user/profile/account/delete_account.md | 57 --- doc/user/project/quick_actions.md | 3 +- lib/gitlab/utils/deep_size.rb | 4 + lib/sentry/client.rb | 15 +- locale/gitlab.pot | 14 +- spec/features/markdown/metrics_spec.rb | 72 ++- spec/fixtures/grafana/dashboard_response.json | 2 +- spec/fixtures/grafana/proxy_response.json | 459 ++++++++++++++++++ spec/lib/gitlab/utils/deep_size_spec.rb | 6 + spec/lib/sentry/client_spec.rb | 9 + .../project_error_tracking_setting_spec.rb | 22 + spec/support/helpers/grafana_api_helpers.rb | 9 + 20 files changed, 696 insertions(+), 104 deletions(-) create mode 100644 changelogs/unreleased/ff-user-ids-per-scope-fe.yml create mode 100644 doc/user/profile/account/activating_deactivating_users.md create mode 100644 doc/user/profile/account/blocking_unblocking_users.md create mode 100644 spec/fixtures/grafana/proxy_response.json diff --git a/app/models/error_tracking/project_error_tracking_setting.rb b/app/models/error_tracking/project_error_tracking_setting.rb index 0fa19b1cedc..2aa058a243f 100644 --- a/app/models/error_tracking/project_error_tracking_setting.rb +++ b/app/models/error_tracking/project_error_tracking_setting.rb @@ -7,6 +7,7 @@ module ErrorTracking SENTRY_API_ERROR_TYPE_MISSING_KEYS = 'missing_keys_in_sentry_response' SENTRY_API_ERROR_TYPE_NON_20X_RESPONSE = 'non_20x_response_from_sentry' + SENTRY_API_ERROR_INVALID_SIZE = 'invalid_size_of_sentry_response' API_URL_PATH_REGEXP = %r{ \A @@ -116,6 +117,8 @@ module ErrorTracking { error: e.message, error_type: SENTRY_API_ERROR_TYPE_NON_20X_RESPONSE } rescue Sentry::Client::MissingKeysError => e { error: e.message, error_type: SENTRY_API_ERROR_TYPE_MISSING_KEYS } + rescue Sentry::Client::ResponseInvalidSizeError => e + { error: e.message, error_type: SENTRY_API_ERROR_INVALID_SIZE } end # http://HOST/api/0/projects/ORG/PROJECT diff --git a/changelogs/unreleased/ff-user-ids-per-scope-fe.yml b/changelogs/unreleased/ff-user-ids-per-scope-fe.yml new file mode 100644 index 00000000000..2d928ce8c8a --- /dev/null +++ b/changelogs/unreleased/ff-user-ids-per-scope-fe.yml @@ -0,0 +1,5 @@ +--- +title: Make User IDs work per scope in Feature Flags +merge_request: 19399 +author: +type: added diff --git a/doc/api/scim.md b/doc/api/scim.md index 134761334b6..cf9d8ebbec2 100644 --- a/doc/api/scim.md +++ b/doc/api/scim.md @@ -21,7 +21,7 @@ Parameters: | Attribute | Type | Required | Description | |:----------|:--------|:---------|:----------------------------------------------------------------------------------------------------------------------------------------| -| `filter` | string | yes | A [filter](#available-filters) expression. | +| `filter` | string | no | A [filter](#available-filters) expression. | | `group_path` | string | yes | Full path to the group. | | `startIndex` | integer | no | The 1-based index indicating where to start returning results from. A value of less than one will be interpreted as 1. | | `count` | integer | no | Desired maximum number of query results. | diff --git a/doc/api/users.md b/doc/api/users.md index f95ad7b62ba..c82a5e23c8e 100644 --- a/doc/api/users.md +++ b/doc/api/users.md @@ -1124,7 +1124,7 @@ Parameters: ## Block user -Blocks the specified user. Available only for admin. +Blocks the specified user. Available only for admin. ``` POST /users/:id/block @@ -1139,7 +1139,7 @@ Will return `201 OK` on success, `404 User Not Found` is user cannot be found or ## Unblock user -Unblocks the specified user. Available only for admin. +Unblocks the specified user. Available only for admin. ``` POST /users/:id/unblock diff --git a/doc/user/admin_area/index.md b/doc/user/admin_area/index.md index c75a8bcac79..6e63bfe8993 100644 --- a/doc/user/admin_area/index.md +++ b/doc/user/admin_area/index.md @@ -112,8 +112,8 @@ To list users matching a specific criteria, click on one of the following tabs o - **2FA Enabled** - **2FA Disabled** - **External** -- **Blocked** -- **Deactivated** +- **[Blocked](../profile/account/blocking_unblocking_users.md)** +- **[Deactivated](../profile/account/activating_deactivating_users.md)** - **Without projects** For each user, their username, email address, are listed, also the date their account was diff --git a/doc/user/discussions/index.md b/doc/user/discussions/index.md index 773f6aaa8a2..dcb75a19b2a 100644 --- a/doc/user/discussions/index.md +++ b/doc/user/discussions/index.md @@ -352,10 +352,7 @@ bottom of the screen with two buttons: Clicking **Submit review** will publish all comments. Any quick actions submitted are performed at this time. -Alternatively, to finish the entire review from a pending comment: - -- Click the **Finish review** button on the comment. -- Use the `/submit_review` [quick action](../project/quick_actions.md) in the text of the comment. +Alternatively, every pending comment has a button to finish the entire review. ![Review submission](img/review_preview.png) diff --git a/doc/user/profile/account/activating_deactivating_users.md b/doc/user/profile/account/activating_deactivating_users.md new file mode 100644 index 00000000000..26ebe010c1b --- /dev/null +++ b/doc/user/profile/account/activating_deactivating_users.md @@ -0,0 +1,61 @@ +--- +type: howto +--- + +# Activating and deactivating users + +## Deactivating a user + +> [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/issues/63921) in GitLab 12.4. + +In order to temporarily prevent access by a GitLab user that has no recent activity, administrators can choose to deactivate the user. + +Deactivating a user is functionally identical to [blocking a user](blocking_unblocking_users.md), with the following differences: + +- It does not prohibit the user from logging back in via the UI. +- Once a deactivated user logs back into the GitLab UI, their account is set to active. + +A deactivated user: + +- Cannot access Git repositories or the API. +- Will not receive any notifications from GitLab. +- Will not be able to use [slash commands](../../../integration/slash_commands.md). + +Personal projects, group and user history of the deactivated user will be left intact. + +A user can be deactivated from the Admin area. To do this: + +1. Navigate to **Admin Area > Overview > Users**. +1. Select a user. +1. Under the **Account** tab, click **Deactivate user**. + +Please note that for the deactivation option to be visible to an admin, the user: + +- Must be currently active. +- Should not have any activity in the last 180 days. + +Users can also be deactivated using the [GitLab API](../../../api/users.html#deactivate-user). + +NOTE: **Note:** +A deactivated user does not consume a [seat](../../../subscriptions/index.md#managing-subscriptions). + +## Activating a user + +> [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/issues/63921) in GitLab 12.4. + +A deactivated user can be activated from the Admin area. + +To do this: + +1. Navigate to **Admin Area > Overview > Users**. +1. Click on the **Deactivated** tab. +1. Select a user. +1. Under the **Account** tab, click **Activate user**. + +Users can also be activated using the [GitLab API](../../../api/users.html#activate-user). + +NOTE: **Note:** +Activating a user will change the user's state to active and it consumes a [seat](../../../subscriptions/index.md#managing-subscriptions). + +TIP: **Tip:** +A deactivated user can also activate their account by themselves by simply logging back via the UI. diff --git a/doc/user/profile/account/blocking_unblocking_users.md b/doc/user/profile/account/blocking_unblocking_users.md new file mode 100644 index 00000000000..5426927813c --- /dev/null +++ b/doc/user/profile/account/blocking_unblocking_users.md @@ -0,0 +1,44 @@ +--- +type: howto +--- + +# Blocking and unblocking users + +## Blocking a user + +Inorder to completely prevent access of a user to the GitLab instance, admin can choose to block the user. + +Users can be blocked [via an abuse report](../../admin_area/abuse_reports.md#blocking-users), +or directly from the Admin area. To do this: + +1. Navigate to **Admin Area > Overview > Users**. +1. Select a user. +1. Under the **Account** tab, click **Block user**. + +A blocked user: + +- Will not be able to login. +- Cannot access Git repositories or the API. +- Will not receive any notifications from GitLab. +- Will not be able to use [slash commands](../../../integration/slash_commands.md). + +Personal projects, group and user history of the blocked user will be left intact. + +Users can also be blocked using the [GitLab API](../../../api/users.html#block-user). + +NOTE: **Note:** +A blocked user does not consume a [seat](../../../subscriptions/index.md#managing-subscriptions). + +## Unblocking a user + +A blocked user can be unblocked from the Admin area. To do this: + +1. Navigate to **Admin Area > Overview > Users**. +1. Click on the **Blocked** tab. +1. Select a user. +1. Under the **Account** tab, click **Unblock user**. + +Users can also be unblocked using the [GitLab API](../../../api/users.html#unblock-user). + +NOTE: **Note:** +Unblocking a user will change the user's state to active and it consumes a [seat](../../../subscriptions/index.md#managing-subscriptions). diff --git a/doc/user/profile/account/delete_account.md b/doc/user/profile/account/delete_account.md index be761ca7558..beea063672e 100644 --- a/doc/user/profile/account/delete_account.md +++ b/doc/user/profile/account/delete_account.md @@ -32,63 +32,6 @@ As an administrator, you can delete a user account by: - **Delete user and contributions** to delete the user and their associated records. -### Blocking a user - -In addition to blocking a user -[via an abuse report](../../admin_area/abuse_reports.md#blocking-users), -a user can be blocked directly from the Admin area. To do this: - -1. Navigate to **Admin Area > Overview > Users**. -1. Selecting a user. -1. Under the **Account** tab, click **Block user**. - -### Deactivating a user - -> [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/issues/63921) in GitLab 12.4. - -A user can be deactivated from the Admin area. Deactivating a user is functionally identical to blocking a user, with the following differences: - -- It does not prohibit the user from logging back in via the UI. -- Once a deactivated user logs back into the GitLab UI, their account is set to active. - -A deactivated user: - -- Cannot access Git repositories or the API. -- Will not receive any notifications from GitLab. -- Will not be able to use [slash commands](../../../integration/slash_commands.md). - -Personal projects, group and user history of the deactivated user will be left intact. - -NOTE: **Note:** -A deactivated user does not consume a [seat](../../../subscriptions/index.md#managing-subscriptions). - -To do this: - -1. Navigate to **Admin Area > Overview > Users**. -1. Select a user. -1. Under the **Account** tab, click **Deactivate user**. - -Please note that for the deactivation option to be visible to an admin, the user: - -- Must be currently active. -- Should not have any activity in the last 180 days. - -### Activating a user - -> [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/issues/63921) in GitLab 12.4. - -A deactivated user can be activated from the Admin area. Activating a user sets their account to active state. - -To do this: - -1. Navigate to **Admin Area > Overview > Users**. -1. Click on the **Deactivated** tab. -1. Select a user. -1. Under the **Account** tab, click **Activate user**. - -TIP: **Tip:** -A deactivated user can also activate their account by themselves by simply logging back via the UI. - ## Associated Records > - Introduced for issues in diff --git a/doc/user/project/quick_actions.md b/doc/user/project/quick_actions.md index 9a9e54d7caa..61bc66a6a69 100644 --- a/doc/user/project/quick_actions.md +++ b/doc/user/project/quick_actions.md @@ -68,8 +68,7 @@ The following quick actions are applicable to descriptions, discussions and thre | `/remove_zoom` | ✓ | | | Remove Zoom meeting from this issue. ([Introduced in GitLab 12.4](https://gitlab.com/gitlab-org/gitlab/merge_requests/16609)) | | `/target_branch ` | | ✓ | | Set target branch | | `/wip` | | ✓ | | Toggle the Work In Progress status | -| `/approve` | | ✓ | | Approve the merge request **(STARTER)** | -| `/submit_review` | | ✓ | | Submit a pending review. ([Introduced in GitLab 12.5](https://gitlab.com/gitlab-org/gitlab/issues/8041)) **(PREMIUM)** | +| `/approve` | | ✓ | | Approve the merge request | | `/merge` | | ✓ | | Merge (when pipeline succeeds) | | `/child_epic ` | | | ✓ | Add child epic to ``. The `` value should be in the format of `&epic`, `group&epic`, or a URL to an epic. ([Introduced in GitLab 12.0](https://gitlab.com/gitlab-org/gitlab/issues/7330)) **(ULTIMATE)** | | `/remove_child_epic ` | | | ✓ | Remove child epic from ``. The `` value should be in the format of `&epic`, `group&epic`, or a URL to an epic. ([Introduced in GitLab 12.0](https://gitlab.com/gitlab-org/gitlab/issues/7330)) **(ULTIMATE)** | diff --git a/lib/gitlab/utils/deep_size.rb b/lib/gitlab/utils/deep_size.rb index 562cf09e249..ed2ceb8af7c 100644 --- a/lib/gitlab/utils/deep_size.rb +++ b/lib/gitlab/utils/deep_size.rb @@ -25,6 +25,10 @@ module Gitlab !too_big? && !too_deep? end + def self.human_default_max_size + ActiveSupport::NumberHelper.number_to_human_size(DEFAULT_MAX_SIZE) + end + private def evaluate diff --git a/lib/sentry/client.rb b/lib/sentry/client.rb index f16df0dde4f..15158bbc3b5 100644 --- a/lib/sentry/client.rb +++ b/lib/sentry/client.rb @@ -4,6 +4,7 @@ module Sentry class Client Error = Class.new(StandardError) MissingKeysError = Class.new(StandardError) + ResponseInvalidSizeError = Class.new(StandardError) attr_accessor :url, :token @@ -27,6 +28,8 @@ module Sentry def list_issues(issue_status:, limit:) issues = get_issues(issue_status: issue_status, limit: limit) + validate_size(issues) + handle_mapping_exceptions do map_to_errors(issues) end @@ -42,6 +45,16 @@ module Sentry private + def validate_size(issues) + return if Gitlab::Utils::DeepSize.new(issues).valid? + + raise Client::ResponseInvalidSizeError, "Sentry API response is too big. Limit is #{Gitlab::Utils::DeepSize.human_default_max_size}." + end + + def valid_size?(issues) + Gitlab::Utils::DeepSize.new(issues).valid? + end + def handle_mapping_exceptions(&block) yield rescue KeyError => e @@ -108,7 +121,7 @@ module Sentry raise_error "Sentry response status code: #{response.code}" end - response + response.parsed_response end def raise_error(message) diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 06344a6880e..67e9627c7c8 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -7264,6 +7264,9 @@ msgstr "" msgid "FeatureFlags|Inactive flag for %{scope}" msgstr "" +msgid "FeatureFlags|Include additional user IDs" +msgstr "" + msgid "FeatureFlags|Install a %{docs_link_anchored_start}compatible client library%{docs_link_anchored_end} and specify the API URL, application name, and instance ID during the configuration setup. %{docs_link_start}More Information%{docs_link_end}" msgstr "" @@ -13621,7 +13624,7 @@ msgstr "" msgid "Promotions|Learn more" msgstr "" -msgid "Promotions|See the other features in the %{subscription_link_start}bronze plan%{subscriptions_link_end}" +msgid "Promotions|See the other features in the %{subscription_link_start}bronze plan%{subscription_link_end}" msgstr "" msgid "Promotions|This feature is locked." @@ -16280,9 +16283,6 @@ msgstr "" msgid "Subkeys" msgstr "" -msgid "Submit a review" -msgstr "" - msgid "Submit as spam" msgstr "" @@ -16298,12 +16298,6 @@ msgstr "" msgid "Submit search" msgstr "" -msgid "Submit the current review." -msgstr "" - -msgid "Submitted the current review." -msgstr "" - msgid "Subscribe" msgstr "" diff --git a/spec/features/markdown/metrics_spec.rb b/spec/features/markdown/metrics_spec.rb index 580826f4a29..e7fec41fae3 100644 --- a/spec/features/markdown/metrics_spec.rb +++ b/spec/features/markdown/metrics_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' describe 'Metrics rendering', :js, :use_clean_rails_memory_store_caching, :sidekiq_might_not_need_inline do include PrometheusHelpers + include GrafanaApiHelpers let(:user) { create(:user) } let(:project) { create(:prometheus_project) } @@ -14,11 +15,7 @@ describe 'Metrics rendering', :js, :use_clean_rails_memory_store_caching, :sidek before do configure_host - import_common_metrics - stub_any_prometheus_request_with_response - project.add_developer(user) - sign_in(user) end @@ -26,31 +23,58 @@ describe 'Metrics rendering', :js, :use_clean_rails_memory_store_caching, :sidek restore_host end - it 'shows embedded metrics' do - visit project_issue_path(project, issue) - - expect(page).to have_css('div.prometheus-graph') - expect(page).to have_text('Memory Usage (Total)') - expect(page).to have_text('Core Usage (Total)') - end - - context 'when dashboard params are in included the url' do - let(:metrics_url) { metrics_project_environment_url(project, environment, **chart_params) } - - let(:chart_params) do - { - group: 'System metrics (Kubernetes)', - title: 'Memory Usage (Pod average)', - y_label: 'Memory Used per Pod (MB)' - } + context 'internal metrics embeds' do + before do + import_common_metrics + stub_any_prometheus_request_with_response end - it 'shows embedded metrics for the specifiec chart' do + it 'shows embedded metrics' do visit project_issue_path(project, issue) expect(page).to have_css('div.prometheus-graph') - expect(page).to have_text(chart_params[:title]) - expect(page).to have_text(chart_params[:y_label]) + expect(page).to have_text('Memory Usage (Total)') + expect(page).to have_text('Core Usage (Total)') + end + + context 'when dashboard params are in included the url' do + let(:metrics_url) { metrics_project_environment_url(project, environment, **chart_params) } + + let(:chart_params) do + { + group: 'System metrics (Kubernetes)', + title: 'Memory Usage (Pod average)', + y_label: 'Memory Used per Pod (MB)' + } + end + + it 'shows embedded metrics for the specific chart' do + visit project_issue_path(project, issue) + + expect(page).to have_css('div.prometheus-graph') + expect(page).to have_text(chart_params[:title]) + expect(page).to have_text(chart_params[:y_label]) + end + end + end + + context 'grafana metrics embeds' do + let(:grafana_integration) { create(:grafana_integration, project: project) } + let(:grafana_base_url) { grafana_integration.grafana_url } + let(:metrics_url) { valid_grafana_dashboard_link(grafana_base_url) } + + before do + stub_dashboard_request(grafana_base_url) + stub_datasource_request(grafana_base_url) + stub_all_grafana_proxy_requests(grafana_base_url) + end + + it 'shows embedded metrics' do + visit project_issue_path(project, issue) + + expect(page).to have_css('div.prometheus-graph') + expect(page).to have_text('Expired / Evicted') + expect(page).to have_text('expired - test-attribute-value') end end diff --git a/spec/fixtures/grafana/dashboard_response.json b/spec/fixtures/grafana/dashboard_response.json index 4743ec39b44..c0dd77e2fdc 100644 --- a/spec/fixtures/grafana/dashboard_response.json +++ b/spec/fixtures/grafana/dashboard_response.json @@ -424,7 +424,7 @@ "format": "time_series", "interval": "1m", "intervalFactor": 2, - "legendFormat": "expired", + "legendFormat": "expired - {{ test_attribute }}", "metric": "", "refId": "A", "step": 240, diff --git a/spec/fixtures/grafana/proxy_response.json b/spec/fixtures/grafana/proxy_response.json new file mode 100644 index 00000000000..b9f34abcaaf --- /dev/null +++ b/spec/fixtures/grafana/proxy_response.json @@ -0,0 +1,459 @@ +{ + "status": "success", + "data": { + "resultType": "matrix", + "result": [ + { + "metric": { + "test_attribute": "test-attribute-value" + }, + "values": [ + [1570768177, "54"], + [1570768237, "54"], + [1570768297, "54"], + [1570768357, "54"], + [1570768417, "54"], + [1570768477, "54"], + [1570768537, "54"], + [1570768597, "54"], + [1570768657, "54"], + [1570768717, "54"], + [1570768777, "54"], + [1570768837, "54"], + [1570768897, "54"], + [1570768957, "54"], + [1570769017, "54"], + [1570769077, "54"], + [1570769377, "54"], + [1570769437, "54"], + [1570769497, "54"], + [1570769557, "54"], + [1570769617, "54"], + [1570769677, "54"], + [1570769737, "54"], + [1570769797, "54"], + [1570769857, "54"], + [1570769917, "54"], + [1570769977, "54"], + [1570770037, "54"], + [1570770097, "54"], + [1570770157, "54"], + [1570770217, "54"], + [1570770277, "54"], + [1570770337, "54"], + [1570770397, "54"], + [1570770457, "54"], + [1570770517, "54"], + [1570770577, "54"], + [1570770637, "54"], + [1570770697, "54"], + [1570770757, "54"], + [1570770817, "54"], + [1570770877, "54"], + [1570770937, "54"], + [1570770997, "54"], + [1570771057, "54"], + [1570771117, "54"], + [1570771177, "54"], + [1570771237, "54"], + [1570771297, "54"], + [1570771357, "54"], + [1570771417, "54"], + [1570771477, "54"], + [1570771537, "54"], + [1570771597, "54"], + [1570771657, "54"], + [1570771717, "54"], + [1570771777, "54"], + [1570771837, "54"], + [1570771897, "54"], + [1570771957, "54"], + [1570772017, "54"], + [1570772077, "54"], + [1570772137, "54"], + [1570772197, "54"], + [1570772257, "54"], + [1570772317, "54"], + [1570772377, "54"], + [1570772437, "54"], + [1570772497, "54"], + [1570772557, "54"], + [1570772617, "54"], + [1570772677, "54"], + [1570772737, "54"], + [1570772797, "54"], + [1570772857, "54"], + [1570772917, "54"], + [1570772977, "54"], + [1570773037, "54"], + [1570773097, "54"], + [1570773157, "54"], + [1570773217, "54"], + [1570773277, "54"], + [1570773337, "54"], + [1570773397, "54"], + [1570773457, "54"], + [1570773517, "54"], + [1570773577, "54"], + [1570773637, "54"], + [1570773697, "54"], + [1570773757, "54"], + [1570773817, "54"], + [1570773877, "54"], + [1570773937, "54"], + [1570773997, "54"], + [1570774057, "54"], + [1570774117, "54"], + [1570774177, "54"], + [1570774237, "54"], + [1570774297, "54"], + [1570774357, "54"], + [1570774417, "54"], + [1570774477, "54"], + [1570774537, "54"], + [1570774597, "54"], + [1570774657, "54"], + [1570774717, "54"], + [1570774777, "54"], + [1570774837, "54"], + [1570774897, "54"], + [1570774957, "54"], + [1570775017, "54"], + [1570775077, "54"], + [1570775137, "54"], + [1570776937, "54"], + [1570776997, "54"], + [1570777057, "54"], + [1570777117, "54"], + [1570777177, "54"], + [1570777237, "54"], + [1570777297, "54"], + [1570777357, "54"], + [1570777417, "54"], + [1570777477, "54"], + [1570777537, "54"], + [1570777597, "54"], + [1570777657, "54"], + [1570777717, "54"], + [1570778017, "54"], + [1570778077, "54"], + [1570778137, "54"], + [1570778197, "54"], + [1570778257, "54"], + [1570778317, "54"], + [1570778377, "54"], + [1570778437, "54"], + [1570778497, "54"], + [1570778557, "54"], + [1570778617, "54"], + [1570778677, "54"], + [1570778737, "54"], + [1570778797, "54"], + [1570778857, "54"], + [1570778917, "54"], + [1570778977, "54"], + [1570779037, "54"], + [1570779097, "54"], + [1570779157, "54"], + [1570779217, "54"], + [1570779277, "54"], + [1570779337, "54"], + [1570779397, "54"], + [1570779457, "54"], + [1570779517, "54"], + [1570779577, "54"], + [1570779637, "54"], + [1570779697, "54"], + [1570779757, "54"], + [1570779817, "54"], + [1570779877, "54"], + [1570779937, "54"], + [1570779997, "54"], + [1570780057, "54"], + [1570780117, "54"], + [1570780177, "54"], + [1570780237, "54"], + [1570780297, "54"], + [1570780357, "54"], + [1570780417, "54"], + [1570780477, "54"], + [1570780537, "54"], + [1570780597, "54"], + [1570780657, "54"], + [1570780717, "54"], + [1570780777, "54"], + [1570780837, "54"], + [1570780897, "54"], + [1570780957, "54"], + [1570781017, "54"], + [1570781077, "54"], + [1570781137, "54"], + [1570781197, "54"], + [1570781257, "54"], + [1570781317, "54"], + [1570781377, "54"], + [1570781437, "54"], + [1570781497, "54"], + [1570781557, "54"], + [1570781617, "54"], + [1570781677, "54"], + [1570781737, "54"], + [1570781797, "54"], + [1570781857, "54"], + [1570781917, "54"], + [1570781977, "54"], + [1570782037, "54"], + [1570782097, "54"], + [1570782157, "54"], + [1570782217, "54"], + [1570782277, "54"], + [1570782337, "54"], + [1570782397, "54"], + [1570782457, "54"], + [1570782517, "54"], + [1570782577, "54"], + [1570782637, "54"], + [1570782697, "54"], + [1570782757, "54"], + [1570782817, "54"], + [1570782877, "54"], + [1570782937, "54"], + [1570782997, "54"], + [1570783057, "54"], + [1570783117, "54"], + [1570783177, "54"], + [1570783237, "54"], + [1570783297, "54"], + [1570783357, "54"], + [1570783417, "54"], + [1570783477, "54"], + [1570783537, "54"], + [1570783597, "54"], + [1570783657, "54"], + [1570783717, "54"], + [1570783777, "54"], + [1570783837, "54"], + [1570783897, "54"], + [1570783957, "54"], + [1570784017, "54"], + [1570784077, "54"], + [1570784137, "54"], + [1570784197, "54"], + [1570784257, "54"], + [1570784317, "54"], + [1570784377, "54"], + [1570784437, "54"], + [1570784497, "54"], + [1570784557, "54"], + [1570784617, "54"], + [1570784677, "54"], + [1570784737, "54"], + [1570784797, "54"], + [1570784857, "54"], + [1570784917, "54"], + [1570784977, "54"], + [1570785037, "54"], + [1570785097, "54"], + [1570785157, "54"], + [1570785217, "54"], + [1570785277, "54"], + [1570785337, "54"], + [1570785397, "54"], + [1570785457, "54"], + [1570785517, "54"], + [1570785577, "54"], + [1570785637, "54"], + [1570785697, "54"], + [1570785757, "54"], + [1570785817, "54"], + [1570785877, "54"], + [1570785937, "54"], + [1570785997, "54"], + [1570786057, "54"], + [1570786117, "54"], + [1570786177, "54"], + [1570786237, "54"], + [1570786297, "54"], + [1570786357, "54"], + [1570786417, "54"], + [1570786477, "54"], + [1570786537, "54"], + [1570786597, "54"], + [1570786657, "54"], + [1570786717, "54"], + [1570786777, "54"], + [1570786837, "54"], + [1570786897, "54"], + [1570786957, "53"], + [1570787017, "54"], + [1570787077, "54"], + [1570787137, "54"], + [1570787197, "54"], + [1570787257, "54"], + [1570787317, "54"], + [1570787377, "54"], + [1570787437, "54"], + [1570787497, "54"], + [1570787557, "54"], + [1570787617, "54"], + [1570787677, "54"], + [1570787737, "54"], + [1570787797, "54"], + [1570787857, "54"], + [1570787917, "54"], + [1570787977, "54"], + [1570788037, "54"], + [1570788097, "54"], + [1570788157, "54"], + [1570788217, "54"], + [1570788277, "54"], + [1570788337, "54"], + [1570788397, "54"], + [1570788457, "54"], + [1570788517, "54"], + [1570788577, "54"], + [1570788637, "54"], + [1570788697, "54"], + [1570788757, "54"], + [1570788817, "54"], + [1570788877, "54"], + [1570788937, "54"], + [1570788997, "54"], + [1570789057, "54"], + [1570789117, "54"], + [1570789177, "54"], + [1570789237, "54"], + [1570789297, "54"], + [1570789357, "54"], + [1570789417, "54"], + [1570789477, "54"], + [1570789537, "54"], + [1570789597, "54"], + [1570789657, "54"], + [1570789717, "54"], + [1570789777, "54"], + [1570789837, "54"], + [1570789897, "54"], + [1570789957, "54"], + [1570790017, "54"], + [1570790077, "54"], + [1570790137, "54"], + [1570790197, "54"], + [1570790257, "54"], + [1570790317, "54"], + [1570790377, "54"], + [1570790437, "54"], + [1570790497, "54"], + [1570790557, "54"], + [1570790617, "54"], + [1570790677, "54"], + [1570790737, "54"], + [1570790797, "54"], + [1570790857, "54"], + [1570790917, "54"], + [1570790977, "54"], + [1570791037, "54"], + [1570791097, "54"], + [1570791157, "54"], + [1570791217, "54"], + [1570791277, "54"], + [1570791337, "54"], + [1570791397, "54"], + [1570791457, "54"], + [1570791517, "54"], + [1570791577, "54"], + [1570791637, "54"], + [1570791697, "54"], + [1570791757, "54"], + [1570791817, "54"], + [1570791877, "54"], + [1570791937, "54"], + [1570791997, "54"], + [1570792057, "54"], + [1570792117, "54"], + [1570792177, "54"], + [1570792237, "54"], + [1570792297, "54"], + [1570792357, "54"], + [1570792417, "54"], + [1570792477, "54"], + [1570792537, "54"], + [1570792597, "54"], + [1570792657, "54"], + [1570792717, "54"], + [1570792777, "54"], + [1570792837, "54"], + [1570792897, "54"], + [1570792957, "54"], + [1570793017, "54"], + [1570793077, "54"], + [1570793137, "54"], + [1570793197, "54"], + [1570793257, "54"], + [1570793317, "54"], + [1570793377, "54"], + [1570793437, "54"], + [1570793497, "54"], + [1570793557, "54"], + [1570793617, "54"], + [1570793677, "54"], + [1570793737, "54"], + [1570793797, "54"], + [1570793857, "54"], + [1570793917, "54"], + [1570793977, "54"], + [1570794037, "54"], + [1570794097, "54"], + [1570794157, "54"], + [1570794217, "54"], + [1570794277, "54"], + [1570794337, "54"], + [1570794397, "54"], + [1570794457, "54"], + [1570794517, "54"], + [1570794577, "54"], + [1570794637, "54"], + [1570794697, "54"], + [1570794757, "54"], + [1570794817, "54"], + [1570794877, "54"], + [1570794937, "54"], + [1570794997, "54"], + [1570795057, "54"], + [1570795117, "54"], + [1570795177, "54"], + [1570795237, "54"], + [1570795297, "54"], + [1570795357, "54"], + [1570795417, "54"], + [1570795477, "54"], + [1570795537, "54"], + [1570795597, "54"], + [1570795657, "54"], + [1570795717, "54"], + [1570795777, "54"], + [1570795837, "54"], + [1570795897, "54"], + [1570795957, "54"], + [1570796017, "54"], + [1570796077, "54"], + [1570796137, "54"], + [1570796197, "54"], + [1570796257, "54"], + [1570796317, "54"], + [1570796377, "54"], + [1570796437, "55"], + [1570796497, "54"], + [1570796557, "54"], + [1570796617, "54"], + [1570796677, "54"], + [1570796737, "54"], + [1570796797, "54"], + [1570796857, "54"], + [1570796917, "54"], + [1570796977, "54"] + ] + } + ] + } +} diff --git a/spec/lib/gitlab/utils/deep_size_spec.rb b/spec/lib/gitlab/utils/deep_size_spec.rb index 47dfc04f46f..ccd202b33f7 100644 --- a/spec/lib/gitlab/utils/deep_size_spec.rb +++ b/spec/lib/gitlab/utils/deep_size_spec.rb @@ -42,4 +42,10 @@ describe Gitlab::Utils::DeepSize do end end end + + describe '.human_default_max_size' do + it 'returns 1 MB' do + expect(described_class.human_default_max_size).to eq('1 MB') + end + end end diff --git a/spec/lib/sentry/client_spec.rb b/spec/lib/sentry/client_spec.rb index ca2b17b44e0..8101664d34f 100644 --- a/spec/lib/sentry/client_spec.rb +++ b/spec/lib/sentry/client_spec.rb @@ -192,6 +192,15 @@ describe Sentry::Client do end end + context 'sentry api response too large' do + it 'raises exception' do + deep_size = double('Gitlab::Utils::DeepSize', valid?: false) + allow(Gitlab::Utils::DeepSize).to receive(:new).with(sentry_api_response).and_return(deep_size) + + expect { subject }.to raise_error(Sentry::Client::ResponseInvalidSizeError, 'Sentry API response is too big. Limit is 1 MB.') + end + end + it_behaves_like 'maps exceptions' end diff --git a/spec/models/error_tracking/project_error_tracking_setting_spec.rb b/spec/models/error_tracking/project_error_tracking_setting_spec.rb index 21e381d9fb7..dbd3f8ffab3 100644 --- a/spec/models/error_tracking/project_error_tracking_setting_spec.rb +++ b/spec/models/error_tracking/project_error_tracking_setting_spec.rb @@ -208,6 +208,28 @@ describe ErrorTracking::ProjectErrorTrackingSetting do expect(sentry_client).to have_received(:list_issues) end end + + context 'when sentry client raises Sentry::Client::ResponseInvalidSizeError' do + let(:sentry_client) { spy(:sentry_client) } + let(:error_msg) {"Sentry API response is too big. Limit is #{Gitlab::Utils::DeepSize.human_default_max_size}."} + + before do + synchronous_reactive_cache(subject) + + allow(subject).to receive(:sentry_client).and_return(sentry_client) + allow(sentry_client).to receive(:list_issues).with(opts) + .and_raise(Sentry::Client::ResponseInvalidSizeError, error_msg) + end + + it 'returns error' do + expect(result).to eq( + error: error_msg, + error_type: ErrorTracking::ProjectErrorTrackingSetting::SENTRY_API_ERROR_INVALID_SIZE + ) + expect(subject).to have_received(:sentry_client) + expect(sentry_client).to have_received(:list_issues) + end + end end describe '#list_sentry_projects' do diff --git a/spec/support/helpers/grafana_api_helpers.rb b/spec/support/helpers/grafana_api_helpers.rb index b212cbf2943..e47b1a808f2 100644 --- a/spec/support/helpers/grafana_api_helpers.rb +++ b/spec/support/helpers/grafana_api_helpers.rb @@ -29,4 +29,13 @@ module GrafanaApiHelpers headers: { 'Content-Type' => 'application/json' } ) end + + def stub_all_grafana_proxy_requests(base_url) + stub_request(:any, /#{base_url}\/api\/datasources\/proxy/) + .to_return( + status: 200, + body: fixture_file('grafana/proxy_response.json'), + headers: { 'Content-Type' => 'application/json' } + ) + end end