Commit d1426dcc authored by Roque Porchetto's avatar Roque Porchetto Committed by Roque

erp5_scalability_test: security guard for scripts and user script fixing

parent 4b22ac7a
...@@ -52,6 +52,12 @@ ...@@ -52,6 +52,12 @@
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item>
<key> <string>guard</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>ERP5Site_bootstrapScalabilityTest</string> </value> <value> <string>ERP5Site_bootstrapScalabilityTest</string> </value>
...@@ -59,4 +65,21 @@ ...@@ -59,4 +65,21 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Guard" module="Products.DCWorkflow.Guard"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData> </ZopeData>
# Script that creates "user_number" user for scalabiility tests: # Script that creates "user_quantity" user for scalabiility tests:
# creates and validates persons # creates and validates persons
# adds assignment and starts it # adds assignment and starts it
# creates user (login credentials) # creates user (login credentials)
...@@ -26,8 +26,8 @@ if configurator == None or not configurator.contentValues(portal_type='Configura ...@@ -26,8 +26,8 @@ if configurator == None or not configurator.contentValues(portal_type='Configura
error_message = "Could not find the scalability business configuration object. Standard configuration not installed?" error_message = "Could not find the scalability business configuration object. Standard configuration not installed?"
return {'status_code' : 1, 'error_message': error_message, 'password' : None } return {'status_code' : 1, 'error_message': error_message, 'password' : None }
user_number = request.get('user_number') user_quantity = request.get('user_quantity')
if user_number is None: return {'status_code' : 1, 'error_message': "Parameter 'user_number' is required.", 'password' : None } if user_quantity is None: return {'status_code' : 1, 'error_message': "Parameter 'user_quantity' is required.", 'password' : None }
password = ''.join(random.choice(string.digits + string.letters) for i in xrange(10)) password = ''.join(random.choice(string.digits + string.letters) for i in xrange(10))
try: try:
...@@ -39,7 +39,7 @@ try: ...@@ -39,7 +39,7 @@ try:
return {'status_code' : 1, 'error_message': error_message, 'password' : None } return {'status_code' : 1, 'error_message': error_message, 'password' : None }
organisation = organisation.getObject().getRelativeUrl() organisation = organisation.getObject().getRelativeUrl()
for i in xrange(0, int(user_number)): for i in xrange(0, int(user_quantity)):
user_id = "scalability_user_%i" % i user_id = "scalability_user_%i" % i
person = portal_catalog.getResultValue( person = portal_catalog.getResultValue(
portal_type="Person", portal_type="Person",
...@@ -53,10 +53,9 @@ try: ...@@ -53,10 +53,9 @@ try:
function_list = ["company/manager"], function_list = ["company/manager"],
) )
person.validate() person.validate()
assignements = person.objectValues(portal_type = 'Assignment')
for assignement in assignements: assignment_id_list = [x.getId() for x in person.objectValues(portal_type="Assignment")]
if assignement.getId() == "assignment_%s" % user_id: if assignment_id_list: person.manage_delObjects(ids=assignment_id_list)
person.deleteContent(id = "assignment_%s" % user_id)
assignment = person.newContent( assignment = person.newContent(
portal_type = "Assignment", portal_type = "Assignment",
id = "assignment_%s" % user_id, id = "assignment_%s" % user_id,
...@@ -69,10 +68,9 @@ try: ...@@ -69,10 +68,9 @@ try:
stop_date = DateTime(3000, 1, 1) stop_date = DateTime(3000, 1, 1)
) )
assignment.open() assignment.open()
users = person.objectValues(portal_type = 'ERP5 Login')
for user in users: user_id_list = [x.getId() for x in person.objectValues(portal_type="ERP5 Login")]
if user.getId() == "login_%s" % user_id: if user_id_list: person.manage_delObjects(ids=user_id_list)
person.deleteContent(id = "login_%s" % user_id)
user = person.newContent( user = person.newContent(
portal_type = "ERP5 Login", portal_type = "ERP5 Login",
id = "login_%s" % user_id, id = "login_%s" % user_id,
......
...@@ -52,6 +52,12 @@ ...@@ -52,6 +52,12 @@
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item>
<key> <string>guard</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>ERP5Site_createScalabilityTestUsers</string> </value> <value> <string>ERP5Site_createScalabilityTestUsers</string> </value>
...@@ -59,4 +65,21 @@ ...@@ -59,4 +65,21 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Guard" module="Products.DCWorkflow.Guard"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData> </ZopeData>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment