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
1
Merge Requests
1
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
Romain Courteaud
slapos.core
Commits
e23cbb59
Commit
e23cbb59
authored
Jan 09, 2023
by
Romain Courteaud
🐙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_cloud: only project admin can create Computer Network
parent
6d1c7407
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
226 deletions
+9
-226
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudNetworkSlapInterfaceWorkflow.py
.../test.erp5.testSlapOSCloudNetworkSlapInterfaceWorkflow.py
+6
-202
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudNetworkSlapInterfaceWorkflow.xml
...test.erp5.testSlapOSCloudNetworkSlapInterfaceWorkflow.xml
+3
-24
No files found.
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudNetworkSlapInterfaceWorkflow.py
View file @
e23cbb59
...
...
@@ -19,8 +19,6 @@
#
##############################################################################
from
erp5.component.test.SlapOSTestCaseMixin
import
SlapOSTestCaseMixin
from
time
import
sleep
from
zExceptions
import
Unauthorized
import
transaction
class
TestSlapOSCoreNetworkSlapInterfaceWorkflow
(
SlapOSTestCaseMixin
):
...
...
@@ -28,8 +26,10 @@ class TestSlapOSCoreNetworkSlapInterfaceWorkflow(SlapOSTestCaseMixin):
def
afterSetUp
(
self
):
SlapOSTestCaseMixin
.
afterSetUp
(
self
)
portal
=
self
.
getPortalObject
()
person_user
=
self
.
makePerson
()
self
.
project
=
self
.
addProject
()
person_user
=
self
.
makePerson
(
self
.
project
)
self
.
addProjectProductionManagerAssignment
(
person_user
,
self
.
project
)
self
.
tic
()
# Login as new user
...
...
@@ -39,7 +39,8 @@ class TestSlapOSCoreNetworkSlapInterfaceWorkflow(SlapOSTestCaseMixin):
self
.
assertEqual
(
person_user
.
getRelativeUrl
(),
new_person
.
getRelativeUrl
())
self
.
network
=
portal
.
computer_network_module
.
newContent
(
portal_type
=
"Computer Network"
portal_type
=
"Computer Network"
,
follow_up_value
=
self
.
project
)
self
.
tic
()
self
.
assertEqual
(
...
...
@@ -62,200 +63,3 @@ class TestSlapOSCoreNetworkSlapInterfaceWorkflow(SlapOSTestCaseMixin):
self
.
network
.
validate
()
# Don't raise if network is validated
self
.
assertEqual
(
self
.
network
.
approveRegistration
(),
None
)
def
_makeProject
(
self
):
project
=
self
.
portal
.
project_module
.
newContent
()
project
.
edit
(
reference
=
"TESTPROJ-%s"
%
project
.
getId
())
project
.
validate
()
self
.
tic
()
return
project
def
_makeOrganisation
(
self
):
organisation
=
self
.
portal
.
organisation_module
.
newContent
()
organisation
.
edit
(
reference
=
"TESTSITE-%s"
%
organisation
.
getId
())
organisation
.
validate
()
self
.
tic
()
return
organisation
def
test_ComputerNetwork_requestTransfer_project
(
self
):
source_administrator
=
self
.
portal
.
portal_membership
.
getAuthenticatedMember
().
getUserValue
()
self
.
network
.
setSourceAdministrationValue
(
source_administrator
)
self
.
login
()
self
.
network
.
approveRegistration
()
project
=
self
.
_makeProject
()
other_project
=
self
.
_makeProject
()
self
.
tic
()
self
.
login
(
source_administrator
.
getUserId
())
self
.
assertEqual
(
self
.
network
.
Item_getCurrentProjectValue
(),
None
)
self
.
assertEqual
(
self
.
network
.
Item_getCurrentOwnerValue
(),
None
)
# Place in a project
self
.
network
.
requestTransfer
(
destination_section
=
None
,
destination_project
=
project
.
getRelativeUrl
())
self
.
tic
()
self
.
assertEqual
(
self
.
network
.
Item_getCurrentProjectValue
(),
project
)
self
.
assertEqual
(
self
.
network
.
Item_getCurrentOwnerValue
(),
source_administrator
)
self
.
assertEqual
(
1
,
len
(
self
.
network
.
getAggregateRelatedList
(
portal_type
=
"Internal Packing List Line"
))
)
self
.
login
(
source_administrator
.
getUserId
())
# We don't remove from Project if destination project is not provided
self
.
network
.
requestTransfer
(
destination_project
=
None
,
destination_section
=
None
)
self
.
tic
()
self
.
assertEqual
(
self
.
network
.
Item_getCurrentProjectValue
(),
project
)
self
.
assertEqual
(
self
.
network
.
Item_getCurrentOwnerValue
(),
source_administrator
)
self
.
assertEqual
(
2
,
len
(
self
.
network
.
getAggregateRelatedList
(
portal_type
=
"Internal Packing List Line"
))
)
# Ensure that we don't have 2 new Internal Packing lists in the same second
sleep
(
1
)
# Place in another project
self
.
network
.
requestTransfer
(
destination_section
=
None
,
destination_project
=
other_project
.
getRelativeUrl
())
self
.
tic
()
self
.
assertEqual
(
self
.
network
.
Item_getCurrentProjectValue
(),
other_project
)
self
.
assertEqual
(
self
.
network
.
Item_getCurrentOwnerValue
(),
source_administrator
)
self
.
assertEqual
(
3
,
len
(
self
.
network
.
getAggregateRelatedList
(
portal_type
=
"Internal Packing List Line"
))
)
self
.
login
(
source_administrator
.
getUserId
())
# Ensure that we don't have 2 new Internal Packing lists in the same second
sleep
(
1
)
# We don't remove from Project if destination project is not provided
self
.
network
.
requestTransfer
(
destination_project
=
None
,
destination_section
=
None
)
self
.
tic
()
self
.
assertEqual
(
self
.
network
.
Item_getCurrentProjectValue
(),
other_project
)
self
.
assertEqual
(
self
.
network
.
Item_getCurrentOwnerValue
(),
source_administrator
)
self
.
assertEqual
(
4
,
len
(
self
.
network
.
getAggregateRelatedList
(
portal_type
=
"Internal Packing List Line"
))
)
def
test_ComputerNetwork_requestTransfer_owner
(
self
):
source_administrator
=
self
.
portal
.
portal_membership
.
getAuthenticatedMember
().
getUserValue
()
self
.
network
.
setSourceAdministrationValue
(
source_administrator
)
self
.
login
()
self
.
network
.
approveRegistration
()
organisation
=
self
.
_makeOrganisation
()
other_organisation
=
self
.
_makeOrganisation
()
self
.
tic
()
self
.
login
(
source_administrator
.
getUserId
())
self
.
assertEqual
(
self
.
network
.
Item_getCurrentProjectValue
(),
None
)
self
.
assertEqual
(
self
.
network
.
Item_getCurrentOwnerValue
(),
None
)
self
.
network
.
requestTransfer
(
destination_project
=
None
,
destination_section
=
organisation
.
getRelativeUrl
())
self
.
tic
()
self
.
assertEqual
(
self
.
network
.
Item_getCurrentProjectValue
(),
None
)
self
.
assertEqual
(
self
.
network
.
Item_getCurrentOwnerValue
(),
organisation
)
self
.
assertEqual
(
1
,
len
(
self
.
network
.
getAggregateRelatedList
(
portal_type
=
"Internal Packing List Line"
))
)
self
.
login
(
source_administrator
.
getUserId
())
# Ensure that we don't have 2 new Internal Packing lists in the same second
sleep
(
1
)
# We don't remove from Project if destination project is not provided
self
.
network
.
requestTransfer
(
destination_project
=
None
,
destination_section
=
None
)
self
.
tic
()
self
.
assertEqual
(
self
.
network
.
Item_getCurrentProjectValue
(),
None
)
self
.
assertEqual
(
self
.
network
.
Item_getCurrentOwnerValue
(),
organisation
)
# Ensure that we don't have 2 new Internal Packing lists in the same second
sleep
(
1
)
# Place in another project
self
.
network
.
requestTransfer
(
destination_project
=
None
,
destination_section
=
other_organisation
.
getRelativeUrl
())
self
.
tic
()
self
.
assertEqual
(
3
,
len
(
self
.
network
.
getAggregateRelatedList
(
portal_type
=
"Internal Packing List Line"
))
)
self
.
assertEqual
(
self
.
network
.
Item_getCurrentProjectValue
(),
None
)
self
.
assertEqual
(
self
.
network
.
Item_getCurrentOwnerValue
(),
other_organisation
)
self
.
assertEqual
(
3
,
len
(
self
.
network
.
getAggregateRelatedList
(
portal_type
=
"Internal Packing List Line"
))
)
self
.
login
(
source_administrator
.
getUserId
())
# Ensure that we don't have 2 new Internal Packing lists in the same second
sleep
(
1
)
# We don't remove from Project if destination project is not provided
self
.
network
.
requestTransfer
(
destination_project
=
None
,
destination_section
=
None
)
self
.
tic
()
self
.
assertEqual
(
self
.
network
.
Item_getCurrentProjectValue
(),
None
)
self
.
assertEqual
(
self
.
network
.
Item_getCurrentOwnerValue
(),
other_organisation
)
self
.
assertEqual
(
4
,
len
(
self
.
network
.
getAggregateRelatedList
(
portal_type
=
"Internal Packing List Line"
))
)
def
test_ComputerNetwork_requestTransfer_Unauthorized
(
self
):
self
.
network
.
approveRegistration
()
self
.
login
()
self
.
assertRaises
(
Unauthorized
,
self
.
network
.
requestTransfer
)
source_administrator
=
self
.
makePerson
(
user
=
1
)
self
.
assertEqual
(
1
,
len
(
source_administrator
.
objectValues
(
portal_type
=
"ERP5 Login"
)))
self
.
login
(
source_administrator
.
getUserId
())
self
.
assertRaises
(
Unauthorized
,
self
.
network
.
requestTransfer
)
self
.
login
()
other_user
=
self
.
makePerson
(
user
=
1
)
self
.
assertEqual
(
1
,
len
(
other_user
.
objectValues
(
portal_type
=
"ERP5 Login"
)))
self
.
network
.
setSourceAdministrationValue
(
source_administrator
)
self
.
tic
()
self
.
assertRaises
(
Unauthorized
,
self
.
network
.
requestTransfer
)
self
.
login
(
other_user
.
getUserId
())
self
.
assertRaises
(
Unauthorized
,
self
.
network
.
requestTransfer
)
self
.
login
(
source_administrator
.
getUserId
())
self
.
network
.
requestTransfer
(
destination_project
=
None
,
destination_section
=
None
)
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudNetworkSlapInterfaceWorkflow.xml
View file @
e23cbb59
...
...
@@ -6,12 +6,6 @@
</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>
testSlapOSCloudNetworkSlapInterfaceWorkflow
</string>
</value>
...
...
@@ -61,28 +55,13 @@
<item>
<key>
<string>
workflow_history
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
M
=
</string>
</persistent>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
I
=
</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>
...
...
@@ -95,7 +74,7 @@
<item>
<key>
<string>
component_validation_workflow
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
Q
=
</string>
</persistent>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
M
=
</string>
</persistent>
</value>
</item>
</dictionary>
...
...
@@ -104,7 +83,7 @@
</dictionary>
</pickle>
</record>
<record
id=
"
4"
aka=
"AAAAAAAAAAQ
="
>
<record
id=
"
3"
aka=
"AAAAAAAAAAM
="
>
<pickle>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.Workflow"
/>
</pickle>
...
...
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