Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
4ab82656
Commit
4ab82656
authored
Nov 11, 2019
by
Vladimir Shushlin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable Let's Encrypt by default for new domains
only if Let's Encrypt is enabled on the instance level
parent
037db4be
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
5 deletions
+28
-5
app/models/pages_domain.rb
app/models/pages_domain.rb
+2
-0
spec/features/projects/pages_lets_encrypt_spec.rb
spec/features/projects/pages_lets_encrypt_spec.rb
+13
-1
spec/features/projects/pages_spec.rb
spec/features/projects/pages_spec.rb
+12
-3
spec/workers/pages_domain_ssl_renewal_cron_worker_spec.rb
spec/workers/pages_domain_ssl_renewal_cron_worker_spec.rb
+1
-1
No files found.
app/models/pages_domain.rb
View file @
4ab82656
...
...
@@ -24,6 +24,8 @@ class PagesDomain < ApplicationRecord
validate
:validate_matching_key
,
if:
->
(
domain
)
{
domain
.
certificate
.
present?
||
domain
.
key
.
present?
}
validate
:validate_intermediates
,
if:
->
(
domain
)
{
domain
.
certificate
.
present?
&&
domain
.
certificate_changed?
}
default_value_for
(
:auto_ssl_enabled
,
allow_nil:
false
)
{
::
Gitlab
::
LetsEncrypt
.
enabled?
}
attr_encrypted
:key
,
mode: :per_attribute_iv_and_salt
,
insecure_mode:
true
,
...
...
spec/features/projects/pages_lets_encrypt_spec.rb
View file @
4ab82656
...
...
@@ -23,6 +23,18 @@ describe "Pages with Let's Encrypt", :https_pages_enabled do
end
end
it
"creates new domain with Let's Encrypt enabled by default"
do
visit
new_project_pages_domain_path
(
project
)
fill_in
'Domain'
,
with:
'my.test.domain.com'
expect
(
find
(
"#pages_domain_auto_ssl_enabled"
,
visible:
false
).
value
).
to
eq
'true'
click_button
'Create New Domain'
expect
(
page
).
to
have_content
(
'my.test.domain.com'
)
expect
(
PagesDomain
.
find_by_domain
(
'my.test.domain.com'
).
auto_ssl_enabled
).
to
eq
(
true
)
end
context
'when the auto SSL management is initially disabled'
do
let
(
:domain
)
do
create
(
:pages_domain
,
auto_ssl_enabled:
false
,
project:
project
)
...
...
@@ -96,7 +108,7 @@ describe "Pages with Let's Encrypt", :https_pages_enabled do
end
context
'when certificate is provided by user'
do
let
(
:domain
)
{
create
(
:pages_domain
,
project:
project
)
}
let
(
:domain
)
{
create
(
:pages_domain
,
project:
project
,
auto_ssl_enabled:
false
)
}
it
'user sees certificate subject'
do
visit
edit_project_pages_domain_path
(
project
,
domain
)
...
...
spec/features/projects/pages_spec.rb
View file @
4ab82656
...
...
@@ -133,7 +133,7 @@ shared_examples 'pages settings editing' do
end
end
context
'when pages are exposed on external HTTPS address'
,
:https_pages_enabled
do
context
'when pages are exposed on external HTTPS address'
,
:https_pages_enabled
,
:js
do
let
(
:certificate_pem
)
do
<<~
PEM
-----BEGIN CERTIFICATE-----
...
...
@@ -178,6 +178,11 @@ shared_examples 'pages settings editing' do
visit
new_project_pages_domain_path
(
project
)
fill_in
'Domain'
,
with:
'my.test.domain.com'
if
::
Gitlab
::
LetsEncrypt
.
enabled?
find
(
'.js-auto-ssl-toggle-container .project-feature-toggle'
).
click
end
fill_in
'Certificate (PEM)'
,
with:
certificate_pem
fill_in
'Key (PEM)'
,
with:
certificate_key
click_button
'Create New Domain'
...
...
@@ -202,7 +207,7 @@ shared_examples 'pages settings editing' do
describe
'updating the certificate for an existing domain'
do
let!
(
:domain
)
do
create
(
:pages_domain
,
project:
project
)
create
(
:pages_domain
,
project:
project
,
auto_ssl_enabled:
false
)
end
it
'allows the certificate to be updated'
do
...
...
@@ -215,7 +220,7 @@ shared_examples 'pages settings editing' do
end
context
'when the certificate is invalid'
do
let
_it_be
(
:domain
)
do
let
!
(
:domain
)
do
create
(
:pages_domain
,
:without_certificate
,
:without_key
,
project:
project
)
end
...
...
@@ -224,6 +229,10 @@ shared_examples 'pages settings editing' do
within
(
'#content-body'
)
{
click_link
'Edit'
}
if
::
Gitlab
::
LetsEncrypt
.
enabled?
find
(
'.js-auto-ssl-toggle-container .project-feature-toggle'
).
click
end
fill_in
'Certificate (PEM)'
,
with:
'invalid data'
click_button
'Save Changes'
...
...
spec/workers/pages_domain_ssl_renewal_cron_worker_spec.rb
View file @
4ab82656
...
...
@@ -13,7 +13,7 @@ describe PagesDomainSslRenewalCronWorker do
describe
'#perform'
do
let
(
:project
)
{
create
:project
}
let!
(
:domain
)
{
create
(
:pages_domain
,
project:
project
)
}
let!
(
:domain
)
{
create
(
:pages_domain
,
project:
project
,
auto_ssl_enabled:
false
)
}
let!
(
:domain_with_enabled_auto_ssl
)
{
create
(
:pages_domain
,
project:
project
,
auto_ssl_enabled:
true
)
}
let!
(
:domain_with_obtained_letsencrypt
)
do
create
(
:pages_domain
,
:letsencrypt
,
project:
project
,
auto_ssl_enabled:
true
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment