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
Boxiang Sun
slapos.core
Commits
519e4138
Commit
519e4138
authored
Jun 15, 2020
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_jio: Add test for Person_newLogin
parent
5867f920
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
4 deletions
+63
-4
master/bt5/slapos_jio/SkinTemplateItem/portal_skins/slapos_hal_json_style/Person_newLogin.py
...tem/portal_skins/slapos_hal_json_style/Person_newLogin.py
+1
-1
master/bt5/slapos_jio/TestTemplateItem/portal_components/test.erp5.testSlapOSHalJsonStyleSkins.py
...ortal_components/test.erp5.testSlapOSHalJsonStyleSkins.py
+62
-3
No files found.
master/bt5/slapos_jio/SkinTemplateItem/portal_skins/slapos_hal_json_style/Person_newLogin.py
View file @
519e4138
...
...
@@ -5,7 +5,7 @@ portal = context.getPortalObject()
person
=
portal
.
portal_membership
.
getAuthenticatedMember
().
getUserValue
()
if
person
.
getUid
()
!=
context
.
getUid
(
):
if
(
person
is
None
)
or
(
person
.
getUid
()
!=
context
.
getUid
()
):
raise
Unauthorized
(
"You are not allowed to create login to a different user"
)
if
context
.
Person_testLoginExistence
(
reference
=
reference
):
...
...
master/bt5/slapos_jio/TestTemplateItem/portal_components/test.erp5.testSlapOSHalJsonStyleSkins.py
View file @
519e4138
...
...
@@ -22,6 +22,7 @@
##############################################################################
from
erp5.component.test.SlapOSTestCaseMixin
import
\
SlapOSTestCaseMixinWithAbort
,
simulate
from
zExceptions
import
Unauthorized
from
App.Common
import
rfc1123_date
from
DateTime
import
DateTime
import
json
...
...
@@ -51,8 +52,8 @@ class TestSlapOSHalJsonStyleMixin(SlapOSTestCaseMixinWithAbort):
memcached_dict
=
self
.
portal
.
Base_getSlapToolMemcachedDict
()
memcached_dict
[
reference
]
=
value
def
_makePerson
(
self
):
person_user
=
self
.
makePerson
()
def
_makePerson
(
self
,
**
kw
):
person_user
=
self
.
makePerson
(
**
kw
)
self
.
tic
()
self
.
changeSkin
(
'Hal'
)
return
person_user
...
...
@@ -575,4 +576,62 @@ class TestProject_getNewsDict(TestSlapOSHalJsonStyleMixin):
expected_news_dict
=
{
'computer'
:
{},
'partition'
:
{}}
self
.
assertEquals
(
news_dict
,
expected_news_dict
)
# Ensure it don't raise error when converting to JSON
json
.
dumps
(
news_dict
)
\ No newline at end of file
json
.
dumps
(
news_dict
)
class
TestPerson_newLogin
(
TestSlapOSHalJsonStyleMixin
):
def
test_Person_newLogin_as_superuser
(
self
):
person
=
self
.
_makePerson
(
user
=
0
)
self
.
assertEqual
(
0
,
len
(
person
.
objectValues
(
portal_type
=
"ERP5 Login"
)))
self
.
assertRaises
(
Unauthorized
,
person
.
Person_newLogin
,
reference
=
"a"
,
password
=
"b"
)
def
test_Person_newLogin_different_user
(
self
):
person
=
self
.
_makePerson
(
user
=
1
)
self
.
assertEqual
(
1
,
len
(
person
.
objectValues
(
portal_type
=
"ERP5 Login"
)))
personx
=
self
.
_makePerson
(
user
=
1
)
self
.
assertEqual
(
1
,
len
(
personx
.
objectValues
(
portal_type
=
"ERP5 Login"
)))
self
.
login
(
person
.
getUserId
())
self
.
assertRaises
(
Unauthorized
,
personx
.
Person_newLogin
,
reference
=
"a"
,
password
=
"b"
)
def
test_Person_newLogin_duplicated
(
self
):
person
=
self
.
_makePerson
(
user
=
1
)
self
.
assertEqual
(
1
,
len
(
person
.
objectValues
(
portal_type
=
"ERP5 Login"
)))
personx
=
self
.
_makePerson
(
user
=
1
)
login_list
=
personx
.
objectValues
(
portal_type
=
"ERP5 Login"
)
self
.
assertEqual
(
1
,
len
(
login_list
))
login
=
login_list
[
0
].
getReference
()
self
.
tic
()
self
.
login
(
person
.
getUserId
())
result
=
json
.
loads
(
person
.
Person_newLogin
(
reference
=
login
,
password
=
"b"
))
self
.
assertEqual
(
self
.
portal
.
REQUEST
.
RESPONSE
.
getStatus
(),
406
)
self
.
assertEqual
(
result
,
'Login already exists'
)
def
test_Person_newLogin_dont_comply
(
self
):
person
=
self
.
_makePerson
(
user
=
1
)
self
.
assertEqual
(
1
,
len
(
person
.
objectValues
(
portal_type
=
"ERP5 Login"
)))
self
.
login
(
person
.
getUserId
())
result
=
json
.
loads
(
person
.
Person_newLogin
(
reference
=
"a"
,
password
=
"b"
))
self
.
assertEqual
(
self
.
portal
.
REQUEST
.
RESPONSE
.
getStatus
(),
406
)
self
.
assertEqual
(
result
,
'Password value doest not comply with password policy'
)
def
test_Person_newLogin
(
self
):
person
=
self
.
_makePerson
(
user
=
1
)
self
.
assertEqual
(
1
,
len
(
person
.
objectValues
(
portal_type
=
"ERP5 Login"
)))
self
.
login
(
person
.
getUserId
())
result
=
json
.
loads
(
person
.
Person_newLogin
(
reference
=
"SOMEUNIQUEUSER%s"
%
self
.
generateNewId
(),
password
=
person
.
Person_generatePassword
()))
self
.
assertEqual
(
self
.
portal
.
REQUEST
.
RESPONSE
.
getStatus
(),
200
)
self
.
assertIn
(
person
.
getRelativeUrl
(),
result
)
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