forked from apache/cloudstack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_regions_accounts.py
More file actions
206 lines (176 loc) · 6.72 KB
/
Copy pathtest_regions_accounts.py
File metadata and controls
206 lines (176 loc) · 6.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
from marvin.integration.lib.utils import *
from marvin.integration.lib.base import *
from marvin.integration.lib.common import *
from nose.plugins.attrib import attr
class Services:
def __init__(self):
self.services = {
"domain": {
"name": "testuuid",
"domainUUID": "domain1"
},
"account": {
"email": "test@test.com",
"firstname": "Testuuid",
"lastname": "Useruuid",
"username": "test",
"password": "password",
"accountUUID": "account1",
"userUUID": "user1"
},
"user": {
"email": "test@test.com",
"firstname": "Testuuid",
"lastname": "Useruuid",
"username": "test",
"password": "password",
"userUUID": "user2"
},
}
class TestRegionsAccounts(cloudstackTestCase):
"""Test Accounts in Regions - CRUD tests for accounts in regions
"""
@classmethod
def setUpClass(cls):
cls.api_client = super(TestRegionsAccounts, cls).getClsTestClient().getApiClient()
cls.services = Services().services
cls.domain = get_domain(cls.api_client, cls.services)
cls.cleanup = []
return
@attr(tags=["simulator", "basic", "advanced"])
def test_createAccountWithUUID(self):
"""Test for creating account by passing id parameter
# Validate the following
# 1.Create an Account by passing id parameter.Verify the account is created.
# 2.List this account by passing id parameter.Verify that list account is able to lis this account.
# 3.Delete account should succeed.
"""
account = Account.create(
self.api_client,
self.services["account"],
domainid=self.domain.id
)
self.assertIn(self.services["account"]["accountUUID"], account.id,
"Account is not created with the accountId passed")
list_account = Account.list(self.api_client,
id=account.id)
self.assertEqual(
isinstance(list_account, list),
True,
"Check for list account response by uuid failed"
)
account_response = list_account[0]
self.assertEqual(account_response.id,
account.id,
"listAccount response does not match with account Id "
)
self.assertEqual(
account_response.user[0].firstname,
self.services["account"]["firstname"],
"listAccount response does not match with account firstname"
)
self.cleanup.append(account)
return
@attr(tags=["simulator", "basic", "advanced"])
def test_createUserWithUUID(self):
"""Test for creating User by passing id parameter
# Validate the following
# 1.Create a User by passing id parameter.Verify the user is created.
# 2.List this user by passing id parameter.Verify that list user is able to list this user.
# 3.Delete User should succeed.
"""
user = User.create(
self.api_client,
self.services["user"],
account="admin",
domainid=self.domain.id
)
self.assertIn(self.services["user"]["userUUID"], user.id,
"User is not created successfully with the userId passed")
list_user = User.list(self.api_client, id=user.id)
self.assertEqual(
isinstance(list_user, list),
True,
"Check for list user response by uuid failed"
)
user_response = list_user[0]
self.assertEqual(user_response.id,
user.id,
"list User response does not match with user Id "
)
self.assertEqual(
user_response.firstname,
self.services["user"]["firstname"],
"listUser response does not match with user firstname"
)
user.delete(self.api_client)
list_user = User.list(self.api_client,
id=user.id
)
self.assertIsNone(
list_user,
"Deletion of user failed"
)
return
@attr(tags=["simulator", "basic", "advanced"])
def test_createdomainWithUUID(self):
"""Test for creating Domain by passing id parameter
# Validate the following
# 1.Create a domain by passing id parameter.Verify the domain is created.
# 2.List this domain by passing id parameter.Verify that list domain is able to list this domain.
# 3.Delete domain should succeed.
"""
domain = Domain.create(
self.api_client,
self.services["domain"]
)
self.assertIn(self.services["domain"]["domainUUID"], domain.id,
"Domain is not created with the doaminId passed")
list_domain = Domain.list(self.api_client,
id=domain.id
)
self.assertEqual(
isinstance(list_domain, list),
True,
"Check for list domain response by uuid failed"
)
domain_response = list_domain[0]
self.assertEqual(domain_response.id,
domain.id,
"list domain response does not match with domain Id "
)
self.assertIn(
self.services["domain"]["name"],
domain_response.name,
"list domaiin response does not match with user firstname"
)
try:
domain.delete(self.api_client)
except Exception as e:
self.fail("Failed to delete domain: %s" % e)
return
@classmethod
def tearDownClass(cls):
try:
#Clean up
cleanup_resources(cls.api_client, cls.cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)