cc1  v2.1
CC1 source code docs
 All Classes Namespaces Files Functions Variables Pages
s010_registration_logic.py
Go to the documentation of this file.
1 # -*- coding: utf-8 -*-
2 # @COPYRIGHT_begin
3 #
4 # Copyright [2010-2014] Institute of Nuclear Physics PAN, Krakow, Poland
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 # http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 #
18 # @COPYRIGHT_end
19 
20 from datetime import datetime
21 import hashlib
22 from random import random
23 from predefined.macros import *
24 from predefined.actions import *
25 from predefined.users import *
26 
27 actions = [list_clusters]
28 
29 # Register users
30 for u_new in test_users:
31  actions.append({'fname': 'user.guest.register', 'args': [{'login': u_new['l'],
32  'password': hashlib.sha1(u_new['p']).hexdigest(),
33  'act_key': u_new['act_key'],
34  'organization': u_new['organization'],
35  'email': u_new['email'],
36  'first': u_new['first'],
37  'last': u_new['last'],
38  }]})
39 
40  # List vm images. Inactive user shouldn't be allowed to list private images
41  actions.append({'u': u_new,
42  'fname': 'image.user.list',
43  'args':[{'access': 0, 'type': 2}], 'estatus': 'not_activated'})
44 
45  # Activate user
46  actions.append({'fname': 'user.guest.activate', 'args': ['fake_key'], 'estatus': 'user_get'})
47  actions.append({'fname': 'user.guest.activate', 'args': [u_new['act_key']], 'estatus': 'ok'})
48 
49  # Now user should be able to list private images
50  actions.append({'u': u_new,
51  'fname': 'image.user.list',
52  'args': [{'access': 1, 'type': 2}],
53  'store_as': 'public_images'})
54 
55  # Check user's login
56  #TODO: change to check_password
57  #actions.append({'fname': 'user.guest.get_by_login', 'args': [u_new['l']], 'store_as': 'get_by_login'})
58 
59  # Check user's password hash
60  actions.append({'fname': 'user.guest.check_password',
61  'args': [u_new['l'], hashlib.sha1(u_new['p']).hexdigest()]})
62 
63  # Get message list
64  actions.append({'u': u_new, 'fname': 'message.user.list', 'args': []})
65 
66  #TODO: Change password
67  #TODO: recovery password
68  #TODO: Show quota
69  #TODO: Check admin_cm password cmadmin.admin_cm.check_password
70  #TODO: Check cm_user password
71 
72 # Try to list VMs with various logins
73 actions.append({'u': u_new, 'fname': 'vm.user.list', 'args': [], 'estatus': 'ok'})
74 actions.append({'u': u_nexists, 'fname': 'vm.user.list', 'args': [], 'estatus': 'user_get'})
75 actions.append({'u': u_pass, 'fname': 'vm.user.list', 'args': [], 'estatus': 'user_get'})
76 actions.append({'u': u_cm, 'fname': 'vm.user.list', 'args': [], 'estatus': 'cluster_get'})
77 actions.append({'u': u_cm_pass, 'fname': 'vm.user.list', 'args': [], 'estatus': 'user_get'})
78 
79 # Store user list
80 actions.append(list_users)
81 
82 # Set user_clm_admin as CLM administrator
83 actions.append({'u': u_admin,
84  'fname': 'user.admin_clm.set_admin',
85  'args': [MACRO_GET_USER_ID(u_admin_clm['l']),
86  True]})
87 actions.append({'u': u_admin,
88  'fname': 'user.admin_clm.set_admin',
89  'args': [MACRO_GET_USER_ID(u_admin_clm['l']),
90  False]})
91 actions.append({'u': u_admin,
92  'fname': 'user.admin_clm.set_admin',
93  'args': [MACRO_GET_USER_ID(u_admin_clm['l']),
94  True]})
95 
96 # Set user admin_cm as CM administrator
97 actions.append({'u': u_admin,
98  'as_cmadmin': True,
99  'fname': 'cmadmin.admin_cm.add',
100  'args': [MACRO_GET_USER_ID(u_admin_cm['l']),
101  {'password': hashlib.sha1(u_admin_cm['cm_p']).hexdigest()}]
102  })
103