Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
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
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Paul Graydon
slapos.core
Commits
b0a1e55b
Commit
b0a1e55b
authored
Apr 14, 2022
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_erp5: Include alarm to renew the instance certificate every 3 month
Include general tests for the revoke/generation
parent
c113c5ef
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
386 additions
and
0 deletions
+386
-0
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudComputeNodeSlapInterfaceWorkflow.py
...t.erp5.testSlapOSCloudComputeNodeSlapInterfaceWorkflow.py
+67
-0
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudInstanceSlapInterfaceWorkflow.py
...test.erp5.testSlapOSCloudInstanceSlapInterfaceWorkflow.py
+67
-0
master/bt5/slapos_erp5/PathTemplateItem/portal_alarms/slapos_renew_software_instance_certificate.xml
...tal_alarms/slapos_renew_software_instance_certificate.xml
+113
-0
master/bt5/slapos_erp5/SkinTemplateItem/portal_skins/slapos_administration/Alarm_renewSoftwareInstanceCertificate.py
..._administration/Alarm_renewSoftwareInstanceCertificate.py
+13
-0
master/bt5/slapos_erp5/SkinTemplateItem/portal_skins/slapos_administration/Alarm_renewSoftwareInstanceCertificate.xml
...administration/Alarm_renewSoftwareInstanceCertificate.xml
+58
-0
master/bt5/slapos_erp5/SkinTemplateItem/portal_skins/slapos_administration/SoftwareInstance_renewCertificate.py
...lapos_administration/SoftwareInstance_renewCertificate.py
+5
-0
master/bt5/slapos_erp5/SkinTemplateItem/portal_skins/slapos_administration/SoftwareInstance_renewCertificate.xml
...apos_administration/SoftwareInstance_renewCertificate.xml
+62
-0
master/bt5/slapos_erp5/bt/template_path_list
master/bt5/slapos_erp5/bt/template_path_list
+1
-0
No files found.
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudComputeNodeSlapInterfaceWorkflow.py
View file @
b0a1e55b
...
...
@@ -293,6 +293,73 @@ class TestSlapOSCoreComputeNodeSlapInterfaceWorkflow(SlapOSTestCaseMixin):
self
.
assertEqual
(
None
,
self
.
portal
.
REQUEST
.
get
(
'compute_node_certificate'
))
self
.
assertEqual
(
None
,
self
.
compute_node
.
getDestinationReference
())
def
test_renewCertificate
(
self
):
self
.
login
(
self
.
compute_node
.
getUserId
())
self
.
compute_node
.
generateCertificate
()
compute_node_key
=
self
.
portal
.
REQUEST
.
get
(
'compute_node_key'
)
compute_node_certificate
=
self
.
portal
.
REQUEST
.
get
(
'compute_node_certificate'
)
destination_reference
=
self
.
compute_node
.
getDestinationReference
()
self
.
assertNotEqual
(
None
,
compute_node_key
)
self
.
assertNotEqual
(
None
,
compute_node_certificate
)
self
.
assertNotEqual
(
None
,
destination_reference
)
serial
=
'0x%x'
%
int
(
self
.
compute_node
.
getDestinationReference
(),
16
)
self
.
assertTrue
(
serial
in
compute_node_certificate
)
self
.
assertTrue
(
self
.
compute_node
.
getReference
()
in
compute_node_certificate
.
decode
(
'string_escape'
))
self
.
compute_node
.
renewCertificate
()
self
.
assertNotEqual
(
None
,
self
.
portal
.
REQUEST
.
get
(
'compute_node_key'
))
self
.
assertNotEqual
(
None
,
self
.
portal
.
REQUEST
.
get
(
'compute_node_certificate'
))
self
.
assertNotEqual
(
None
,
self
.
compute_node
.
getDestinationReference
())
self
.
assertNotEqual
(
compute_node_key
,
self
.
portal
.
REQUEST
.
get
(
'compute_node_key'
))
self
.
assertNotEqual
(
compute_node_certificate
,
self
.
portal
.
REQUEST
.
get
(
'compute_node_certificate'
))
self
.
assertNotEqual
(
destination_reference
,
self
.
compute_node
.
getDestinationReference
())
def
test_renewCertificateNoCertificate
(
self
):
self
.
login
(
self
.
compute_node
.
getUserId
())
self
.
assertRaises
(
ValueError
,
self
.
compute_node
.
renewCertificate
)
self
.
assertEqual
(
None
,
self
.
portal
.
REQUEST
.
get
(
'compute_node_key'
))
self
.
assertEqual
(
None
,
self
.
portal
.
REQUEST
.
get
(
'compute_node_certificate'
))
self
.
assertEqual
(
None
,
self
.
compute_node
.
getDestinationReference
())
def
test_renewCertificate_twice
(
self
):
self
.
login
(
self
.
compute_node
.
getUserId
())
self
.
compute_node
.
generateCertificate
()
compute_node_key
=
self
.
portal
.
REQUEST
.
get
(
'compute_node_key'
)
compute_node_certificate
=
self
.
portal
.
REQUEST
.
get
(
'compute_node_certificate'
)
destination_reference
=
self
.
compute_node
.
getDestinationReference
()
self
.
assertNotEqual
(
None
,
compute_node_key
)
self
.
assertNotEqual
(
None
,
compute_node_certificate
)
self
.
assertNotEqual
(
None
,
self
.
compute_node
.
getDestinationReference
())
serial
=
'0x%x'
%
int
(
self
.
compute_node
.
getDestinationReference
(),
16
)
self
.
assertTrue
(
serial
in
compute_node_certificate
)
self
.
assertTrue
(
self
.
compute_node
.
getReference
()
in
compute_node_certificate
.
decode
(
'string_escape'
))
self
.
compute_node
.
renewCertificate
()
self
.
assertNotEqual
(
None
,
self
.
portal
.
REQUEST
.
get
(
'compute_node_key'
))
self
.
assertNotEqual
(
None
,
self
.
portal
.
REQUEST
.
get
(
'compute_node_certificate'
))
self
.
assertNotEqual
(
None
,
self
.
compute_node
.
getDestinationReference
())
self
.
assertNotEqual
(
compute_node_key
,
self
.
portal
.
REQUEST
.
get
(
'compute_node_key'
))
self
.
assertNotEqual
(
compute_node_certificate
,
self
.
portal
.
REQUEST
.
get
(
'compute_node_certificate'
))
self
.
assertNotEqual
(
destination_reference
,
self
.
compute_node
.
getDestinationReference
())
compute_node_key
=
self
.
portal
.
REQUEST
.
get
(
'compute_node_key'
)
compute_node_certificate
=
self
.
portal
.
REQUEST
.
get
(
'compute_node_certificate'
)
destination_reference
=
self
.
compute_node
.
getDestinationReference
()
self
.
compute_node
.
renewCertificate
()
self
.
assertNotEqual
(
None
,
self
.
portal
.
REQUEST
.
get
(
'compute_node_key'
))
self
.
assertNotEqual
(
None
,
self
.
portal
.
REQUEST
.
get
(
'compute_node_certificate'
))
self
.
assertNotEqual
(
None
,
self
.
compute_node
.
getDestinationReference
())
self
.
assertNotEqual
(
compute_node_key
,
self
.
portal
.
REQUEST
.
get
(
'compute_node_key'
))
self
.
assertNotEqual
(
compute_node_certificate
,
self
.
portal
.
REQUEST
.
get
(
'compute_node_certificate'
))
self
.
assertNotEqual
(
destination_reference
,
self
.
compute_node
.
getDestinationReference
())
class
TestSlapOSCoreComputeNodeSlapInterfaceWorkflowSupply
(
SlapOSTestCaseMixin
):
def
afterSetUp
(
self
):
...
...
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudInstanceSlapInterfaceWorkflow.py
View file @
b0a1e55b
...
...
@@ -1138,3 +1138,70 @@ class TestSlapOSCoreInstanceSlapInterfaceWorkflowTransfer(SlapOSTestCaseMixin):
len
(
self
.
instance_tree
.
getAggregateRelatedList
(
portal_type
=
"Internal Packing List Line"
))
)
def
test_generateCertificate
(
self
):
self
.
login
()
self
.
software_instance
.
setDestinationReference
(
None
)
self
.
software_instance
.
getSslKey
(
None
)
self
.
software_instance
.
getSslCertificate
(
None
)
self
.
software_instance
.
generateCertificate
()
self
.
assertNotEqual
(
self
.
software_instance
.
getDestinationReference
(),
None
)
self
.
assertNotEqual
(
self
.
software_instance
.
getSslKey
(),
None
)
self
.
assertNotEqual
(
self
.
software_instance
.
getSslCertificate
(),
None
)
self
.
assertRaises
(
ValueError
,
self
.
software_instance
.
generateCertificate
)
def
test_revokeCertificate
(
self
):
self
.
login
()
self
.
assertNotEqual
(
self
.
software_instance
.
getDestinationReference
(),
None
)
self
.
assertNotEqual
(
self
.
software_instance
.
getSslKey
(),
None
)
self
.
assertNotEqual
(
self
.
software_instance
.
getSslCertificate
(),
None
)
self
.
software_instance
.
revokeCertificate
()
self
.
assertEqual
(
self
.
software_instance
.
getDestinationReference
(),
None
)
self
.
assertEqual
(
self
.
software_instance
.
getSslKey
(),
None
)
self
.
assertEqual
(
self
.
software_instance
.
getSslCertificate
(),
None
)
self
.
assertRaises
(
ValueError
,
self
.
software_instance
.
revokeCertificate
)
def
test_revokeAndGenerateCertificate
(
self
):
self
.
login
()
destination_reference
=
self
.
software_instance
.
getDestinationReference
()
ssl_key
=
self
.
software_instance
.
getSslKey
()
ssl_certificate
=
self
.
software_instance
.
getSslCertificate
()
self
.
assertNotEqual
(
self
.
software_instance
.
getDestinationReference
(),
None
)
self
.
assertNotEqual
(
self
.
software_instance
.
getSslKey
(),
None
)
self
.
assertNotEqual
(
self
.
software_instance
.
getSslCertificate
(),
None
)
self
.
software_instance
.
revokeCertificate
()
self
.
software_instance
.
generateCertificate
()
self
.
assertNotEqual
(
self
.
software_instance
.
getDestinationReference
(),
None
)
self
.
assertNotEqual
(
self
.
software_instance
.
getSslKey
(),
None
)
self
.
assertNotEqual
(
self
.
software_instance
.
getSslCertificate
(),
None
)
self
.
assertNotEqual
(
self
.
software_instance
.
getDestinationReference
(),
destination_reference
)
self
.
assertNotEqual
(
self
.
software_instance
.
getSslKey
(),
ssl_key
)
self
.
assertNotEqual
(
self
.
software_instance
.
getSslCertificate
(),
ssl_certificate
)
destination_reference
=
self
.
software_instance
.
getDestinationReference
()
ssl_key
=
self
.
software_instance
.
getSslKey
()
ssl_certificate
=
self
.
software_instance
.
getSslCertificate
()
self
.
software_instance
.
revokeCertificate
()
self
.
software_instance
.
generateCertificate
()
self
.
assertNotEqual
(
self
.
software_instance
.
getDestinationReference
(),
None
)
self
.
assertNotEqual
(
self
.
software_instance
.
getSslKey
(),
None
)
self
.
assertNotEqual
(
self
.
software_instance
.
getSslCertificate
(),
None
)
self
.
assertNotEqual
(
self
.
software_instance
.
getDestinationReference
(),
destination_reference
)
self
.
assertNotEqual
(
self
.
software_instance
.
getSslKey
(),
ssl_key
)
self
.
assertNotEqual
(
self
.
software_instance
.
getSslCertificate
(),
ssl_certificate
)
master/bt5/slapos_erp5/PathTemplateItem/portal_alarms/slapos_renew_software_instance_certificate.xml
0 → 100644
View file @
b0a1e55b
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"Alarm"
module=
"erp5.portal_type"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
active_sense_method_id
</string>
</key>
<value>
<string>
Alarm_renewSoftwareInstanceCertificate
</string>
</value>
</item>
<item>
<key>
<string>
automatic_solve
</string>
</key>
<value>
<int>
0
</int>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
enabled
</string>
</key>
<value>
<int>
0
</int>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
slapos_renew_software_instance_certificate
</string>
</value>
</item>
<item>
<key>
<string>
periodicity_hour
</string>
</key>
<value>
<tuple>
<int>
3
</int>
</tuple>
</value>
</item>
<item>
<key>
<string>
periodicity_minute
</string>
</key>
<value>
<tuple>
<int>
0
</int>
</tuple>
</value>
</item>
<item>
<key>
<string>
periodicity_minute_frequency
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
periodicity_month
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
periodicity_month_day
</string>
</key>
<value>
<tuple>
<int>
3
</int>
</tuple>
</value>
</item>
<item>
<key>
<string>
periodicity_month_frequency
</string>
</key>
<value>
<int>
3
</int>
</value>
</item>
<item>
<key>
<string>
periodicity_start_date
</string>
</key>
<value>
<object>
<klass>
<global
name=
"DateTime"
module=
"DateTime.DateTime"
/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>
433814400.0
</float>
<string>
GMT
</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
periodicity_week
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
portal_type
</string>
</key>
<value>
<string>
Alarm
</string>
</value>
</item>
<item>
<key>
<string>
sense_method_id
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string>
SlapOS Renew Certificate for Software Instances
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_erp5/SkinTemplateItem/portal_skins/slapos_administration/Alarm_renewSoftwareInstanceCertificate.py
0 → 100644
View file @
b0a1e55b
# Example code:
# Import a standard function, and get the HTML request and response objects.
from
Products.PythonScripts.standard
import
html_quote
request
=
container
.
REQUEST
response
=
request
.
response
# Return a string identifying this script.
print
"This is the"
,
script
.
meta_type
,
'"%s"'
%
script
.
getId
(),
if
script
.
title
:
print
"(%s)"
%
html_quote
(
script
.
title
),
print
"in"
,
container
.
absolute_url
()
return
printed
master/bt5/slapos_erp5/SkinTemplateItem/portal_skins/slapos_administration/Alarm_renewSoftwareInstanceCertificate.xml
0 → 100644
View file @
b0a1e55b
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
Script_magic
</string>
</key>
<value>
<int>
3
</int>
</value>
</item>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key>
<string>
_asgns
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
name_container
</string>
</key>
<value>
<string>
container
</string>
</value>
</item>
<item>
<key>
<string>
name_context
</string>
</key>
<value>
<string>
context
</string>
</value>
</item>
<item>
<key>
<string>
name_m_self
</string>
</key>
<value>
<string>
script
</string>
</value>
</item>
<item>
<key>
<string>
name_subpath
</string>
</key>
<value>
<string>
traverse_subpath
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Alarm_renewSoftwareInstanceCertificate
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_erp5/SkinTemplateItem/portal_skins/slapos_administration/SoftwareInstance_renewCertificate.py
0 → 100644
View file @
b0a1e55b
if
(
context
.
getPortalType
()
==
"Software Instance"
and
\
context
.
getValiationState
()
==
"validated"
and
\
context
.
getSlapState
()
in
[
"start_requested"
,
"stop_requested"
]):
context
.
revokeCertificate
()
context
.
generateCertificate
()
master/bt5/slapos_erp5/SkinTemplateItem/portal_skins/slapos_administration/SoftwareInstance_renewCertificate.xml
0 → 100644
View file @
b0a1e55b
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
Script_magic
</string>
</key>
<value>
<int>
3
</int>
</value>
</item>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key>
<string>
_asgns
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
name_container
</string>
</key>
<value>
<string>
container
</string>
</value>
</item>
<item>
<key>
<string>
name_context
</string>
</key>
<value>
<string>
context
</string>
</value>
</item>
<item>
<key>
<string>
name_m_self
</string>
</key>
<value>
<string>
script
</string>
</value>
</item>
<item>
<key>
<string>
name_subpath
</string>
</key>
<value>
<string>
traverse_subpath
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
**kw
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
SoftwareInstance_renewCertificate
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_erp5/bt/template_path_list
View file @
b0a1e55b
...
...
@@ -6,6 +6,7 @@ portal_alarms/slapos_check_security_uid
portal_alarms/slapos_check_stored_broken_state
portal_alarms/slapos_erp5_cleanup_active_process
portal_alarms/slapos_erp5_cleanup_business_template
portal_alarms/slapos_renew_software_instance_certificate
portal_caches/erp5_session_cache/distributed_ram_cache
portal_categories/local_role_group/**
software_product_module/frontend
...
...
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