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
Labels
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Rafael Monnerat
slapos.core
Commits
d00185f7
Commit
d00185f7
authored
Dec 27, 2021
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_cloud: Added test for organisation_slap_interface_workflow
parent
a42e9af7
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
359 additions
and
109 deletions
+359
-109
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudOrganisationSlapInterfaceWorkflow.py
....erp5.testSlapOSCloudOrganisationSlapInterfaceWorkflow.py
+213
-0
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudOrganisationSlapInterfaceWorkflow.xml
...erp5.testSlapOSCloudOrganisationSlapInterfaceWorkflow.xml
+133
-0
master/bt5/slapos_cloud/WorkflowTemplateItem/portal_workflow/organisation_slap_interface_workflow/script_Organisation_acceptInvitation.py
...nterface_workflow/script_Organisation_acceptInvitation.py
+9
-7
master/bt5/slapos_cloud/WorkflowTemplateItem/portal_workflow/organisation_slap_interface_workflow/script_Organisation_approveRegistration.py
...rface_workflow/script_Organisation_approveRegistration.py
+3
-0
master/bt5/slapos_cloud/WorkflowTemplateItem/portal_workflow/organisation_slap_interface_workflow/script_Organisation_generateInvitation.py
...erface_workflow/script_Organisation_generateInvitation.py
+0
-24
master/bt5/slapos_cloud/WorkflowTemplateItem/portal_workflow/organisation_slap_interface_workflow/script_Organisation_generateInvitation.xml
...rface_workflow/script_Organisation_generateInvitation.xml
+0
-78
master/bt5/slapos_cloud/bt/template_test_id_list
master/bt5/slapos_cloud/bt/template_test_id_list
+1
-0
No files found.
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudOrganisationSlapInterfaceWorkflow.py
0 → 100644
View file @
d00185f7
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved.
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from
erp5.component.test.SlapOSTestCaseMixin
import
SlapOSTestCaseMixin
from
zExceptions
import
Unauthorized
import
transaction
class
TestSlapOSCoreOrganisationSlapInterfaceWorkflow
(
SlapOSTestCaseMixin
):
def
afterSetUp
(
self
):
SlapOSTestCaseMixin
.
afterSetUp
(
self
)
portal
=
self
.
getPortalObject
()
person_user
=
self
.
makePerson
()
self
.
tic
()
# Login as new user
self
.
login
(
person_user
.
getUserId
())
new_person
=
self
.
portal
.
portal_membership
.
getAuthenticatedMember
().
getUserValue
()
self
.
assertEqual
(
person_user
.
getRelativeUrl
(),
new_person
.
getRelativeUrl
())
self
.
organisation
=
portal
.
organisation_module
.
newContent
(
portal_type
=
"Organisation"
)
self
.
tic
()
def
beforeTearDown
(
self
):
transaction
.
abort
()
def
test_organisation_approveRegistration_with_reference
(
self
):
reference
=
"TEST-%s"
%
self
.
generateNewId
()
self
.
organisation
.
setReference
(
reference
)
self
.
organisation
.
approveRegistration
()
self
.
assertEqual
(
self
.
organisation
.
getReference
(),
reference
)
def
test_organisation_approveRegistration_already_validated
(
self
):
# Login as admin since user cannot re-approve a validated organisation
self
.
login
()
self
.
organisation
.
setReference
(
None
)
self
.
organisation
.
validate
()
# Don't raise if organisation is validated
self
.
assertEqual
(
self
.
organisation
.
approveRegistration
(),
None
)
def
test_organisation_approveRegistration_site
(
self
,
role
=
"host"
,
expected_prefix
=
"SITE-"
):
person
=
self
.
portal
.
portal_membership
.
getAuthenticatedMember
().
getUserValue
()
self
.
organisation
.
edit
(
role
=
role
)
self
.
organisation
.
approveRegistration
()
self
.
tic
()
self
.
logout
()
self
.
login
(
person
.
getUserId
())
self
.
assertEqual
(
self
.
organisation
.
getValidationState
(),
'validated'
)
self
.
assertTrue
(
self
.
organisation
.
getReference
().
startswith
(
expected_prefix
),
"Reference don't start with %s : %s "
%
(
expected_prefix
,
self
.
organisation
.
getReference
()))
assignment_list
=
[
i
for
i
in
person
.
objectValues
(
portal_type
=
"Assignment"
)
if
i
.
getDestinationValue
()
==
self
.
organisation
]
self
.
assertEqual
(
len
(
assignment_list
),
1
)
self
.
assertEqual
(
assignment_list
[
0
].
getValidationState
(),
'open'
)
self
.
assertIn
(
"Assigment for Organisation "
,
assignment_list
[
0
].
getTitle
())
def
test_organisation_approveRegistration_organisation
(
self
):
self
.
test_organisation_approveRegistration_site
(
role
=
"client"
,
expected_prefix
=
"O-"
)
def
test_organisation_leaveOrganisation_no_user
(
self
):
self
.
login
()
self
.
assertRaises
(
Unauthorized
,
self
.
organisation
.
leaveOrganisation
)
def
test_organisation_leaveOrganisation_after_join
(
self
):
person
=
self
.
portal
.
portal_membership
.
getAuthenticatedMember
().
getUserValue
()
# Just make things fast, by using the API tested above
self
.
organisation
.
approveRegistration
()
self
.
tic
()
self
.
logout
()
self
.
login
(
person
.
getUserId
())
assignment_list
=
[
i
for
i
in
person
.
objectValues
(
portal_type
=
"Assignment"
)
if
i
.
getDestinationValue
()
==
self
.
organisation
]
self
.
assertEqual
(
len
(
assignment_list
),
1
)
self
.
assertEqual
(
assignment_list
[
0
].
getValidationState
(),
'open'
)
self
.
organisation
.
leaveOrganisation
()
self
.
tic
()
self
.
login
()
assignment_list
=
[
i
for
i
in
person
.
objectValues
(
portal_type
=
"Assignment"
)
if
i
.
getDestinationValue
()
==
self
.
organisation
]
self
.
assertEqual
(
len
(
assignment_list
),
1
)
self
.
assertEqual
(
assignment_list
[
0
].
getValidationState
(),
'closed'
)
def
test_organisation_acceptInvitation_no_invitation_token
(
self
):
self
.
assertRaises
(
TypeError
,
self
.
organisation
.
acceptInvitation
)
def
test_organisation_acceptInvitation_no_token_dont_exist
(
self
):
self
.
assertRaises
(
ValueError
,
self
.
organisation
.
acceptInvitation
,
invitation_token
=
"DONOTEXIST"
)
def
test_organisation_acceptInvitation
(
self
):
person
=
self
.
portal
.
portal_membership
.
getAuthenticatedMember
().
getUserValue
()
self
.
login
()
token
=
self
.
portal
.
invitation_token_module
.
newContent
(
portal_type
=
"Invitation Token"
)
token_id
=
token
.
getId
()
# User is None
self
.
assertRaises
(
ValueError
,
self
.
organisation
.
acceptInvitation
,
invitation_token
=
token_id
)
# Not validated yet
self
.
login
(
person
.
getUserId
())
self
.
assertRaises
(
ValueError
,
self
.
organisation
.
acceptInvitation
,
invitation_token
=
token_id
)
self
.
login
()
token
.
validate
()
token
.
setSourceValue
(
person
)
self
.
login
(
person
.
getUserId
())
# Not used by the owner
self
.
assertRaises
(
ValueError
,
self
.
organisation
.
acceptInvitation
,
invitation_token
=
token_id
)
self
.
login
()
token
.
setSourceValue
(
None
)
self
.
login
(
person
.
getUserId
())
self
.
organisation
.
acceptInvitation
(
invitation_token
=
token_id
)
self
.
tic
()
self
.
login
()
assignment_list
=
[
i
for
i
in
person
.
objectValues
(
portal_type
=
"Assignment"
)
if
i
.
getDestinationValue
()
==
self
.
organisation
]
self
.
assertEqual
(
len
(
assignment_list
),
1
)
self
.
assertEqual
(
assignment_list
[
0
].
getValidationState
(),
'open'
)
self
.
assertEqual
(
token
.
getValidationState
(),
"invalidated"
)
def
test_organisation_acceptInvitation_already_member
(
self
):
person
=
self
.
portal
.
portal_membership
.
getAuthenticatedMember
().
getUserValue
()
self
.
organisation
.
approveRegistration
()
self
.
tic
()
self
.
login
()
assignment_list
=
[
i
for
i
in
person
.
objectValues
(
portal_type
=
"Assignment"
)
if
i
.
getDestinationValue
()
==
self
.
organisation
]
self
.
assertEqual
(
len
(
assignment_list
),
1
)
self
.
assertEqual
(
assignment_list
[
0
].
getValidationState
(),
'open'
)
token
=
self
.
portal
.
invitation_token_module
.
newContent
(
portal_type
=
"Invitation Token"
)
token_id
=
token
.
getId
()
# User is None
self
.
assertRaises
(
ValueError
,
self
.
organisation
.
acceptInvitation
,
invitation_token
=
token_id
)
# Not validated yet
self
.
login
(
person
.
getUserId
())
self
.
assertRaises
(
ValueError
,
self
.
organisation
.
acceptInvitation
,
invitation_token
=
token_id
)
self
.
login
()
token
.
validate
()
token
.
setSourceValue
(
person
)
self
.
login
(
person
.
getUserId
())
# Not used by the owner
self
.
assertRaises
(
ValueError
,
self
.
organisation
.
acceptInvitation
,
invitation_token
=
token_id
)
self
.
login
()
token
.
setSourceValue
(
None
)
self
.
login
(
person
.
getUserId
())
self
.
organisation
.
acceptInvitation
(
invitation_token
=
token_id
)
self
.
tic
()
self
.
login
()
assignment_list
=
[
i
for
i
in
person
.
objectValues
(
portal_type
=
"Assignment"
)
if
i
.
getDestinationValue
()
==
self
.
organisation
]
self
.
assertEqual
(
len
(
assignment_list
),
1
)
self
.
assertEqual
(
assignment_list
[
0
].
getValidationState
(),
'open'
)
self
.
assertEqual
(
token
.
getValidationState
(),
"invalidated"
)
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudOrganisationSlapInterfaceWorkflow.xml
0 → 100644
View file @
d00185f7
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"Test Component"
module=
"erp5.portal_type"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_recorded_property_dict
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</string>
</persistent>
</value>
</item>
<item>
<key>
<string>
default_reference
</string>
</key>
<value>
<string>
testSlapOSCloudOrganisationSlapInterfaceWorkflow
</string>
</value>
</item>
<item>
<key>
<string>
default_source_reference
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
test.erp5.testSlapOSCloudOrganisationSlapInterfaceWorkflow
</string>
</value>
</item>
<item>
<key>
<string>
portal_type
</string>
</key>
<value>
<string>
Test Component
</string>
</value>
</item>
<item>
<key>
<string>
sid
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
text_content_error_message
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
text_content_warning_message
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
version
</string>
</key>
<value>
<string>
erp5
</string>
</value>
</item>
<item>
<key>
<string>
workflow_history
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAM=
</string>
</persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"2"
aka=
"AAAAAAAAAAI="
>
<pickle>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
data
</string>
</key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"3"
aka=
"AAAAAAAAAAM="
>
<pickle>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
data
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
component_validation_workflow
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAQ=
</string>
</persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"4"
aka=
"AAAAAAAAAAQ="
>
<pickle>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.Workflow"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_log
</string>
</key>
<value>
<list>
<dictionary>
<item>
<key>
<string>
action
</string>
</key>
<value>
<string>
validate
</string>
</value>
</item>
<item>
<key>
<string>
validation_state
</string>
</key>
<value>
<string>
validated
</string>
</value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_cloud/WorkflowTemplateItem/portal_workflow/organisation_slap_interface_workflow/script_Organisation_acceptInvitation.py
View file @
d00185f7
project
=
state_change
[
'object'
]
portal
=
project
.
getPortalObject
()
organisation
=
state_change
[
'object'
]
portal
=
organisation
.
getPortalObject
()
person
=
portal
.
portal_membership
.
getAuthenticatedMember
().
getUserValue
()
# Get required arguments
...
...
@@ -10,7 +10,7 @@ kwargs = state_change.kwargs
try
:
token_id
=
kwargs
[
'invitation_token'
]
except
KeyError
:
raise
TypeError
(
"
Project
_acceptInvitation takes exactly 1 argument"
)
raise
TypeError
(
"
Organisation
_acceptInvitation takes exactly 1 argument"
)
try
:
invitation_token
=
portal
.
invitation_token_module
[
token_id
]
...
...
@@ -33,16 +33,18 @@ if invitation_token.getSourceValue() == person:
message_str
=
"Invitation Token cannot be used by the same user that generated the token!"
raise
ValueError
(
message_str
)
for
assignment
in
person
.
objectValues
(
portal_type
=
"Assignment"
):
if
assignment
.
get
DestinationProject
()
==
project
.
getRelativeUrl
()
and
\
assignment
.
getValidationState
()
==
"open"
:
if
assignment
.
get
Subordination
()
==
organisation
.
getRelativeUrl
()
and
\
assignment
.
getValidationState
()
==
"open"
:
invitation_token
.
invalidate
(
comment
=
"User already has assignment to the Person"
)
break
if
invitation_token
.
getValidationState
()
==
"validated"
:
person
.
newContent
(
title
=
"Assigment for
Project %s"
%
project
.
getTitle
(
),
title
=
"Assigment for
Organisation (%s) %s"
%
(
organisation
.
getRole
(),
organisation
.
getTitle
()
),
portal_type
=
"Assignment"
,
destination_project_value
=
project
).
open
()
subordination_value
=
organisation
,
destination_value
=
organisation
).
open
()
invitation_token
.
invalidate
()
master/bt5/slapos_cloud/WorkflowTemplateItem/portal_workflow/organisation_slap_interface_workflow/script_Organisation_approveRegistration.py
View file @
d00185f7
...
...
@@ -14,6 +14,9 @@ if organisation.getReference() in [None, ""]:
organisation
.
setReference
(
reference
)
if
organisation
.
getValidationState
()
!=
"draft"
:
return
organisation
.
validate
()
# Get the user id of the context owner.
...
...
master/bt5/slapos_cloud/WorkflowTemplateItem/portal_workflow/organisation_slap_interface_workflow/script_Organisation_generateInvitation.py
deleted
100644 → 0
View file @
a42e9af7
project
=
state_change
[
'object'
]
portal
=
context
.
getPortalObject
()
person
=
portal
.
portal_membership
.
getAuthenticatedMember
().
getUserValue
()
request_method
=
"POST"
script_name
=
"Project_acceptInvitation"
web_site
=
context
.
getWebSiteValue
()
if
web_site
is
None
:
web_site
=
portal
request_url
=
"%s/%s/%s"
%
(
web_site
.
absolute_url
(),
project
.
getRelativeUrl
(),
script_name
)
# Maybe it would be better to use another portal_type
token
=
portal
.
invitation_token_module
.
newContent
(
portal_type
=
"Invitation Token"
,
source_value
=
person
,
url_string
=
request_url
,
url_method
=
request_method
)
token
.
validate
()
context
.
REQUEST
.
set
(
'request_token_id'
,
token
.
getId
())
context
.
REQUEST
.
set
(
'request_token_url_string'
,
request_url
)
master/bt5/slapos_cloud/WorkflowTemplateItem/portal_workflow/organisation_slap_interface_workflow/script_Organisation_generateInvitation.xml
deleted
100644 → 0
View file @
a42e9af7
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"Workflow Script"
module=
"erp5.portal_type"
/>
</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>
state_change
</string>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
script_Organisation_generateInvitation
</string>
</value>
</item>
<item>
<key>
<string>
portal_type
</string>
</key>
<value>
<string>
Workflow Script
</string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<none/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_cloud/bt/template_test_id_list
View file @
d00185f7
...
...
@@ -6,6 +6,7 @@ test.erp5.testSlapOSCloudPersonSlapInterfaceWorkflow
test.erp5.testSlapOSCloudComputeNodeSlapInterfaceWorkflow
test.erp5.testSlapOSCloudInstanceSlapInterfaceWorkflow
test.erp5.testSlapOSCloudProjectSlapInterfaceWorkflow
test.erp5.testSlapOSCloudOrganisationSlapInterfaceWorkflow
test.erp5.testSlapOSCloudSecurityGroup
test.erp5.testSlapOSCloudConstraint
test.erp5.testSlapOSCloudUpgrader
...
...
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