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
ab66c0c0
Commit
ab66c0c0
authored
Mar 31, 2023
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Plain Diff
slapos_subscription_request: A valid Assignment is required to be a valid user.
See merge request
nexedi/slapos.core!508
parents
b8011d42
5bf0d22b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
17 deletions
+16
-17
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_boostrapUserAccount.py
...iption_request/SubscriptionRequest_boostrapUserAccount.py
+1
-1
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_createUser.py
...os_subscription_request/SubscriptionRequest_createUser.py
+8
-10
master/bt5/slapos_subscription_request/TestTemplateItem/portal_components/test.erp5.testSlapOSSubscriptionSkins.py
...ortal_components/test.erp5.testSlapOSSubscriptionSkins.py
+7
-6
No files found.
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_boostrapUserAccount.py
View file @
ab66c0c0
...
...
@@ -53,7 +53,7 @@ if not login_list:
login
=
login_list
[
0
]
# Let's reset password if the user is his first login.
if
not
open_assignment_list
and
person
.
getUserId
()
==
login_list
[
0
].
getReference
():
if
"%s-FIRST-SUBSCRIBER-LOGIN"
%
person
.
getUserId
()
==
login_list
[
0
].
getReference
():
login
.
invalidate
()
login
.
setReference
(
person
.
getDefaultEmailText
())
reference
=
person
.
getDefaultEmailText
()
...
...
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_createUser.py
View file @
ab66c0c0
...
...
@@ -14,7 +14,6 @@ if person is not None:
# Already has login with this.
person
=
context
.
SubscriptionRequest_searchExistingUserByEmail
(
email
)
if
person
is
not
None
:
return
person
,
False
...
...
@@ -23,20 +22,19 @@ person = portal.person_module.newContent(
portal_type
=
"Person"
,
first_name
=
name
)
password
=
[
random
.
choice
(
string
.
upper
(
string
.
ascii_letters
)),
random
.
choice
(
string
.
lower
(
string
.
ascii_letters
)),
random
.
choice
(
string
.
digits
),
random
.
choice
(
"$!*#%$.;:,"
)]
chars
=
string
.
ascii_letters
+
string
.
digits
+
'!@#$%^&*()'
password
.
extend
([
random
.
choice
(
chars
)
for
_
in
range
(
26
)])
for
role
in
[
'member'
,
'subscriber'
]:
person
.
newContent
(
portal_type
=
'Assignment'
,
title
=
'%s Assignment'
%
(
role
.
capitalize
()),
role
=
role
).
open
(
comment
=
"Created by Subscription Request"
)
password
=
list
(
""
.
join
([
context
.
Person_generatePassword
(
15
,
5
,
4
)
for
_
in
range
(
random
.
randint
(
2
,
4
))]))
random
.
shuffle
(
password
)
login
=
person
.
newContent
(
portal_type
=
"ERP5 Login"
,
reference
=
person
.
getUserId
(),
password
=
''
.
join
(
password
))
reference
=
"%s-FIRST-SUBSCRIBER-LOGIN"
%
person
.
getUserId
(),
password
=
""
.
join
(
password
))
login
.
validate
()
...
...
master/bt5/slapos_subscription_request/TestTemplateItem/portal_components/test.erp5.testSlapOSSubscriptionSkins.py
View file @
ab66c0c0
...
...
@@ -294,7 +294,7 @@ class TestSubscriptionRequest_createUser(TestSubscriptionSkinsMixin):
erp5_login
=
[
i
for
i
in
person
.
searchFolder
(
portal_type
=
"ERP5 Login"
)][
0
]
self
.
assertEqual
(
person
.
getValidationState
(),
"draft"
)
self
.
assertEqual
(
erp5_login
.
getValidationState
(),
"validated"
)
self
.
assertEqual
(
erp5_login
.
getReference
(),
person
.
getUserId
())
self
.
assertEqual
(
erp5_login
.
getReference
(),
person
.
getUserId
()
+
"-FIRST-SUBSCRIBER-LOGIN"
)
class
Test0SubscriptionRequestModule_requestSubscriptionProxy
(
TestSubscriptionSkinsMixin
):
...
...
@@ -388,7 +388,8 @@ class TestSubscriptionRequest_applyCondition(TestSubscriptionSkinsMixin):
class
SubscriptionRequest_boostrapUserAccount
(
TestSubscriptionSkinsMixin
):
@
simulate
(
'SubscriptionRequest_sendAcceptedNotification'
,
'reference, password'
,
"""assert reference == context.getDefaultEmailText()
@
simulate
(
'SubscriptionRequest_sendAcceptedNotification'
,
'reference, password'
,
"""
assert reference == context.getDefaultEmailText(), "%s != %s" % (reference, context.getDefaultEmailText())
assert password"""
)
def
test_bootstrap_user
(
self
):
email
=
"abc%s@nexedi.com"
%
self
.
new_id
...
...
@@ -405,7 +406,7 @@ assert password""")
subscription_request
.
plan
()
self
.
assertEqual
(
len
(
person
.
searchFolder
(
portal_type
=
"Assignment"
,
validation_state
=
"open"
)),
0
)
validation_state
=
"open"
)),
2
)
subscription_request
.
SubscriptionRequest_boostrapUserAccount
()
...
...
@@ -430,7 +431,7 @@ assert password""")
erp5_login
=
login_list
[
0
]
self
.
assertEqual
(
erp5_login
.
getReference
(),
email
)
self
.
assertNotEqual
(
erp5_login
.
getPassword
(),
None
)
self
.
assertNotEqual
(
erp5_login
.
getPassword
(),
None
)
self
.
assertNotEqual
(
erp5_login
.
getPassword
(),
""
)
self
.
assertEqual
(
erp5_login
.
getValidationState
(),
"validated"
)
...
...
@@ -795,7 +796,7 @@ class TestSubscriptionRequest_sendAcceptedNotification(TestSubscriptionSkinsMixi
self
.
assertEqual
(
event
.
getContentType
(),
'text/html'
)
self
.
assertEqual
(
event
.
getTextContent
(),
'%s %s'
%
(
person
.
getTitle
(),
person
.
getUserId
()))
event
.
getTextContent
(),
'%s %s
-FIRST-SUBSCRIBER-LOGIN
'
%
(
person
.
getTitle
(),
person
.
getUserId
()))
def
test_send_notification_with_password
(
self
):
...
...
@@ -824,7 +825,7 @@ class TestSubscriptionRequest_sendAcceptedNotification(TestSubscriptionSkinsMixi
self
.
assertEqual
(
event
.
getContentType
(),
'text/html'
)
self
.
assertEqual
(
event
.
getTextContent
(),
'%s %s password'
%
(
person
.
getTitle
(),
person
.
getUserId
()))
event
.
getTextContent
(),
'%s %s password'
%
(
person
.
getTitle
(),
person
.
getUserId
()
+
"-FIRST-SUBSCRIBER-LOGIN"
))
class
TestSubscriptionRequest_notifyInstanceIsReady
(
TestSubscriptionSkinsMixin
):
...
...
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