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
12563bb3
Commit
12563bb3
authored
Jul 12, 2019
by
Vladimir Shushlin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix saving domain without certificate for auto_ssl
parent
5ea899d3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
12 deletions
+27
-12
app/models/pages_domain.rb
app/models/pages_domain.rb
+8
-2
spec/models/pages_domain_spec.rb
spec/models/pages_domain_spec.rb
+19
-10
No files found.
app/models/pages_domain.rb
View file @
12563bb3
...
...
@@ -12,9 +12,11 @@ class PagesDomain < ApplicationRecord
validates
:domain
,
hostname:
{
allow_numeric_hostname:
true
}
validates
:domain
,
uniqueness:
{
case_sensitive:
false
}
validates
:certificate
,
presence:
{
message:
'must be present if HTTPS-only is enabled'
},
if:
->
(
domain
)
{
domain
.
project
&
.
pages_https_only?
}
validates
:certificate
,
presence:
{
message:
'must be present if HTTPS-only is enabled'
},
if: :certificate_should_be_present?
validates
:certificate
,
certificate:
true
,
if:
->
(
domain
)
{
domain
.
certificate
.
present?
}
validates
:key
,
presence:
{
message:
'must be present if HTTPS-only is enabled'
},
if:
->
(
domain
)
{
domain
.
project
&
.
pages_https_only?
}
validates
:key
,
presence:
{
message:
'must be present if HTTPS-only is enabled'
},
if: :certificate_should_be_present?
validates
:key
,
certificate_key:
true
,
if:
->
(
domain
)
{
domain
.
key
.
present?
}
validates
:verification_code
,
presence:
true
,
allow_blank:
false
...
...
@@ -249,4 +251,8 @@ class PagesDomain < ApplicationRecord
rescue
OpenSSL
::
PKey
::
PKeyError
,
OpenSSL
::
Cipher
::
CipherError
nil
end
def
certificate_should_be_present?
!
auto_ssl_enabled?
&&
project
&
.
pages_https_only?
end
end
spec/models/pages_domain_spec.rb
View file @
12563bb3
...
...
@@ -53,24 +53,33 @@ describe PagesDomain do
end
let
(
:pages_domain
)
do
build
(
:pages_domain
,
certificate:
certificate
,
key:
key
).
tap
do
|
pd
|
build
(
:pages_domain
,
certificate:
certificate
,
key:
key
,
auto_ssl_enabled:
auto_ssl_enabled
).
tap
do
|
pd
|
allow
(
pd
).
to
receive
(
:project
).
and_return
(
project
)
pd
.
valid?
end
end
where
(
:pages_https_only
,
:certificate
,
:key
,
:errors_on
)
do
where
(
:pages_https_only
,
:certificate
,
:key
,
:
auto_ssl_enabled
,
:
errors_on
)
do
attributes
=
attributes_for
(
:pages_domain
)
cert
,
key
=
attributes
.
fetch_values
(
:certificate
,
:key
)
true
|
nil
|
nil
|
%i(certificate key)
true
|
cert
|
nil
|
%i(key)
true
|
nil
|
key
|
%i(certificate key)
true
|
cert
|
key
|
[]
false
|
nil
|
nil
|
[]
false
|
cert
|
nil
|
%i(key)
false
|
nil
|
key
|
%i(key)
false
|
cert
|
key
|
[]
true
|
nil
|
nil
|
false
|
%i(certificate key)
true
|
nil
|
nil
|
true
|
[]
true
|
cert
|
nil
|
false
|
%i(key)
true
|
cert
|
nil
|
true
|
%i(key)
true
|
nil
|
key
|
false
|
%i(certificate key)
true
|
nil
|
key
|
true
|
%i(key)
true
|
cert
|
key
|
false
|
[]
true
|
cert
|
key
|
true
|
[]
false
|
nil
|
nil
|
false
|
[]
false
|
nil
|
nil
|
true
|
[]
false
|
cert
|
nil
|
false
|
%i(key)
false
|
cert
|
nil
|
true
|
%i(key)
false
|
nil
|
key
|
false
|
%i(key)
false
|
nil
|
key
|
true
|
%i(key)
false
|
cert
|
key
|
false
|
[]
false
|
cert
|
key
|
true
|
[]
end
with_them
do
...
...
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