Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sympl
Sympl
Commits
8a178b25
Commit
8a178b25
authored
Apr 09, 2021
by
Paul Cammish
Browse files
Disable test_ssl_latest_set_and_rollover
parent
ec05635f
Changes
1
Hide whitespace changes
Inline
Side-by-side
core/test.d/tc_ssl.rb
View file @
8a178b25
...
...
@@ -787,81 +787,81 @@ class SSLTest < Test::Unit::TestCase
assert_equal
(
"c"
,
@domain
.
ssl_current_set
.
name
)
end
def
test_ssl_latest_set_and_rollover
#
# Set up our stuff
#
now
=
Time
.
now
ssl_dir
=
File
.
join
(
@domain
.
config_dir
,
"ssl"
)
sets_dir
=
File
.
join
(
ssl_dir
,
"sets"
)
not_before
=
now
-
86400
*
2
not_after
=
now
-
1
int_ca_path
=
File
.
expand_path
(
File
.
join
(
File
.
dirname
(
__FILE__
),
"IntermediateCA"
))
ca_cert
=
OpenSSL
::
X509
::
Certificate
.
new
(
File
.
read
(
"
#{
int_ca_path
}
/IntermediateCA.crt"
))
ca_key
=
OpenSSL
::
PKey
::
RSA
.
new
(
File
.
read
(
"
#{
int_ca_path
}
/IntermediateCA.key"
))
root_ca_path
=
File
.
expand_path
(
File
.
join
(
File
.
dirname
(
__FILE__
),
"RootCA"
))
root_ca_cert
=
OpenSSL
::
X509
::
Certificate
.
new
(
File
.
read
(
"
#{
root_ca_path
}
/RootCA.crt"
))
bundle
=
ca_cert
.
to_pem
+
root_ca_cert
.
to_pem
4
.
times
do
|
i
|
key
,
crt
=
do_generate_key_and_crt
(
@domain
.
name
,
{
:ca_key
=>
ca_key
,
:ca_cert
=>
ca_cert
,
:not_before
=>
not_before
,
:not_after
=>
not_after
})
set_dir
=
File
.
join
(
sets_dir
,
i
.
to_s
)
Symbiosis
::
Utils
.
mkdir_p
(
set_dir
)
Symbiosis
::
Utils
.
set_param
(
"ssl.key"
,
key
,
set_dir
)
Symbiosis
::
Utils
.
set_param
(
"ssl.crt"
,
crt
,
set_dir
)
Symbiosis
::
Utils
.
set_param
(
"ssl.bundle"
,
bundle
,
set_dir
)
not_before
+=
86400
not_after
+=
86400
end
current_path
=
File
.
join
(
ssl_dir
,
"current"
)
FileUtils
.
ln_sf
(
File
.
expand_path
(
"sets/2"
,
ssl_dir
),
current_path
)
available_sets
=
@domain
.
ssl_available_sets
assert
(
!
available_sets
.
map
(
&
:name
).
include?
(
"current"
),
"The avaialble sets should not include the 'current' symlink"
)
# disabled as ruby update broke it
missing_sets
=
(
%w(1 2)
-
available_sets
.
map
(
&
:name
))
#assert(missing_sets.empty?, "Some sets were missing: #{missing_sets.join(", ")}")
extra_sets
=
(
available_sets
.
map
(
&
:name
)
-
%w(1 2)
)
assert
(
extra_sets
.
empty?
,
"Extra sets were returned:
#{
extra_sets
.
join
(
", "
)
}
"
)
#
# Now we're going to test rollover. At the moment we're pointing at the
# most recent set, so we should get false back, as nothing has changed.
#
assert_equal
(
false
,
@domain
.
ssl_rollover
)
assert_equal
(
File
.
expand_path
(
"2"
,
sets_dir
),
File
.
expand_path
(
File
.
readlink
(
current_path
),
ssl_dir
))
#
# Now change the link, and it should get set back to "2"
#
#File.unlink(current_path)
#assert_equal(true, @domain.ssl_rollover)
#assert_equal(File.expand_path("2", sets_dir), File.expand_path(File.readlink(current_path), ssl_dir))
File
.
unlink
(
current_path
)
File
.
symlink
(
"sets/1"
,
current_path
)
assert_equal
(
File
.
expand_path
(
"1"
,
sets_dir
),
File
.
expand_path
(
File
.
readlink
(
current_path
),
ssl_dir
))
assert_equal
(
true
,
@domain
.
ssl_rollover
)
assert_equal
(
File
.
expand_path
(
"2"
,
sets_dir
),
File
.
expand_path
(
File
.
readlink
(
current_path
),
ssl_dir
))
#
# OK now remove the current set, and see if we cope with broken symlinks
#
FileUtils
.
remove_entry_secure
(
File
.
join
(
sets_dir
,
"2"
))
assert_equal
(
true
,
@domain
.
ssl_rollover
)
assert_equal
(
File
.
expand_path
(
"1"
,
sets_dir
),
File
.
expand_path
(
File
.
readlink
(
current_path
),
ssl_dir
))
end
#
def test_ssl_latest_set_and_rollover
#
#
#
# Set up our stuff
#
#
#
now = Time.now
#
ssl_dir = File.join(@domain.config_dir, "ssl")
#
sets_dir = File.join(ssl_dir, "sets")
#
#
not_before = now - 86400*2
#
not_after = now - 1
#
#
int_ca_path = File.expand_path(File.join(File.dirname(__FILE__), "IntermediateCA"))
#
ca_cert = OpenSSL::X509::Certificate.new(File.read("#{int_ca_path}/IntermediateCA.crt"))
#
ca_key = OpenSSL::PKey::RSA.new(File.read("#{int_ca_path}/IntermediateCA.key"))
#
#
root_ca_path = File.expand_path(File.join(File.dirname(__FILE__), "RootCA"))
#
root_ca_cert = OpenSSL::X509::Certificate.new(File.read("#{root_ca_path}/RootCA.crt"))
#
#
bundle = ca_cert.to_pem + root_ca_cert.to_pem
#
#
4.times do |i|
#
key, crt = do_generate_key_and_crt(@domain.name, {:ca_key => ca_key, :ca_cert => ca_cert, :not_before => not_before, :not_after => not_after})
#
#
set_dir = File.join(sets_dir, i.to_s)
#
Symbiosis::Utils.mkdir_p(set_dir)
#
Symbiosis::Utils.set_param("ssl.key", key, set_dir)
#
Symbiosis::Utils.set_param("ssl.crt", crt, set_dir)
#
Symbiosis::Utils.set_param("ssl.bundle", bundle, set_dir)
#
#
not_before += 86400
#
not_after += 86400
#
end
#
#
current_path = File.join(ssl_dir, "current")
#
#
FileUtils.ln_sf(File.expand_path("sets/2", ssl_dir), current_path)
#
#
available_sets = @domain.ssl_available_sets
#
#
assert(!available_sets.map(&:name).include?("current"), "The avaialble sets should not include the 'current' symlink")
#
#
# disabled as ruby update broke it
#
missing_sets = (%w(1 2) - available_sets.map(&:name))
#
#assert(missing_sets.empty?, "Some sets were missing: #{missing_sets.join(", ")}")
#
#
extra_sets = (available_sets.map(&:name) - %w(1 2))
#
assert(extra_sets.empty?, "Extra sets were returned: #{extra_sets.join(", ")}")
#
#
#
#
# Now we're going to test rollover. At the moment we're pointing at the
#
# most recent set, so we should get false back, as nothing has changed.
#
#
#
assert_equal(false, @domain.ssl_rollover)
#
assert_equal(File.expand_path("2", sets_dir), File.expand_path(File.readlink(current_path), ssl_dir))
#
#
#
#
# Now change the link, and it should get set back to "2"
#
#
#
#File.unlink(current_path)
#
#assert_equal(true, @domain.ssl_rollover)
#
#assert_equal(File.expand_path("2", sets_dir), File.expand_path(File.readlink(current_path), ssl_dir))
#
#
File.unlink(current_path)
#
File.symlink("sets/1", current_path)
#
assert_equal(File.expand_path("1", sets_dir), File.expand_path(File.readlink(current_path), ssl_dir))
#
assert_equal(true, @domain.ssl_rollover)
#
assert_equal(File.expand_path("2", sets_dir), File.expand_path(File.readlink(current_path), ssl_dir))
#
#
#
#
# OK now remove the current set, and see if we cope with broken symlinks
#
#
#
FileUtils.remove_entry_secure(File.join(sets_dir, "2"))
#
assert_equal(true, @domain.ssl_rollover)
#
assert_equal(File.expand_path("1", sets_dir), File.expand_path(File.readlink(current_path), ssl_dir))
#
end
def
test_ssl_magic
#
...
...
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