summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Gemfile.lock2
-rw-r--r--app/assets/javascripts/notes/components/diff_with_note.vue7
-rw-r--r--app/assets/javascripts/pages/projects/pages_domains/form.js16
-rw-r--r--app/assets/javascripts/releases/components/release_block.vue26
-rw-r--r--app/assets/javascripts/vue_shared/components/paginated_list.vue35
-rw-r--r--app/controllers/projects/issues_controller.rb16
-rw-r--r--app/controllers/projects/pages_domains_controller.rb8
-rw-r--r--app/models/pages_domain.rb30
-rw-r--r--app/services/boards/issues/move_service.rb6
-rw-r--r--app/services/issues/reorder_service.rb48
-rw-r--r--app/services/issues/update_service.rb1
-rw-r--r--app/services/pages_domains/obtain_lets_encrypt_certificate_service.rb2
-rw-r--r--app/views/layouts/nav/sidebar/_group.html.haml3
-rw-r--r--app/views/projects/pages_domains/_form.html.haml26
-rw-r--r--changelogs/unreleased/38105-pre-release-tag.yml5
-rw-r--r--changelogs/unreleased/59028-fix-extra-plus-in-diffs.yml5
-rw-r--r--changelogs/unreleased/db-update-geo-nodes-primary.yml5
-rw-r--r--changelogs/unreleased/paginate-license-management.yml5
-rw-r--r--changelogs/unreleased/sanitize_rake_ldap_check_output.yml5
-rw-r--r--config/routes/project.rb1
-rw-r--r--db/migrate/20190607085356_add_source_to_pages_domains.rb21
-rw-r--r--db/post_migrate/20190618171120_update_geo_nodes_primary.rb20
-rw-r--r--db/schema.rb3
-rw-r--r--doc/administration/geo/replication/troubleshooting.md108
-rw-r--r--doc/user/application_security/license_management/img/license_management_add_license.pngbin0 -> 87049 bytes
-rw-r--r--doc/user/application_security/license_management/img/license_management_search.pngbin0 -> 104278 bytes
-rw-r--r--doc/user/application_security/license_management/img/license_management_settings.pngbin13300 -> 171592 bytes
-rw-r--r--doc/user/application_security/license_management/index.md16
-rw-r--r--doc/user/project/description_templates.md1
-rw-r--r--lib/api/pages_domains.rb15
-rw-r--r--lib/gitlab/ci/ansi2html.rb4
-rw-r--r--lib/system_check/ldap_check.rb9
-rw-r--r--locale/gitlab.pot9
-rw-r--r--spec/controllers/projects/issues_controller_spec.rb84
-rw-r--r--spec/controllers/projects/pages_domains_controller_spec.rb64
-rw-r--r--spec/factories/pages_domains.rb4
-rw-r--r--spec/features/projects/pages_lets_encrypt_spec.rb153
-rw-r--r--spec/features/projects/pages_spec.rb16
-rw-r--r--spec/frontend/vue_shared/components/paginated_list_spec.js56
-rw-r--r--spec/javascripts/notes/components/diff_with_note_spec.js13
-rw-r--r--spec/javascripts/releases/components/release_block_spec.js14
-rw-r--r--spec/lib/gitlab/ci/ansi2html_spec.rb8
-rw-r--r--spec/lib/gitlab/ci/trace/stream_spec.rb10
-rw-r--r--spec/lib/gitlab/highlight_spec.rb13
-rw-r--r--spec/models/pages_domain_spec.rb96
-rw-r--r--spec/requests/api/pages_domains_spec.rb8
-rw-r--r--spec/services/issues/reorder_service_spec.rb88
-rw-r--r--spec/services/issues/update_service_spec.rb16
-rw-r--r--spec/services/pages_domains/obtain_lets_encrypt_certificate_service_spec.rb6
-rw-r--r--spec/support/shared_examples/ci_trace_shared_examples.rb2
-rw-r--r--spec/tasks/gitlab/check_rake_spec.rb9
51 files changed, 882 insertions, 236 deletions
diff --git a/Gemfile.lock b/Gemfile.lock
index b03bd58eacc..4881faac0e0 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -770,7 +770,7 @@ GEM
retriable (3.1.2)
rinku (2.0.0)
rotp (2.1.2)
- rouge (3.3.0)
+ rouge (3.4.1)
rqrcode (0.7.0)
chunky_png
rqrcode-rails3 (0.1.7)
diff --git a/app/assets/javascripts/notes/components/diff_with_note.vue b/app/assets/javascripts/notes/components/diff_with_note.vue
index b95835ed10a..54c242b2fda 100644
--- a/app/assets/javascripts/notes/components/diff_with_note.vue
+++ b/app/assets/javascripts/notes/components/diff_with_note.vue
@@ -7,6 +7,8 @@ import { GlSkeletonLoading } from '@gitlab/ui';
import { getDiffMode } from '~/diffs/store/utils';
import { diffViewerModes } from '~/ide/constants';
+const FIRST_CHAR_REGEX = /^(\+|-| )/;
+
export default {
components: {
DiffFileHeader,
@@ -59,6 +61,9 @@ export default {
this.error = true;
});
},
+ trimChar(line) {
+ return line.replace(FIRST_CHAR_REGEX, '');
+ },
},
userColorSchemeClass: window.gon.user_color_scheme,
};
@@ -83,7 +88,7 @@ export default {
>
<td :class="line.type" class="diff-line-num old_line">{{ line.old_line }}</td>
<td :class="line.type" class="diff-line-num new_line">{{ line.new_line }}</td>
- <td :class="line.type" class="line_content" v-html="line.rich_text"></td>
+ <td :class="line.type" class="line_content" v-html="trimChar(line.rich_text)"></td>
</tr>
</template>
<tr v-if="!hasTruncatedDiffLines" class="line_holder line-holder-placeholder">
diff --git a/app/assets/javascripts/pages/projects/pages_domains/form.js b/app/assets/javascripts/pages/projects/pages_domains/form.js
index 1d0dbfe0406..cef8e92610c 100644
--- a/app/assets/javascripts/pages/projects/pages_domains/form.js
+++ b/app/assets/javascripts/pages/projects/pages_domains/form.js
@@ -5,14 +5,6 @@ export default () => {
if (toggleContainer) {
const onToggleButtonClicked = isAutoSslEnabled => {
- Array.from(document.querySelectorAll('.js-shown-if-auto-ssl')).forEach(el => {
- if (isAutoSslEnabled) {
- el.classList.remove('d-none');
- } else {
- el.classList.add('d-none');
- }
- });
-
Array.from(document.querySelectorAll('.js-shown-unless-auto-ssl')).forEach(el => {
if (isAutoSslEnabled) {
el.classList.add('d-none');
@@ -21,14 +13,6 @@ export default () => {
}
});
- Array.from(document.querySelectorAll('.js-enabled-if-auto-ssl')).forEach(el => {
- if (isAutoSslEnabled) {
- el.removeAttribute('disabled');
- } else {
- el.setAttribute('disabled', 'disabled');
- }
- });
-
Array.from(document.querySelectorAll('.js-enabled-unless-auto-ssl')).forEach(el => {
if (isAutoSslEnabled) {
el.setAttribute('disabled', 'disabled');
diff --git a/app/assets/javascripts/releases/components/release_block.vue b/app/assets/javascripts/releases/components/release_block.vue
index 0958b9fa926..f510b905a2e 100644
--- a/app/assets/javascripts/releases/components/release_block.vue
+++ b/app/assets/javascripts/releases/components/release_block.vue
@@ -1,6 +1,6 @@
<script>
import _ from 'underscore';
-import { GlTooltipDirective, GlLink } from '@gitlab/ui';
+import { GlTooltipDirective, GlLink, GlBadge } from '@gitlab/ui';
import Icon from '~/vue_shared/components/icon.vue';
import UserAvatarLink from '~/vue_shared/components/user_avatar/user_avatar_link.vue';
import timeagoMixin from '~/vue_shared/mixins/timeago';
@@ -10,6 +10,7 @@ export default {
name: 'ReleaseBlock',
components: {
GlLink,
+ GlBadge,
Icon,
UserAvatarLink,
},
@@ -53,7 +54,12 @@ export default {
<template>
<div class="card">
<div class="card-body">
- <h2 class="card-title mt-0">{{ release.name }}</h2>
+ <h2 class="card-title mt-0">
+ {{ release.name }}
+ <gl-badge v-if="release.pre_release" variant="warning" class="align-middle">{{
+ __('Pre-release')
+ }}</gl-badge>
+ </h2>
<div class="card-subtitle d-flex flex-wrap text-secondary">
<div class="append-right-8">
@@ -68,9 +74,9 @@ export default {
<div class="append-right-4">
&bull;
- <span v-gl-tooltip.bottom :title="tooltipTitle(release.created_at)">{{
- releasedTimeAgo
- }}</span>
+ <span v-gl-tooltip.bottom :title="tooltipTitle(release.created_at)">
+ {{ releasedTimeAgo }}
+ </span>
</div>
<div v-if="hasAuthor" class="d-flex">
@@ -98,7 +104,8 @@ export default {
<li v-for="link in assets.links" :key="link.name" class="append-bottom-8">
<gl-link v-gl-tooltip.bottom :title="__('Download asset')" :href="link.url">
<icon name="package" class="align-middle append-right-4 align-text-bottom" />
- {{ link.name }} <span v-if="link.external"> {{ __('(external source)') }}</span>
+ {{ link.name }}
+ <span v-if="link.external">{{ __('(external source)') }}</span>
</gl-link>
</li>
</ul>
@@ -111,7 +118,8 @@ export default {
aria-haspopup="true"
aria-expanded="false"
>
- <icon name="doc-code" class="align-top append-right-4" /> {{ __('Source code') }}
+ <icon name="doc-code" class="align-top append-right-4" />
+ {{ __('Source code') }}
<icon name="arrow-down" />
</button>
@@ -123,7 +131,9 @@ export default {
</div>
</div>
- <div class="card-text prepend-top-default"><div v-html="release.description_html"></div></div>
+ <div class="card-text prepend-top-default">
+ <div v-html="release.description_html"></div>
+ </div>
</div>
</div>
</template>
diff --git a/app/assets/javascripts/vue_shared/components/paginated_list.vue b/app/assets/javascripts/vue_shared/components/paginated_list.vue
new file mode 100644
index 00000000000..e19b8510399
--- /dev/null
+++ b/app/assets/javascripts/vue_shared/components/paginated_list.vue
@@ -0,0 +1,35 @@
+<script>
+import { GlPaginatedList } from '@gitlab/ui';
+import { PREV, NEXT } from '~/vue_shared/components/pagination/constants';
+
+export default {
+ components: {
+ GlPaginatedList,
+ },
+ labels: {
+ prev: PREV,
+ next: NEXT,
+ },
+};
+</script>
+
+<template>
+ <gl-paginated-list
+ v-bind="$attrs"
+ :prev-text="$options.labels.prev"
+ :next-text="$options.labels.next"
+ >
+ <!-- proxy the slots -->
+ <template #header>
+ <slot name="header"></slot>
+ </template>
+
+ <template #subheader>
+ <slot name="subheader"></slot>
+ </template>
+
+ <template #default="{ listItem, query }">
+ <slot :listItem="listItem" :query="query"></slot>
+ </template>
+ </gl-paginated-list>
+</template>
diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb
index b4d89db20c5..b16f3dd9d82 100644
--- a/app/controllers/projects/issues_controller.rb
+++ b/app/controllers/projects/issues_controller.rb
@@ -33,7 +33,7 @@ class Projects::IssuesController < Projects::ApplicationController
before_action :authorize_create_issue!, only: [:new, :create]
# Allow modify issue
- before_action :authorize_update_issuable!, only: [:edit, :update, :move]
+ before_action :authorize_update_issuable!, only: [:edit, :update, :move, :reorder]
# Allow create a new branch and empty WIP merge request from current issue
before_action :authorize_create_merge_request_from!, only: [:create_merge_request]
@@ -132,6 +132,16 @@ class Projects::IssuesController < Projects::ApplicationController
render_conflict_response
end
+ def reorder
+ service = Issues::ReorderService.new(project, current_user, reorder_params)
+
+ if service.execute(issue)
+ head :ok
+ else
+ head :unprocessable_entity
+ end
+ end
+
def related_branches
@related_branches = Issues::RelatedBranchesService.new(project, current_user).execute(issue)
@@ -239,6 +249,10 @@ class Projects::IssuesController < Projects::ApplicationController
] + [{ label_ids: [], assignee_ids: [], update_task: [:index, :checked, :line_number, :line_source] }]
end
+ def reorder_params
+ params.permit(:move_before_id, :move_after_id, :group_full_path)
+ end
+
def store_uri
if request.get? && !request.xhr?
store_location_for :user, request.fullpath
diff --git a/app/controllers/projects/pages_domains_controller.rb b/app/controllers/projects/pages_domains_controller.rb
index 89f21d8dadb..c287e440db0 100644
--- a/app/controllers/projects/pages_domains_controller.rb
+++ b/app/controllers/projects/pages_domains_controller.rb
@@ -65,16 +65,14 @@ class Projects::PagesDomainsController < Projects::ApplicationController
private
def create_params
- params.require(:pages_domain).permit(:key, :certificate, :domain, :auto_ssl_enabled)
+ params.require(:pages_domain).permit(:user_provided_key, :user_provided_certificate, :domain, :auto_ssl_enabled)
end
def update_params
- params.require(:pages_domain).permit(:key, :certificate, :auto_ssl_enabled)
+ params.require(:pages_domain).permit(:user_provided_key, :user_provided_certificate, :auto_ssl_enabled)
end
- # rubocop: disable CodeReuse/ActiveRecord
def domain
- @domain ||= @project.pages_domains.find_by!(domain: params[:id].to_s)
+ @domain ||= @project.pages_domains.find_by_domain!(params[:id].to_s)
end
- # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/models/pages_domain.rb b/app/models/pages_domain.rb
index 524df30289e..07195c0bfd3 100644
--- a/app/models/pages_domain.rb
+++ b/app/models/pages_domain.rb
@@ -4,6 +4,8 @@ class PagesDomain < ApplicationRecord
VERIFICATION_KEY = 'gitlab-pages-verification-code'.freeze
VERIFICATION_THRESHOLD = 3.days.freeze
+ enum certificate_source: { user_provided: 0, gitlab_provided: 1 }, _prefix: :certificate
+
belongs_to :project
has_many :acme_orders, class_name: "PagesDomainAcmeOrder"
@@ -143,6 +145,34 @@ class PagesDomain < ApplicationRecord
self.certificate_valid_not_after = x509&.not_after
end
+ def user_provided_key
+ key if certificate_user_provided?
+ end
+
+ def user_provided_key=(key)
+ self.key = key
+ self.certificate_source = 'user_provided' if key_changed?
+ end
+
+ def user_provided_certificate
+ certificate if certificate_user_provided?
+ end
+
+ def user_provided_certificate=(certificate)
+ self.certificate = certificate
+ self.certificate_source = 'user_provided' if certificate_changed?
+ end
+
+ def gitlab_provided_certificate=(certificate)
+ self.certificate = certificate
+ self.certificate_source = 'gitlab_provided' if certificate_changed?
+ end
+
+ def gitlab_provided_key=(key)
+ self.key = key
+ self.certificate_source = 'gitlab_provided' if key_changed?
+ end
+
private
def set_verification_code
diff --git a/app/services/boards/issues/move_service.rb b/app/services/boards/issues/move_service.rb
index 834baeb9643..e27d34dbcab 100644
--- a/app/services/boards/issues/move_service.rb
+++ b/app/services/boards/issues/move_service.rb
@@ -79,9 +79,11 @@ module Boards
# rubocop: enable CodeReuse/ActiveRecord
def move_between_ids
- return unless params[:move_after_id] || params[:move_before_id]
+ ids = [params[:move_after_id], params[:move_before_id]]
+ .map(&:to_i)
+ .map { |m| m.positive? ? m : nil }
- [params[:move_after_id], params[:move_before_id]]
+ ids.any? ? ids : nil
end
end
end
diff --git a/app/services/issues/reorder_service.rb b/app/services/issues/reorder_service.rb
new file mode 100644
index 00000000000..02c18d31b5e
--- /dev/null
+++ b/app/services/issues/reorder_service.rb
@@ -0,0 +1,48 @@
+# frozen_string_literal: true
+
+module Issues
+ class ReorderService < Issues::BaseService
+ def execute(issue)
+ return false unless can?(current_user, :update_issue, issue)
+ return false if group && !can?(current_user, :read_group, group)
+
+ attrs = issue_params(group)
+ return false if attrs.empty?
+
+ update(issue, attrs)
+ end
+
+ private
+
+ def group
+ return unless params[:group_full_path]
+
+ @group ||= Group.find_by_full_path(params[:group_full_path])
+ end
+
+ def update(issue, attrs)
+ ::Issues::UpdateService.new(project, current_user, attrs).execute(issue)
+ rescue ActiveRecord::RecordNotFound
+ false
+ end
+
+ def issue_params(group)
+ attrs = {}
+
+ if move_between_ids
+ attrs[:move_between_ids] = move_between_ids
+ attrs[:board_group_id] = group&.id
+ end
+
+ attrs
+ end
+
+ def move_between_ids
+ ids = [params[:move_after_id], params[:move_before_id]]
+ .map(&:to_i)
+ .map { |m| m.positive? ? m : nil }
+
+ ids.any? ? ids : nil
+ end
+ end
+end
diff --git a/app/services/issues/update_service.rb b/app/services/issues/update_service.rb
index cb2337d29d4..6b9f23f24cd 100644
--- a/app/services/issues/update_service.rb
+++ b/app/services/issues/update_service.rb
@@ -76,6 +76,7 @@ module Issues
issue_before = get_issue_if_allowed(before_id, board_group_id)
issue_after = get_issue_if_allowed(after_id, board_group_id)
+ raise ActiveRecord::RecordNotFound unless issue_before || issue_after
issue.move_between(issue_before, issue_after)
end
diff --git a/app/services/pages_domains/obtain_lets_encrypt_certificate_service.rb b/app/services/pages_domains/obtain_lets_encrypt_certificate_service.rb
index 2dfe1a3d8ca..3413a9e4612 100644
--- a/app/services/pages_domains/obtain_lets_encrypt_certificate_service.rb
+++ b/app/services/pages_domains/obtain_lets_encrypt_certificate_service.rb
@@ -35,7 +35,7 @@ module PagesDomains
def save_certificate(private_key, api_order)
certificate = api_order.certificate
- pages_domain.update!(key: private_key, certificate: certificate)
+ pages_domain.update!(gitlab_provided_key: private_key, gitlab_provided_certificate: certificate)
end
end
end
diff --git a/app/views/layouts/nav/sidebar/_group.html.haml b/app/views/layouts/nav/sidebar/_group.html.haml
index 0fc5ebbea7e..4b5ccc33716 100644
--- a/app/views/layouts/nav/sidebar/_group.html.haml
+++ b/app/views/layouts/nav/sidebar/_group.html.haml
@@ -45,7 +45,6 @@
= _('Contribution Analytics')
= render_if_exists 'layouts/nav/group_insights_link'
- = render_if_exists 'groups/sidebar/dependency_proxy' # EE-specific
= render_if_exists "layouts/nav/ee/epic_link", group: @group
@@ -119,6 +118,8 @@
%strong.fly-out-top-item-name
= _('Kubernetes')
+ = render_if_exists 'groups/sidebar/packages' # EE-specific
+
- if group_sidebar_link?(:group_members)
= nav_link(path: 'group_members#index') do
= link_to group_group_members_path(@group) do
diff --git a/app/views/projects/pages_domains/_form.html.haml b/app/views/projects/pages_domains/_form.html.haml
index 33f2166480b..e7edb93f05b 100644
--- a/app/views/projects/pages_domains/_form.html.haml
+++ b/app/views/projects/pages_domains/_form.html.haml
@@ -11,7 +11,7 @@
- if Gitlab.config.pages.external_https
- - auto_ssl_available = Feature.enabled?(:pages_auto_ssl)
+ - auto_ssl_available = ::Gitlab::LetsEncrypt::Client.new.enabled?
- auto_ssl_enabled = @domain.auto_ssl_enabled?
- auto_ssl_available_and_enabled = auto_ssl_available && auto_ssl_enabled
@@ -38,40 +38,24 @@
- docs_link_end = "</a>".html_safe
= _("Let's Encrypt is a free, automated, and open certificate authority (CA) that gives digital certificates in order to enable HTTPS (SSL/TLS) for websites. Learn more about Let's Encrypt configuration by following the %{docs_link_start}documentation on GitLab Pages%{docs_link_end}.").html_safe % { docs_link_url: docs_link_url, docs_link_start: docs_link_start, docs_link_end: docs_link_end }
- .js-shown-if-auto-ssl{ class: ("d-none" unless auto_ssl_available_and_enabled) }
- .form-group.row
- .col-sm-2.col-form-label
- = f.label :certificate, _("Certificate (PEM)")
- .col-sm-10
- - if auto_ssl_available_and_enabled && !@domain.certificate.empty?
- = f.text_area :certificate,
- rows: 5,
- class: "form-control",
- disabled: true
- %span.help-inline.text-muted= _("This certificate is automatically managed by Let's Encrypt")
- - else
- %p.text-secondary.form-control-plaintext= _("The certificate will be shown here once it has been obtained from Let's Encrypt. This process may take up to an hour to complete.")
-
.js-shown-unless-auto-ssl{ class: ("d-none" if auto_ssl_available_and_enabled) }
.form-group.row
.col-sm-2.col-form-label
- = f.label :certificate, _("Certificate (PEM)")
+ = f.label :user_provided_certificate, _("Certificate (PEM)")
.col-sm-10
- = f.text_area :certificate,
+ = f.text_area :user_provided_certificate,
rows: 5,
class: "form-control js-enabled-unless-auto-ssl",
- value: (@domain.certificate unless auto_ssl_available_and_enabled),
disabled: auto_ssl_available_and_enabled
%span.help-inline.text-muted= _("Upload a certificate for your domain with all intermediates")
.form-group.row
.col-sm-2.col-form-label
- = f.label :key, _("Key (PEM)")
+ = f.label :user_provided_key, _("Key (PEM)")
.col-sm-10
- = f.text_area :key,
+ = f.text_area :user_provided_key,
rows: 5,
class: "form-control js-enabled-unless-auto-ssl",
- value: (@domain.key unless auto_ssl_available_and_enabled),
disabled: auto_ssl_available_and_enabled
%span.help-inline.text-muted= _("Upload a private key for your certificate")
diff --git a/changelogs/unreleased/38105-pre-release-tag.yml b/changelogs/unreleased/38105-pre-release-tag.yml
new file mode 100644
index 00000000000..d4c5dcacd19
--- /dev/null
+++ b/changelogs/unreleased/38105-pre-release-tag.yml
@@ -0,0 +1,5 @@
+---
+title: Renders a pre-release tag for releases
+merge_request: 29797
+author:
+type: changed
diff --git a/changelogs/unreleased/59028-fix-extra-plus-in-diffs.yml b/changelogs/unreleased/59028-fix-extra-plus-in-diffs.yml
new file mode 100644
index 00000000000..0786f4dbc10
--- /dev/null
+++ b/changelogs/unreleased/59028-fix-extra-plus-in-diffs.yml
@@ -0,0 +1,5 @@
+---
+title: Remove duplicate trailing +/- char in merge request discussions
+merge_request: 29518
+author:
+type: fixed
diff --git a/changelogs/unreleased/db-update-geo-nodes-primary.yml b/changelogs/unreleased/db-update-geo-nodes-primary.yml
new file mode 100644
index 00000000000..7c5203353ac
--- /dev/null
+++ b/changelogs/unreleased/db-update-geo-nodes-primary.yml
@@ -0,0 +1,5 @@
+---
+title: Disallow `NULL` values for `geo_nodes.primary` column
+merge_request: 29818
+author: Arun Kumar Mohan
+type: other
diff --git a/changelogs/unreleased/paginate-license-management.yml b/changelogs/unreleased/paginate-license-management.yml
new file mode 100644
index 00000000000..c5134978612
--- /dev/null
+++ b/changelogs/unreleased/paginate-license-management.yml
@@ -0,0 +1,5 @@
+---
+title: Backport and Docs for Paginate license management and add license search
+merge_request: 27602
+author:
+type: changed
diff --git a/changelogs/unreleased/sanitize_rake_ldap_check_output.yml b/changelogs/unreleased/sanitize_rake_ldap_check_output.yml
new file mode 100644
index 00000000000..92824d1dd48
--- /dev/null
+++ b/changelogs/unreleased/sanitize_rake_ldap_check_output.yml
@@ -0,0 +1,5 @@
+---
+title: Sanitize LDAP output in Rake tasks
+merge_request: 28427
+author:
+type: fixed
diff --git a/config/routes/project.rb b/config/routes/project.rb
index a1e769f6ca3..0e8e089c78a 100644
--- a/config/routes/project.rb
+++ b/config/routes/project.rb
@@ -406,6 +406,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
post :toggle_subscription
post :mark_as_spam
post :move
+ put :reorder
get :related_branches
get :can_create_branch
get :realtime_changes
diff --git a/db/migrate/20190607085356_add_source_to_pages_domains.rb b/db/migrate/20190607085356_add_source_to_pages_domains.rb
new file mode 100644
index 00000000000..0a845d7d11f
--- /dev/null
+++ b/db/migrate/20190607085356_add_source_to_pages_domains.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+# See http://doc.gitlab.com/ce/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class AddSourceToPagesDomains < ActiveRecord::Migration[5.1]
+ include Gitlab::Database::MigrationHelpers
+
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_column_with_default(:pages_domains, :certificate_source, :smallint, default: 0)
+ end
+
+ def down
+ remove_column(:pages_domains, :certificate_source)
+ end
+end
diff --git a/db/post_migrate/20190618171120_update_geo_nodes_primary.rb b/db/post_migrate/20190618171120_update_geo_nodes_primary.rb
new file mode 100644
index 00000000000..dc9cfbda177
--- /dev/null
+++ b/db/post_migrate/20190618171120_update_geo_nodes_primary.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+# See http://doc.gitlab.com/ce/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class UpdateGeoNodesPrimary < ActiveRecord::Migration[5.1]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ change_column_default(:geo_nodes, :primary, false)
+ change_column_null(:geo_nodes, :primary, false, false)
+ end
+
+ def down
+ change_column_default(:geo_nodes, :primary, nil)
+ change_column_null(:geo_nodes, :primary, true)
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 4e333633a8b..c1c67e012e9 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -1391,7 +1391,7 @@ ActiveRecord::Schema.define(version: 20190619175843) do
end
create_table "geo_nodes", id: :serial, force: :cascade do |t|
- t.boolean "primary"
+ t.boolean "primary", default: false, null: false
t.integer "oauth_application_id"
t.boolean "enabled", default: true, null: false
t.string "access_key"
@@ -2333,6 +2333,7 @@ ActiveRecord::Schema.define(version: 20190619175843) do
t.boolean "auto_ssl_enabled", default: false, null: false
t.datetime_with_timezone "certificate_valid_not_before"
t.datetime_with_timezone "certificate_valid_not_after"
+ t.integer "certificate_source", limit: 2, default: 0, null: false
t.index ["domain"], name: "index_pages_domains_on_domain", unique: true, using: :btree
t.index ["project_id", "enabled_until"], name: "index_pages_domains_on_project_id_and_enabled_until", using: :btree
t.index ["project_id"], name: "index_pages_domains_on_project_id", using: :btree
diff --git a/doc/administration/geo/replication/troubleshooting.md b/doc/administration/geo/replication/troubleshooting.md
index c5bdd36ba70..846afd8f5f4 100644
--- a/doc/administration/geo/replication/troubleshooting.md
+++ b/doc/administration/geo/replication/troubleshooting.md
@@ -1,15 +1,23 @@
# Geo Troubleshooting **[PREMIUM ONLY]**
-NOTE: **Note:**
-This list is an attempt to document all the moving parts that can go wrong.
-We are working into getting all this steps verified automatically in a
-rake task in the future.
-
Setting up Geo requires careful attention to details and sometimes it's easy to
-miss a step. Here is a list of questions you should ask to try to detect
-what you need to fix (all commands and path locations are for Omnibus installs):
+miss a step.
+
+Here is a list of steps you should take to attempt to fix problem:
+
+- Perform [basic troubleshooting](#basic-troubleshooting).
+- Fix any [replication errors](#fixing-replication-errors).
+- Fix any [Foreign Data Wrapper](#fixing-foreign-data-wrapper-errors) errors.
+- Fix any [common](#fixing-common-errors) errors.
-## First check the health of the **secondary** node
+## Basic troubleshooting
+
+Before attempting more advanced troubleshooting:
+
+- Check [the health of the **secondary** node](#check-the-health-of-the-secondary-node).
+- Check [if PostgreSQL replication is working](#check-if-postgresql-replication-is-working).
+
+### Check the health of the **secondary** node
Visit the **primary** node's **Admin Area > Geo** (`/admin/geo/nodes`) in
your browser. We perform the following health checks on each **secondary** node
@@ -23,10 +31,12 @@ to help identify if something is wrong:
![Geo health check](img/geo_node_healthcheck.png)
-For information on how to resolve common errors reported from the UI, see [common errors](#common-errors).
+For information on how to resolve common errors reported from the UI, see
+[Fixing Common Errors](#fixing-common-errors).
If the UI is not working, or you are unable to log in, you can run the Geo
health check manually to get this information as well as a few more details.
+
This rake task can be run on an app node in the **primary** or **secondary**
Geo nodes:
@@ -36,7 +46,7 @@ sudo gitlab-rake gitlab:geo:check
Example output:
-```
+```text
Checking Geo ...
GitLab Geo is available ... yes
@@ -68,7 +78,7 @@ sudo gitlab-rake geo:status
Example output:
-```
+```text
http://secondary.example.com/
-----------------------------------------------------
GitLab Version: 11.10.4-ee
@@ -89,16 +99,21 @@ http://secondary.example.com/
Last status report was: 2 minutes ago
```
-## Is Postgres replication working?
+### Check if PostgreSQL replication is working
+
+To check if PostgreSQL replication is working, check if:
+
+- [Nodes are pointing to the correct database instance](#are-nodes-pointing-to-the-correct-database-instance).
+- [Geo can detect the current node correctly](#can-geo-detect-the-current-node-correctly).
-### Are my nodes pointing to the correct database instance?
+#### Are nodes pointing to the correct database instance?
You should make sure your **primary** Geo node points to the instance with
writing permissions.
Any **secondary** nodes should point only to read-only instances.
-### Can Geo detect my current node correctly?
+#### Can Geo detect the current node correctly?
Geo uses the defined node from the **Admin Area > Geo** screen, and tries to match
it with the value defined in the `/etc/gitlab/gitlab.rb` configuration file.
@@ -112,29 +127,38 @@ sudo gitlab-rails runner "puts Gitlab::Geo.current_node.inspect"
and expect something like:
-```
+```ruby
#<GeoNode id: 2, schema: "https", host: "gitlab.example.com", port: 443, relative_url_root: "", primary: false, ...>
```
By running the command above, `primary` should be `true` when executed in
the **primary** node, and `false` on any **secondary** node.
-## How do I fix the message, "ERROR: replication slots can only be used if max_replication_slots > 0"?
+## Fixing replication errors
+
+The following sections outline troubleshooting steps for fixing replication
+errors.
+
+### Message: "ERROR: replication slots can only be used if max_replication_slots > 0"?
This means that the `max_replication_slots` PostgreSQL variable needs to
be set on the **primary** database. In GitLab 9.4, we have made this setting
default to 1. You may need to increase this value if you have more
-**secondary** nodes. Be sure to restart PostgreSQL for this to take
+**secondary** nodes.
+
+Be sure to restart PostgreSQL for this to take
effect. See the [PostgreSQL replication
setup][database-pg-replication] guide for more details.
-## How do I fix the message, "FATAL: could not start WAL streaming: ERROR: replication slot "geo_secondary_my_domain_com" does not exist"?
+### Message: "FATAL: could not start WAL streaming: ERROR: replication slot "geo_secondary_my_domain_com" does not exist"?
This occurs when PostgreSQL does not have a replication slot for the
-**secondary** node by that name. You may want to rerun the [replication
+**secondary** node by that name.
+
+You may want to rerun the [replication
process](database.md) on the **secondary** node .
-## How do I fix the message, "Command exceeded allowed execution time" when setting up replication?
+### Message: "Command exceeded allowed execution time" when setting up replication?
This may happen while [initiating the replication process][database-start-replication] on the **secondary** node,
and indicates that your initial dataset is too large to be replicated in the default timeout (30 minutes).
@@ -153,7 +177,7 @@ sudo gitlab-ctl \
This will give the initial replication up to six hours to complete, rather than
the default thirty minutes. Adjust as required for your installation.
-## How do I fix the message, "PANIC: could not write to file 'pg_xlog/xlogtemp.123': No space left on device"
+### Message: "PANIC: could not write to file 'pg_xlog/xlogtemp.123': No space left on device"
Determine if you have any unused replication slots in the **primary** database. This can cause large amounts of
log data to build up in `pg_xlog`. Removing the unused slots can reduce the amount of space used in the `pg_xlog`.
@@ -184,11 +208,12 @@ Slots where `active` is `f` are not active.
SELECT pg_drop_replication_slot('<name_of_extra_slot>');
```
-## Very large repositories never successfully synchronize on the **secondary** node
+### Very large repositories never successfully synchronize on the **secondary** node
GitLab places a timeout on all repository clones, including project imports
and Geo synchronization operations. If a fresh `git clone` of a repository
on the primary takes more than a few minutes, you may be affected by this.
+
To increase the timeout, add the following line to `/etc/gitlab/gitlab.rb`
on the **secondary** node:
@@ -205,7 +230,7 @@ sudo gitlab-ctl reconfigure
This will increase the timeout to three hours (10800 seconds). Choose a time
long enough to accommodate a full clone of your largest repositories.
-## How to reset Geo **secondary** node replication
+### Reseting Geo **secondary** node replication
If you get a **secondary** node in a broken state and want to reset the replication state,
to start again from scratch, there are a few steps that can help you:
@@ -289,12 +314,16 @@ to start again from scratch, there are a few steps that can help you:
gitlab-ctl start
```
-## How do I fix a "Foreign Data Wrapper (FDW) is not configured" error?
+## Fixing Foreign Data Wrapper errors
+
+This section documents ways to fix potential Foreign Data Wrapper errors.
+
+### "Foreign Data Wrapper (FDW) is not configured" error
When setting up Geo, you might see this warning in the `gitlab-rake
gitlab:geo:check` output:
-```
+```text
GitLab Geo tracking database Foreign Data Wrapper schema is up-to-date? ... foreign data wrapper is not configured
```
@@ -307,7 +336,7 @@ There are a few key points to remember:
By default, the Geo secondary and tracking database are running on the
same host on different ports. That is, 5432 and 5431 respectively.
-### Checking configuration
+#### Checking configuration
NOTE: **Note:**
The following steps are for Omnibus installs only. Using Geo with source-based installs was **deprecated** in GitLab 11.5.
@@ -419,7 +448,7 @@ should see something like this:
- `geo_postgresql['fdw_external_user']`
- `geo_postgresql['fdw_external_password']`
-### Manual reload of FDW schema
+#### Manual reload of FDW schema
If you're still unable to get FDW working, you may want to try a manual
reload of the FDW schema. To manually reload the FDW schema:
@@ -459,9 +488,25 @@ reload of the FDW schema. To manually reload the FDW schema:
[database-start-replication]: database.md#step-3-initiate-the-replication-process
[database-pg-replication]: database.md#postgresql-replication
-## Common errors
+### "Geo database has an outdated FDW remote schema" error
+
+GitLab can error with a `Geo database has an outdated FDW remote schema` message.
+
+For example:
-This section documents common errors reported in the admin UI and how to fix them.
+```text
+Geo database has an outdated FDW remote schema. It contains 229 of 236 expected tables. Please refer to Geo Troubleshooting.
+```
+
+To resolve this, run the following command:
+
+```sh
+sudo gitlab-rake geo:db:refresh_foreign_tables
+```
+
+## Fixing common errors
+
+This section documents common errors reported in the Admin UI and how to fix them.
### Geo database configuration file is missing
@@ -470,7 +515,6 @@ GitLab cannot find or doesn't have permission to access the `database_geo.yml` c
In an Omnibus GitLab installation, the file should be in `/var/opt/gitlab/gitlab-rails/etc`.
If it doesn't exist or inadvertent changes have been made to it, run `sudo gitlab-ctl reconfigure` to restore it to its correct state.
-
If this path is mounted on a remote volume, please check your volume configuration and that it has correct permissions.
### Geo node has a database that is writable which is an indication it is not configured for replication with the primary node.
@@ -503,7 +547,7 @@ Make sure you follow the [Geo database replication](database.md) instructions fo
If you are using GitLab Omnibus installation, something might have failed during upgrade. You can:
-- Run `sudo gitlab-ctl reconfigure`.
+- Run `sudo gitlab-ctl reconfigure`.
- Manually trigger the database migration by running: `sudo gitlab-rake geo:db:migrate` as root on the **secondary** node.
### Geo database is not configured to use Foreign Data Wrapper
@@ -511,4 +555,4 @@ If you are using GitLab Omnibus installation, something might have failed during
This error means the Geo Tracking Database doesn't have the FDW server and credentials
configured.
-See [How do I fix a "Foreign Data Wrapper (FDW) is not configured" error?](#how-do-i-fix-a-foreign-data-wrapper-fdw-is-not-configured-error).
+See ["Foreign Data Wrapper (FDW) is not configured" error?](#foreign-data-wrapper-fdw-is-not-configured-error).
diff --git a/doc/user/application_security/license_management/img/license_management_add_license.png b/doc/user/application_security/license_management/img/license_management_add_license.png
new file mode 100644
index 00000000000..1e1a698515b
--- /dev/null
+++ b/doc/user/application_security/license_management/img/license_management_add_license.png
Binary files differ
diff --git a/doc/user/application_security/license_management/img/license_management_search.png b/doc/user/application_security/license_management/img/license_management_search.png
new file mode 100644
index 00000000000..7b6006cef9d
--- /dev/null
+++ b/doc/user/application_security/license_management/img/license_management_search.png
Binary files differ
diff --git a/doc/user/application_security/license_management/img/license_management_settings.png b/doc/user/application_security/license_management/img/license_management_settings.png
index b5490e59074..1a2bfa78a03 100644
--- a/doc/user/application_security/license_management/img/license_management_settings.png
+++ b/doc/user/application_security/license_management/img/license_management_settings.png
Binary files differ
diff --git a/doc/user/application_security/license_management/index.md b/doc/user/application_security/license_management/index.md
index 7a583016586..957c4ede981 100644
--- a/doc/user/application_security/license_management/index.md
+++ b/doc/user/application_security/license_management/index.md
@@ -262,6 +262,8 @@ To approve or blacklist a license:
navigate to the project's **Settings > CI/CD** and expand the
**License Management** section.
1. Click the **Add a license** button.
+
+ ![License Management Add License](img/license_management_add_license.png)
1. In the **License name** dropdown, either:
- Select one of the available licenses. You can search for licenses in the field
at the top of the list.
@@ -270,8 +272,22 @@ To approve or blacklist a license:
1. Select the **Approve** or **Blacklist** radio button to approve or blacklist respectively
the selected license.
+
+
+To modify an existing license:
+
+1. In the **License Management** list, click the **Approved/Declined** dropdown to change it to the desired status.
+
![License Management Settings](img/license_management_settings.png)
+Searching for Licenses:
+
+1. Use the **Search** box to search for a specific license.
+
+ ![License Management Search](img/license_management_search.png)
+
+
+
## License Management report under pipelines
> [Introduced](https://gitlab.com/gitlab-org/gitlab-ee/issues/5491)
diff --git a/doc/user/project/description_templates.md b/doc/user/project/description_templates.md
index a8c5d4d95b5..ca59fe3cc7d 100644
--- a/doc/user/project/description_templates.md
+++ b/doc/user/project/description_templates.md
@@ -58,6 +58,7 @@ changes you made after picking the template and return it to its initial status.
## Setting a default template for issues and merge requests **[STARTER]**
> **Notes:**
+>
> - This feature was introduced before [description templates](#overview) and is
> available in [GitLab Starter][products]. It can be enabled
> in the project's settings.
diff --git a/lib/api/pages_domains.rb b/lib/api/pages_domains.rb
index 78442f465bd..4227a106a95 100644
--- a/lib/api/pages_domains.rb
+++ b/lib/api/pages_domains.rb
@@ -90,14 +90,15 @@ module API
end
params do
requires :domain, type: String, desc: 'The domain'
- optional :certificate, allow_blank: false, types: [File, String], desc: 'The certificate'
- optional :key, allow_blank: false, types: [File, String], desc: 'The key'
- all_or_none_of :certificate, :key
+ optional :certificate, allow_blank: false, types: [File, String], desc: 'The certificate', as: :user_provided_certificate
+ optional :key, allow_blank: false, types: [File, String], desc: 'The key', as: :user_provided_key
+ all_or_none_of :user_provided_certificate, :user_provided_key
end
post ":id/pages/domains" do
authorize! :update_pages, user_project
pages_domain_params = declared(params, include_parent_namespaces: false)
+
pages_domain = user_project.pages_domains.create(pages_domain_params)
if pages_domain.persisted?
@@ -110,8 +111,8 @@ module API
desc 'Updates a pages domain'
params do
requires :domain, type: String, desc: 'The domain'
- optional :certificate, allow_blank: false, types: [File, String], desc: 'The certificate'
- optional :key, allow_blank: false, types: [File, String], desc: 'The key'
+ optional :certificate, allow_blank: false, types: [File, String], desc: 'The certificate', as: :user_provided_certificate
+ optional :key, allow_blank: false, types: [File, String], desc: 'The key', as: :user_provided_key
end
put ":id/pages/domains/:domain", requirements: PAGES_DOMAINS_ENDPOINT_REQUIREMENTS do
authorize! :update_pages, user_project
@@ -119,8 +120,8 @@ module API
pages_domain_params = declared(params, include_parent_namespaces: false)
# Remove empty private key if certificate is not empty.
- if pages_domain_params[:certificate] && !pages_domain_params[:key]
- pages_domain_params.delete(:key)
+ if pages_domain_params[:user_provided_certificate] && !pages_domain_params[:user_provided_key]
+ pages_domain_params.delete(:user_provided_key)
end
if pages_domain.update(pages_domain_params)
diff --git a/lib/gitlab/ci/ansi2html.rb b/lib/gitlab/ci/ansi2html.rb
index fc3223e7442..55411b5a8c4 100644
--- a/lib/gitlab/ci/ansi2html.rb
+++ b/lib/gitlab/ci/ansi2html.rb
@@ -200,7 +200,9 @@ module Gitlab
css_classes = %w[section line] + sections.map { |section| "s_#{section}" }
end
- write_in_tag %{<br/>}
+ ensure_open_new_tag
+ write_raw %{<br/>}
+ close_open_tags
write_raw %{<span class="#{css_classes.join(' ')}"></span>} if css_classes.any?
@lineno_in_section += 1
open_new_tag
diff --git a/lib/system_check/ldap_check.rb b/lib/system_check/ldap_check.rb
index 619fb3cccb8..938026424ed 100644
--- a/lib/system_check/ldap_check.rb
+++ b/lib/system_check/ldap_check.rb
@@ -33,8 +33,13 @@ module SystemCheck
$stdout.puts "LDAP users with access to your GitLab server (only showing the first #{limit} results)"
users = adapter.users(adapter.config.uid, '*', limit)
- users.each do |user|
- $stdout.puts "\tDN: #{user.dn}\t #{adapter.config.uid}: #{user.uid}"
+
+ if should_sanitize?
+ $stdout.puts "\tUser output sanitized. Found #{users.length} users of #{limit} limit."
+ else
+ users.each do |user|
+ $stdout.puts "\tDN: #{user.dn}\t #{adapter.config.uid}: #{user.uid}"
+ end
end
end
rescue Net::LDAP::ConnectionRefusedError, Errno::ECONNREFUSED => e
diff --git a/locale/gitlab.pot b/locale/gitlab.pot
index 8f010b2184c..eb76e62c9f5 100644
--- a/locale/gitlab.pot
+++ b/locale/gitlab.pot
@@ -7327,6 +7327,9 @@ msgstr ""
msgid "Please wait while we import the repository for you. Refresh at will."
msgstr ""
+msgid "Pre-release"
+msgstr ""
+
msgid "Preferences"
msgstr ""
@@ -9942,9 +9945,6 @@ msgstr ""
msgid "The X509 Certificate to use when mutual TLS is required to communicate with the external authorization service. If left blank, the server certificate is still validated when accessing over HTTPS."
msgstr ""
-msgid "The certificate will be shown here once it has been obtained from Let's Encrypt. This process may take up to an hour to complete."
-msgstr ""
-
msgid "The character highlighter helps you keep the subject line to %{titleLength} characters and wrap the body at %{bodyLength} so they are readable in git."
msgstr ""
@@ -10278,9 +10278,6 @@ msgstr ""
msgid "This branch has changed since you started editing. Would you like to create a new branch?"
msgstr ""
-msgid "This certificate is automatically managed by Let's Encrypt"
-msgstr ""
-
msgid "This commit is part of merge request %{link_to_merge_request}. Comments created here will be created in the context of that merge request."
msgstr ""
diff --git a/spec/controllers/projects/issues_controller_spec.rb b/spec/controllers/projects/issues_controller_spec.rb
index 32607fc5f56..f82e3c8c7dc 100644
--- a/spec/controllers/projects/issues_controller_spec.rb
+++ b/spec/controllers/projects/issues_controller_spec.rb
@@ -320,6 +320,90 @@ describe Projects::IssuesController do
end
end
+ describe 'PUT #reorder' do
+ let(:group) { create(:group, projects: [project]) }
+ let!(:issue1) { create(:issue, project: project, relative_position: 10) }
+ let!(:issue2) { create(:issue, project: project, relative_position: 20) }
+ let!(:issue3) { create(:issue, project: project, relative_position: 30) }
+
+ before do
+ sign_in(user)
+ end
+
+ context 'when user has access' do
+ before do
+ project.add_developer(user)
+ end
+
+ context 'with valid params' do
+ it 'reorders issues and returns a successful 200 response' do
+ reorder_issue(issue1,
+ move_after_id: issue2.id,
+ move_before_id: issue3.id,
+ group_full_path: group.full_path)
+
+ [issue1, issue2, issue3].map(&:reload)
+
+ expect(response).to have_gitlab_http_status(200)
+ expect(issue1.relative_position)
+ .to be_between(issue2.relative_position, issue3.relative_position)
+ end
+ end
+
+ context 'with invalid params' do
+ it 'returns a unprocessable entity 422 response for invalid move ids' do
+ reorder_issue(issue1, move_after_id: 99, move_before_id: 999)
+
+ expect(response).to have_gitlab_http_status(422)
+ end
+
+ it 'returns a not found 404 response for invalid issue id' do
+ reorder_issue(object_double(issue1, iid: 999),
+ move_after_id: issue2.id,
+ move_before_id: issue3.id)
+
+ expect(response).to have_gitlab_http_status(404)
+ end
+
+ it 'returns a unprocessable entity 422 response for issues not in group' do
+ another_group = create(:group)
+
+ reorder_issue(issue1,
+ move_after_id: issue2.id,
+ move_before_id: issue3.id,
+ group_full_path: another_group.full_path)
+
+ expect(response).to have_gitlab_http_status(422)
+ end
+ end
+ end
+
+ context 'with unauthorized user' do
+ before do
+ project.add_guest(user)
+ end
+
+ it 'responds with 404' do
+ reorder_issue(issue1, move_after_id: issue2.id, move_before_id: issue3.id)
+
+ expect(response).to have_gitlab_http_status(:not_found)
+ end
+ end
+
+ def reorder_issue(issue, move_after_id: nil, move_before_id: nil, group_full_path: nil)
+ put :reorder,
+ params: {
+ namespace_id: project.namespace.to_param,
+ project_id: project,
+ id: issue.iid,
+ move_after_id: move_after_id,
+ move_before_id: move_before_id,
+ group_full_path: group_full_path
+ },
+ format: :json
+ end
+ end
+
describe 'PUT #update' do
subject do
put :update,
diff --git a/spec/controllers/projects/pages_domains_controller_spec.rb b/spec/controllers/projects/pages_domains_controller_spec.rb
index ff3afd51cd8..032f4f1418f 100644
--- a/spec/controllers/projects/pages_domains_controller_spec.rb
+++ b/spec/controllers/projects/pages_domains_controller_spec.rb
@@ -15,7 +15,10 @@ describe Projects::PagesDomainsController do
end
let(:pages_domain_params) do
- build(:pages_domain, domain: 'my.otherdomain.com').slice(:key, :certificate, :domain)
+ attributes_for(:pages_domain, domain: 'my.otherdomain.com').slice(:key, :certificate, :domain).tap do |params|
+ params[:user_provided_key] = params.delete(:key)
+ params[:user_provided_certificate] = params.delete(:certificate)
+ end
end
before do
@@ -84,48 +87,59 @@ describe Projects::PagesDomainsController do
controller.instance_variable_set(:@domain, pages_domain)
end
- let(:pages_domain_params) do
- attributes_for(:pages_domain).slice(:key, :certificate)
- end
-
let(:params) do
request_params.merge(id: pages_domain.domain, pages_domain: pages_domain_params)
end
- it 'updates the domain' do
- expect(pages_domain)
- .to receive(:update)
- .with(ActionController::Parameters.new(pages_domain_params).permit!)
- .and_return(true)
+ context 'with valid params' do
+ let(:pages_domain_params) do
+ attributes_for(:pages_domain, :with_trusted_chain).slice(:key, :certificate).tap do |params|
+ params[:user_provided_key] = params.delete(:key)
+ params[:user_provided_certificate] = params.delete(:certificate)
+ end
+ end
+
+ it 'updates the domain' do
+ expect do
+ patch(:update, params: params)
+ end.to change { pages_domain.reload.certificate }.to(pages_domain_params[:user_provided_certificate])
+ end
+
+ it 'redirects to the project page' do
+ patch(:update, params: params)
- patch(:update, params: params)
+ expect(flash[:notice]).to eq 'Domain was updated'
+ expect(response).to redirect_to(project_pages_path(project))
+ end
end
- it 'redirects to the project page' do
- patch(:update, params: params)
+ context 'with key parameter' do
+ before do
+ pages_domain.update!(key: nil, certificate: nil, certificate_source: 'gitlab_provided')
+ end
- expect(flash[:notice]).to eq 'Domain was updated'
- expect(response).to redirect_to(project_pages_path(project))
+ it 'marks certificate as provided by user' do
+ expect do
+ patch(:update, params: params)
+ end.to change { pages_domain.reload.certificate_source }.from('gitlab_provided').to('user_provided')
+ end
end
context 'the domain is invalid' do
- it 'renders the edit action' do
- allow(pages_domain).to receive(:update).and_return(false)
+ let(:pages_domain_params) { { user_provided_certificate: 'blabla' } }
+ it 'renders the edit action' do
patch(:update, params: params)
expect(response).to render_template('edit')
end
end
- context 'the parameters include the domain' do
- it 'renders 400 Bad Request' do
- expect(pages_domain)
- .to receive(:update)
- .with(hash_not_including(:domain))
- .and_return(true)
-
- patch(:update, params: params.deep_merge(pages_domain: { domain: 'abc' }))
+ context 'when parameters include the domain' do
+ it 'does not update domain' do
+ expect do
+ patch(:update, params: params.deep_merge(pages_domain: { domain: 'abc' }))
+ end.not_to change { pages_domain.reload.domain }
end
end
end
diff --git a/spec/factories/pages_domains.rb b/spec/factories/pages_domains.rb
index db8384877b0..8da19a37a6a 100644
--- a/spec/factories/pages_domains.rb
+++ b/spec/factories/pages_domains.rb
@@ -180,5 +180,9 @@ Iy6oRpHaCF/2obZdIdgf9rlyz0fkqyHJc9GkioSoOhJZxEV2SgAkap8yS0sX2tJ9
ZDXgrA==
-----END CERTIFICATE-----'
end
+
+ trait :letsencrypt do
+ certificate_source { :gitlab_provided }
+ end
end
end
diff --git a/spec/features/projects/pages_lets_encrypt_spec.rb b/spec/features/projects/pages_lets_encrypt_spec.rb
index baa217cbe58..a5f8702302c 100644
--- a/spec/features/projects/pages_lets_encrypt_spec.rb
+++ b/spec/features/projects/pages_lets_encrypt_spec.rb
@@ -2,124 +2,119 @@
require 'spec_helper'
describe "Pages with Let's Encrypt", :https_pages_enabled do
+ include LetsEncryptHelpers
+
let(:project) { create(:project) }
let(:user) { create(:user) }
let(:role) { :maintainer }
- let(:certificate_pem) do
- <<~PEM
- -----BEGIN CERTIFICATE-----
- MIICGzCCAYSgAwIBAgIBATANBgkqhkiG9w0BAQUFADAbMRkwFwYDVQQDExB0ZXN0
- LWNlcnRpZmljYXRlMB4XDTE2MDIxMjE0MzIwMFoXDTIwMDQxMjE0MzIwMFowGzEZ
- MBcGA1UEAxMQdGVzdC1jZXJ0aWZpY2F0ZTCBnzANBgkqhkiG9w0BAQEFAAOBjQAw
- gYkCgYEApL4J9L0ZxFJ1hI1LPIflAlAGvm6ZEvoT4qKU5Xf2JgU7/2geNR1qlNFa
- SvCc08Knupp5yTgmvyK/Xi09U0N82vvp4Zvr/diSc4A/RA6Mta6egLySNT438kdT
- nY2tR5feoTLwQpX0t4IMlwGQGT5h6Of2fKmDxzuwuyffcIHqLdsCAwEAAaNvMG0w
- DAYDVR0TAQH/BAIwADAdBgNVHQ4EFgQUxl9WSxBprB0z0ibJs3rXEk0+95AwCwYD
- VR0PBAQDAgXgMBEGCWCGSAGG+EIBAQQEAwIGQDAeBglghkgBhvhCAQ0EERYPeGNh
- IGNlcnRpZmljYXRlMA0GCSqGSIb3DQEBBQUAA4GBAGC4T8SlFHK0yPSa+idGLQFQ
- joZp2JHYvNlTPkRJ/J4TcXxBTJmArcQgTIuNoBtC+0A/SwdK4MfTCUY4vNWNdese
- 5A4K65Nb7Oh1AdQieTBHNXXCdyFsva9/ScfQGEl7p55a52jOPs0StPd7g64uvjlg
- YHi2yesCrOvVXt+lgPTd
- -----END CERTIFICATE-----
- PEM
- end
+ let(:certificate_pem) { attributes_for(:pages_domain)[:certificate] }
- let(:certificate_key) do
- <<~KEY
- -----BEGIN PRIVATE KEY-----
- MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAKS+CfS9GcRSdYSN
- SzyH5QJQBr5umRL6E+KilOV39iYFO/9oHjUdapTRWkrwnNPCp7qaeck4Jr8iv14t
- PVNDfNr76eGb6/3YknOAP0QOjLWunoC8kjU+N/JHU52NrUeX3qEy8EKV9LeCDJcB
- kBk+Yejn9nypg8c7sLsn33CB6i3bAgMBAAECgYA2D26w80T7WZvazYr86BNMePpd
- j2mIAqx32KZHzt/lhh40J/SRtX9+Kl0Y7nBoRR5Ja9u/HkAIxNxLiUjwg9r6cpg/
- uITEF5nMt7lAk391BuI+7VOZZGbJDsq2ulPd6lO+C8Kq/PI/e4kXcIjeH6KwQsuR
- 5vrXfBZ3sQfflaiN4QJBANBt8JY2LIGQF8o89qwUpRL5vbnKQ4IzZ5+TOl4RLR7O
- AQpJ81tGuINghO7aunctb6rrcKJrxmEH1whzComybrMCQQDKV49nOBudRBAIgG4K
- EnLzsRKISUHMZSJiYTYnablof8cKw1JaQduw7zgrUlLwnroSaAGX88+Jw1f5n2Lh
- Vlg5AkBDdUGnrDLtYBCDEQYZHblrkc7ZAeCllDOWjxUV+uMqlCv8A4Ey6omvY57C
- m6I8DkWVAQx8VPtozhvHjUw80rZHAkB55HWHAM3h13axKG0htCt7klhPsZHpx6MH
- EPjGlXIT+aW2XiPmK3ZlCDcWIenE+lmtbOpI159Wpk8BGXs/s/xBAkEAlAY3ymgx
- 63BDJEwvOb2IaP8lDDxNsXx9XJNVvQbv5n15vNsLHbjslHfAhAbxnLQ1fLhUPqSi
- nNp/xedE1YxutQ==
- -----END PRIVATE KEY-----
- KEY
- end
+ let(:certificate_key) { attributes_for(:pages_domain)[:key] }
before do
allow(Gitlab.config.pages).to receive(:enabled).and_return(true)
+ stub_lets_encrypt_settings
+
project.add_role(user, role)
sign_in(user)
project.namespace.update(owner: user)
allow_any_instance_of(Project).to receive(:pages_deployed?) { true }
end
- context 'when the page_auto_ssl feature flag is enabled' do
- before do
- stub_feature_flags(pages_auto_ssl: true)
+ context 'when the auto SSL management is initially disabled' do
+ let(:domain) do
+ create(:pages_domain, auto_ssl_enabled: false, project: project)
end
- context 'when the auto SSL management is initially disabled' do
- let(:domain) do
- create(:pages_domain, auto_ssl_enabled: false, project: project)
- end
+ it 'enables auto SSL and dynamically updates the form accordingly', :js do
+ visit edit_project_pages_domain_path(project, domain)
- it 'enables auto SSL and dynamically updates the form accordingly', :js do
- visit edit_project_pages_domain_path(project, domain)
+ expect(domain.auto_ssl_enabled).to eq false
- expect(domain.auto_ssl_enabled).to eq false
+ expect(find("#pages_domain_auto_ssl_enabled", visible: false).value).to eq 'false'
+ expect(page).to have_field 'Certificate (PEM)', type: 'textarea'
+ expect(page).to have_field 'Key (PEM)', type: 'textarea'
- expect(find("#pages_domain_auto_ssl_enabled", visible: false).value).to eq 'false'
- expect(page).to have_field 'Certificate (PEM)', type: 'textarea'
- expect(page).to have_field 'Key (PEM)', type: 'textarea'
+ find('.js-auto-ssl-toggle-container .project-feature-toggle').click
- find('.js-auto-ssl-toggle-container .project-feature-toggle').click
+ expect(find("#pages_domain_auto_ssl_enabled", visible: false).value).to eq 'true'
+ expect(page).not_to have_field 'Certificate (PEM)', type: 'textarea'
+ expect(page).not_to have_field 'Key (PEM)', type: 'textarea'
- expect(find("#pages_domain_auto_ssl_enabled", visible: false).value).to eq 'true'
- expect(page).not_to have_field 'Certificate (PEM)', type: 'textarea'
- expect(page).not_to have_field 'Key (PEM)', type: 'textarea'
- expect(page).to have_content "The certificate will be shown here once it has been obtained from Let's Encrypt. This process may take up to an hour to complete."
+ click_on 'Save Changes'
- click_on 'Save Changes'
+ expect(domain.reload.auto_ssl_enabled).to eq true
+ end
+ end
- expect(domain.reload.auto_ssl_enabled).to eq true
- end
+ context 'when the auto SSL management is initially enabled' do
+ let(:domain) do
+ create(:pages_domain, :letsencrypt, auto_ssl_enabled: true, project: project)
end
- context 'when the auto SSL management is initially enabled' do
- let(:domain) do
- create(:pages_domain, auto_ssl_enabled: true, project: project)
- end
+ it 'disables auto SSL and dynamically updates the form accordingly', :js do
+ visit edit_project_pages_domain_path(project, domain)
- it 'disables auto SSL and dynamically updates the form accordingly', :js do
- visit edit_project_pages_domain_path(project, domain)
+ expect(find("#pages_domain_auto_ssl_enabled", visible: false).value).to eq 'true'
+ expect(page).not_to have_field 'Certificate (PEM)', type: 'textarea'
+ expect(page).not_to have_field 'Key (PEM)', type: 'textarea'
- expect(find("#pages_domain_auto_ssl_enabled", visible: false).value).to eq 'true'
- expect(page).to have_field 'Certificate (PEM)', type: 'textarea', disabled: true
- expect(page).not_to have_field 'Key (PEM)', type: 'textarea'
+ find('.js-auto-ssl-toggle-container .project-feature-toggle').click
- find('.js-auto-ssl-toggle-container .project-feature-toggle').click
+ expect(find("#pages_domain_auto_ssl_enabled", visible: false).value).to eq 'false'
+ expect(page).to have_field 'Certificate (PEM)', type: 'textarea'
+ expect(page).to have_field 'Key (PEM)', type: 'textarea'
- expect(find("#pages_domain_auto_ssl_enabled", visible: false).value).to eq 'false'
- expect(page).to have_field 'Certificate (PEM)', type: 'textarea'
- expect(page).to have_field 'Key (PEM)', type: 'textarea'
+ fill_in 'Certificate (PEM)', with: certificate_pem
+ fill_in 'Key (PEM)', with: certificate_key
- fill_in 'Certificate (PEM)', with: certificate_pem
- fill_in 'Key (PEM)', with: certificate_key
+ click_on 'Save Changes'
- click_on 'Save Changes'
+ expect(domain.reload.auto_ssl_enabled).to eq false
+ end
+ end
- expect(domain.reload.auto_ssl_enabled).to eq false
+ shared_examples 'user sees private keys only for user provided certificate' do
+ before do
+ visit edit_project_pages_domain_path(project, domain)
+ end
+
+ shared_examples 'user do not see private key' do
+ it 'user do not see private key' do
+ expect(find_field('Key (PEM)', visible: :all, disabled: :all).value).to be_blank
+ end
+ end
+
+ context 'when auto_ssl is enabled for domain' do
+ let(:domain) { create(:pages_domain, :letsencrypt, project: project, auto_ssl_enabled: true) }
+
+ include_examples 'user do not see private key'
+ end
+
+ context 'when auto_ssl is disabled for domain' do
+ let(:domain) { create(:pages_domain, :letsencrypt, project: project) }
+
+ include_examples 'user do not see private key'
+ end
+
+ context 'when certificate is provided by user' do
+ let(:domain) { create(:pages_domain, project: project) }
+
+ it 'user sees private key' do
+ expect(find_field('Key (PEM)').value).not_to be_blank
end
end
end
- context 'when the page_auto_ssl feature flag is disabled' do
+ include_examples 'user sees private keys only for user provided certificate'
+
+ context 'when letsencrypt is disabled' do
let(:domain) do
create(:pages_domain, auto_ssl_enabled: false, project: project)
end
before do
- stub_feature_flags(pages_auto_ssl: false)
+ stub_application_setting(lets_encrypt_terms_of_service_accepted: false)
visit edit_project_pages_domain_path(project, domain)
end
@@ -127,5 +122,7 @@ describe "Pages with Let's Encrypt", :https_pages_enabled do
it "does not render the Let's Encrypt field", :js do
expect(page).not_to have_selector '.js-auto-ssl-toggle-container'
end
+
+ include_examples 'user sees private keys only for user provided certificate'
end
end
diff --git a/spec/features/projects/pages_spec.rb b/spec/features/projects/pages_spec.rb
index 9bb0ba81ef5..c4b3ddb2088 100644
--- a/spec/features/projects/pages_spec.rb
+++ b/spec/features/projects/pages_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
require 'spec_helper'
-shared_examples 'pages domain editing' do
+shared_examples 'pages settings editing' do
let(:project) { create(:project) }
let(:user) { create(:user) }
let(:role) { :maintainer }
@@ -321,19 +321,15 @@ shared_examples 'pages domain editing' do
end
describe 'Pages' do
- context 'when pages_auto_ssl feature flag is disabled' do
- before do
- stub_feature_flags(pages_auto_ssl: false)
- end
+ include LetsEncryptHelpers
- include_examples 'pages domain editing'
- end
+ include_examples 'pages settings editing'
- context 'when pages_auto_ssl feature flag is enabled' do
+ context 'when letsencrypt support is enabled' do
before do
- stub_feature_flags(pages_auto_ssl: true)
+ stub_lets_encrypt_settings
end
- include_examples 'pages domain editing'
+ include_examples 'pages settings editing'
end
end
diff --git a/spec/frontend/vue_shared/components/paginated_list_spec.js b/spec/frontend/vue_shared/components/paginated_list_spec.js
new file mode 100644
index 00000000000..31ac362d35f
--- /dev/null
+++ b/spec/frontend/vue_shared/components/paginated_list_spec.js
@@ -0,0 +1,56 @@
+import PaginatedList from '~/vue_shared/components/paginated_list.vue';
+import { PREV, NEXT } from '~/vue_shared/components/pagination/constants';
+import { mount } from '@vue/test-utils';
+
+describe('Pagination links component', () => {
+ let wrapper;
+ let glPaginatedList;
+
+ const template = `
+ <div class="slot" slot-scope="{ listItem }">
+ <span class="item">Item Name: {{listItem.id}}</span>
+ </div>
+ `;
+
+ const props = {
+ prevText: PREV,
+ nextText: NEXT,
+ };
+
+ beforeEach(() => {
+ wrapper = mount(PaginatedList, {
+ scopedSlots: {
+ default: template,
+ },
+ propsData: {
+ list: [{ id: 'foo' }, { id: 'bar' }],
+ props,
+ },
+ });
+
+ [glPaginatedList] = wrapper.vm.$children;
+ });
+
+ afterEach(() => {
+ wrapper.destroy();
+ });
+
+ describe('Paginated List Component', () => {
+ describe('props', () => {
+ // We test attrs and not props because we pass through to child component using v-bind:"$attrs"
+ it('should pass prevText to GitLab UI paginated list', () => {
+ expect(glPaginatedList.$attrs['prev-text']).toBe(props.prevText);
+ });
+ it('should pass nextText to GitLab UI paginated list', () => {
+ expect(glPaginatedList.$attrs['next-text']).toBe(props.nextText);
+ });
+ });
+
+ describe('rendering', () => {
+ it('it renders the gl-paginated-list', () => {
+ expect(wrapper.contains('ul.list-group')).toBe(true);
+ expect(wrapper.findAll('li.list-group-item').length).toBe(2);
+ });
+ });
+ });
+});
diff --git a/spec/javascripts/notes/components/diff_with_note_spec.js b/spec/javascripts/notes/components/diff_with_note_spec.js
index 0752bd05904..f849fe9d8bb 100644
--- a/spec/javascripts/notes/components/diff_with_note_spec.js
+++ b/spec/javascripts/notes/components/diff_with_note_spec.js
@@ -47,6 +47,19 @@ describe('diff_with_note', () => {
vm = mountComponentWithStore(Component, { props, store });
});
+ it('removes trailing "+" char', () => {
+ const richText = vm.$el.querySelectorAll('.line_holder')[4].querySelector('.line_content')
+ .textContent[0];
+
+ expect(richText).not.toEqual('+');
+ });
+
+ it('removes trailing "-" char', () => {
+ const richText = vm.$el.querySelector('#LC13').parentNode.textContent[0];
+
+ expect(richText).not.toEqual('-');
+ });
+
it('shows text diff', () => {
expect(selectors.container).toHaveClass('text-file');
expect(selectors.diffTable).toExist();
diff --git a/spec/javascripts/releases/components/release_block_spec.js b/spec/javascripts/releases/components/release_block_spec.js
index 36b181f24ef..e98c665f99d 100644
--- a/spec/javascripts/releases/components/release_block_spec.js
+++ b/spec/javascripts/releases/components/release_block_spec.js
@@ -78,8 +78,10 @@ describe('Release block', () => {
};
let vm;
+ const factory = props => mountComponent(Component, { release: props });
+
beforeEach(() => {
- vm = mountComponent(Component, { release });
+ vm = factory(release);
});
afterEach(() => {
@@ -149,4 +151,14 @@ describe('Release block', () => {
);
});
});
+
+ describe('with pre_release flag', () => {
+ beforeEach(() => {
+ vm = factory(Object.assign({}, release, { pre_release: true }));
+ });
+
+ it('renders pre-release badge', () => {
+ expect(vm.$el.textContent).toContain('Pre-release');
+ });
+ });
});
diff --git a/spec/lib/gitlab/ci/ansi2html_spec.rb b/spec/lib/gitlab/ci/ansi2html_spec.rb
index 3d57ce431ab..aa4e358b148 100644
--- a/spec/lib/gitlab/ci/ansi2html_spec.rb
+++ b/spec/lib/gitlab/ci/ansi2html_spec.rb
@@ -141,11 +141,11 @@ describe Gitlab::Ci::Ansi2html do
end
it "replaces newlines with line break tags" do
- expect(convert_html("\n")).to eq('<span class=""><br/><span class=""></span></span>')
+ expect(convert_html("\n")).to eq('<span class=""></span><br/><span class=""></span>')
end
it "groups carriage returns with newlines" do
- expect(convert_html("\r\n")).to eq('<span class=""><br/><span class=""></span></span>')
+ expect(convert_html("\r\n")).to eq('<span class=""></span><br/><span class=""></span>')
end
describe "incremental update" do
@@ -193,7 +193,7 @@ describe Gitlab::Ci::Ansi2html do
let(:pre_text) { "Hello\r" }
let(:pre_html) { "<span class=\"\">Hello\r</span>" }
let(:text) { "\nWorld" }
- let(:html) { "<span class=\"\"><br/><span class=\"\">World</span></span>" }
+ let(:html) { "<span class=\"\"></span><br/><span class=\"\">World</span>" }
it_behaves_like 'stateable converter'
end
@@ -232,7 +232,7 @@ describe Gitlab::Ci::Ansi2html do
it 'prints light red' do
text = "#{section_start}\e[91mHello\e[0m\n#{section_end}"
header = %{<span class="term-fg-l-red section js-section-header section-header js-s-#{class_name(section_name)}">Hello</span>}
- line_break = %{<span class="section js-section-header section-header js-s-#{class_name(section_name)}"><br/></span>}
+ line_break = %{<span class="section js-section-header section-header js-s-#{class_name(section_name)}"></span><br/>}
line = %{<span class="section line s_#{class_name(section_name)}"></span>}
empty_line = %{<span class="section js-s-#{class_name(section_name)}"></span>}
html = "#{section_start_html}#{header}#{line_break}#{line}#{empty_line}#{section_end_html}"
diff --git a/spec/lib/gitlab/ci/trace/stream_spec.rb b/spec/lib/gitlab/ci/trace/stream_spec.rb
index 35250632e86..0d03eef99c8 100644
--- a/spec/lib/gitlab/ci/trace/stream_spec.rb
+++ b/spec/lib/gitlab/ci/trace/stream_spec.rb
@@ -65,9 +65,9 @@ describe Gitlab::Ci::Trace::Stream, :clean_gitlab_redis_cache do
result = stream.html
expect(result).to eq(
- "<span class=\"\">ヾ(´༎ຶД༎ຶ`)ノ<br/><span class=\"\"></span></span>"\
- "<span class=\"term-fg-green\">許功蓋</span><span class=\"\"><br/>"\
- "<span class=\"\"></span></span>")
+ "<span class=\"\">ヾ(´༎ຶД༎ຶ`)ノ</span><br/><span class=\"\"></span>"\
+ "<span class=\"term-fg-green\">許功蓋</span><span class=\"\"></span><br/>"\
+ "<span class=\"\"></span>")
expect(result.encoding).to eq(Encoding.default_external)
end
end
@@ -306,8 +306,8 @@ describe Gitlab::Ci::Trace::Stream, :clean_gitlab_redis_cache do
shared_examples_for 'htmls' do
it "returns html" do
expect(stream.html).to eq(
- "<span class=\"\">12<br/><span class=\"\">34<br/>"\
- "<span class=\"\">56</span></span></span>")
+ "<span class=\"\">12</span><br/><span class=\"\">34</span><br/>"\
+ "<span class=\"\">56</span>")
end
it "returns html for last line only" do
diff --git a/spec/lib/gitlab/highlight_spec.rb b/spec/lib/gitlab/highlight_spec.rb
index fe0e9702f8a..4676db6b8d8 100644
--- a/spec/lib/gitlab/highlight_spec.rb
+++ b/spec/lib/gitlab/highlight_spec.rb
@@ -18,9 +18,10 @@ describe Gitlab::Highlight do
end
describe '#highlight' do
+ let(:plain_text_file_name) { "test.txt" }
+ let(:plain_text_content) { "plain text contents" }
let(:file_name) { 'test.lisp' }
- let(:no_context_content) { ":type \"assem\"))" }
- let(:content) { "(make-pathname :defaults name\n#{no_context_content}" }
+ let(:content) { "(make-pathname :defaults name\n:type \"assem\")" }
let(:multiline_content) do
%q(
def test(input):
@@ -32,22 +33,22 @@ describe Gitlab::Highlight do
it 'highlights' do
expected = %Q[<span id="LC1" class="line" lang="common_lisp"><span class="p">(</span><span class="nb">make-pathname</span> <span class="ss">:defaults</span> <span class="nv">name</span></span>
-<span id="LC2" class="line" lang="common_lisp"><span class="ss">:type</span> <span class="s">"assem"</span><span class="p">))</span></span>]
+<span id="LC2" class="line" lang="common_lisp"><span class="ss">:type</span> <span class="s">"assem"</span><span class="p">)</span></span>]
expect(described_class.highlight(file_name, content)).to eq(expected)
end
it 'returns plain version for unknown lexer context' do
- result = described_class.highlight(file_name, no_context_content)
+ result = described_class.highlight(plain_text_file_name, plain_text_content)
- expect(result).to eq(%[<span id="LC1" class="line" lang="">:type "assem"))</span>])
+ expect(result).to eq(%[<span id="LC1" class="line" lang="plaintext">plain text contents</span>])
end
it 'returns plain version for long content' do
stub_const('Gitlab::Highlight::MAXIMUM_TEXT_HIGHLIGHT_SIZE', 1)
result = described_class.highlight(file_name, content)
- expect(result).to eq(%[<span id="LC1" class="line" lang="">(make-pathname :defaults name</span>\n<span id="LC2" class="line" lang="">:type "assem"))</span>])
+ expect(result).to eq(%[<span id="LC1" class="line" lang="">(make-pathname :defaults name</span>\n<span id="LC2" class="line" lang="">:type "assem")</span>])
end
it 'highlights multi-line comments' do
diff --git a/spec/models/pages_domain_spec.rb b/spec/models/pages_domain_spec.rb
index fdc81359d34..4fb7b71a3c7 100644
--- a/spec/models/pages_domain_spec.rb
+++ b/spec/models/pages_domain_spec.rb
@@ -356,6 +356,102 @@ describe PagesDomain do
end
end
+ describe '#user_provided_key' do
+ subject { domain.user_provided_key }
+
+ context 'when certificate is provided by user' do
+ let(:domain) { create(:pages_domain) }
+
+ it 'returns key' do
+ is_expected.to eq(domain.key)
+ end
+ end
+
+ context 'when certificate is provided by gitlab' do
+ let(:domain) { create(:pages_domain, :letsencrypt) }
+
+ it 'returns nil' do
+ is_expected.to be_nil
+ end
+ end
+ end
+
+ describe '#user_provided_certificate' do
+ subject { domain.user_provided_certificate }
+
+ context 'when certificate is provided by user' do
+ let(:domain) { create(:pages_domain) }
+
+ it 'returns key' do
+ is_expected.to eq(domain.certificate)
+ end
+ end
+
+ context 'when certificate is provided by gitlab' do
+ let(:domain) { create(:pages_domain, :letsencrypt) }
+
+ it 'returns nil' do
+ is_expected.to be_nil
+ end
+ end
+ end
+
+ shared_examples 'certificate setter' do |attribute, setter_name, old_certificate_source, new_certificate_source|
+ let(:domain) do
+ create(:pages_domain, certificate_source: old_certificate_source)
+ end
+
+ let(:old_value) { domain.public_send(attribute) }
+
+ subject { domain.public_send(setter_name, new_value) }
+
+ context 'when value has been changed' do
+ let(:new_value) { 'new_value' }
+
+ it "assignes new value to #{attribute}" do
+ expect do
+ subject
+ end.to change { domain.public_send(attribute) }.from(old_value).to('new_value')
+ end
+
+ it 'changes certificate source' do
+ expect do
+ subject
+ end.to change { domain.certificate_source }.from(old_certificate_source).to(new_certificate_source)
+ end
+ end
+
+ context 'when value has not been not changed' do
+ let(:new_value) { old_value }
+
+ it 'does not change certificate source' do
+ expect do
+ subject
+ end.not_to change { domain.certificate_source }.from(old_certificate_source)
+ end
+ end
+ end
+
+ describe '#user_provided_key=' do
+ include_examples('certificate setter', 'key', 'user_provided_key=',
+ 'gitlab_provided', 'user_provided')
+ end
+
+ describe '#gitlab_provided_key=' do
+ include_examples('certificate setter', 'key', 'gitlab_provided_key=',
+ 'user_provided', 'gitlab_provided')
+ end
+
+ describe '#user_provided_certificate=' do
+ include_examples('certificate setter', 'certificate', 'user_provided_certificate=',
+ 'gitlab_provided', 'user_provided')
+ end
+
+ describe '#gitlab_provided_certificate=' do
+ include_examples('certificate setter', 'certificate', 'gitlab_provided_certificate=',
+ 'user_provided', 'gitlab_provided')
+ end
+
describe '.for_removal' do
subject { described_class.for_removal }
diff --git a/spec/requests/api/pages_domains_spec.rb b/spec/requests/api/pages_domains_spec.rb
index 3eb68a6abb6..449032b95b7 100644
--- a/spec/requests/api/pages_domains_spec.rb
+++ b/spec/requests/api/pages_domains_spec.rb
@@ -359,6 +359,14 @@ describe API::PagesDomains do
expect(pages_domain_secure.certificate).to eq(params_secure_nokey[:certificate])
end
+ it 'updates certificate source to user_provided if is changed' do
+ pages_domain.update!(certificate_source: 'gitlab_provided')
+
+ expect do
+ put api(route_domain, user), params: params_secure
+ end.to change { pages_domain.reload.certificate_source }.from('gitlab_provided').to('user_provided')
+ end
+
it 'fails to update pages domain adding certificate without key' do
put api(route_domain, user), params: params_secure_nokey
diff --git a/spec/services/issues/reorder_service_spec.rb b/spec/services/issues/reorder_service_spec.rb
new file mode 100644
index 00000000000..b147cdf4e64
--- /dev/null
+++ b/spec/services/issues/reorder_service_spec.rb
@@ -0,0 +1,88 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Issues::ReorderService do
+ set(:user) { create(:user) }
+ set(:project) { create(:project) }
+ set(:group) { create(:group) }
+
+ shared_examples 'issues reorder service' do
+ context 'when reordering issues' do
+ it 'returns false with no params' do
+ expect(service({}).execute(issue1)).to be_falsey
+ end
+
+ it 'returns false with both invalid params' do
+ params = { move_after_id: nil, move_before_id: 1 }
+
+ expect(service(params).execute(issue1)).to be_falsey
+ end
+
+ it 'sorts issues' do
+ params = { move_after_id: issue2.id, move_before_id: issue3.id }
+
+ service(params).execute(issue1)
+
+ expect(issue1.relative_position)
+ .to be_between(issue2.relative_position, issue3.relative_position)
+ end
+ end
+ end
+
+ describe '#execute' do
+ let(:issue1) { create(:issue, project: project, relative_position: 10) }
+ let(:issue2) { create(:issue, project: project, relative_position: 20) }
+ let(:issue3) { create(:issue, project: project, relative_position: 30) }
+
+ context 'when ordering issues in a project' do
+ let(:parent) { project }
+
+ before do
+ parent.add_developer(user)
+ end
+
+ it_behaves_like 'issues reorder service'
+ end
+
+ context 'when ordering issues in a group' do
+ let(:project) { create(:project, namespace: group) }
+
+ before do
+ group.add_developer(user)
+ end
+
+ it_behaves_like 'issues reorder service'
+
+ context 'when ordering in a group issue list' do
+ let(:params) { { move_after_id: issue2.id, move_before_id: issue3.id, group_full_path: group.full_path } }
+
+ subject { service(params) }
+
+ it 'sends the board_group_id parameter' do
+ match_params = { move_between_ids: [issue2.id, issue3.id], board_group_id: group.id }
+
+ expect(Issues::UpdateService)
+ .to receive(:new).with(project, user, match_params)
+ .and_return(double(execute: build(:issue)))
+
+ subject.execute(issue1)
+ end
+
+ it 'sorts issues' do
+ project2 = create(:project, namespace: group)
+ issue4 = create(:issue, project: project2)
+
+ subject.execute(issue4)
+
+ expect(issue4.relative_position)
+ .to be_between(issue2.relative_position, issue3.relative_position)
+ end
+ end
+ end
+ end
+
+ def service(params)
+ described_class.new(project, user, params)
+ end
+end
diff --git a/spec/services/issues/update_service_spec.rb b/spec/services/issues/update_service_spec.rb
index 22f5607cb9c..28fa5d12d9c 100644
--- a/spec/services/issues/update_service_spec.rb
+++ b/spec/services/issues/update_service_spec.rb
@@ -687,6 +687,22 @@ describe Issues::UpdateService, :mailer do
end
end
+ context 'when moving an issue ', :nested_groups do
+ it 'raises an error for invalid move ids within a project' do
+ opts = { move_between_ids: [9000, 9999] }
+
+ expect { described_class.new(issue.project, user, opts).execute(issue) }
+ .to raise_error(ActiveRecord::RecordNotFound)
+ end
+
+ it 'raises an error for invalid move ids within a group' do
+ opts = { move_between_ids: [9000, 9999], board_group_id: create(:group).id }
+
+ expect { described_class.new(issue.project, user, opts).execute(issue) }
+ .to raise_error(ActiveRecord::RecordNotFound)
+ end
+ end
+
include_examples 'issuable update service' do
let(:open_issuable) { issue }
let(:closed_issuable) { create(:closed_issue, project: project) }
diff --git a/spec/services/pages_domains/obtain_lets_encrypt_certificate_service_spec.rb b/spec/services/pages_domains/obtain_lets_encrypt_certificate_service_spec.rb
index 6d7be27939c..d5f77f3354b 100644
--- a/spec/services/pages_domains/obtain_lets_encrypt_certificate_service_spec.rb
+++ b/spec/services/pages_domains/obtain_lets_encrypt_certificate_service_spec.rb
@@ -137,6 +137,12 @@ describe PagesDomains::ObtainLetsEncryptCertificateService do
expect(pages_domain.certificate).to eq(certificate)
end
+ it 'marks certificate as gitlab_provided' do
+ service.execute
+
+ expect(pages_domain.certificate_source).to eq("gitlab_provided")
+ end
+
it 'removes order from database' do
service.execute
diff --git a/spec/support/shared_examples/ci_trace_shared_examples.rb b/spec/support/shared_examples/ci_trace_shared_examples.rb
index f985b2dcbba..7993b2870e5 100644
--- a/spec/support/shared_examples/ci_trace_shared_examples.rb
+++ b/spec/support/shared_examples/ci_trace_shared_examples.rb
@@ -5,7 +5,7 @@ shared_examples_for 'common trace features' do
end
it "returns formatted html" do
- expect(trace.html).to eq("<span class=\"\">12<br/><span class=\"\">34</span></span>")
+ expect(trace.html).to eq("<span class=\"\">12</span><br/><span class=\"\">34</span>")
end
it "returns last line of formatted html" do
diff --git a/spec/tasks/gitlab/check_rake_spec.rb b/spec/tasks/gitlab/check_rake_spec.rb
index 06525e3c771..0fcb9b269f3 100644
--- a/spec/tasks/gitlab/check_rake_spec.rb
+++ b/spec/tasks/gitlab/check_rake_spec.rb
@@ -96,6 +96,15 @@ describe 'check.rake' do
subject
end
+
+ it 'sanitizes output' do
+ user = double(dn: 'uid=fake_user1', uid: 'fake_user1')
+ allow(adapter).to receive(:users).and_return([user])
+ stub_env('SANITIZE', 'true')
+
+ expect { subject }.to output(/User output sanitized/).to_stdout
+ expect { subject }.not_to output('fake_user1').to_stdout
+ end
end
end
end