Debian Codegraph @

dirsrvtests/tests/suites/webui/create/create_instance_test.py

raw
1 # --- BEGIN COPYRIGHT BLOCK ---
2 # Copyright (C) 2021 Red Hat, Inc.
3 # All rights reserved.
4 #
5 # License: GPL (version 3 or any later version).
6 # See LICENSE for details.
7 # --- END COPYRIGHT BLOCK ---
8 #
9 import time
10 import subprocess
11 import pytest
12
13 from lib389.cli_idm.account import *
14 from lib389.tasks import *
15 from lib389.utils import *
16 from test389.topologies import topology_st
17 from .. import setup_page, check_frame_assignment
18
19 pytestmark = pytest.mark.skipif(os.getenv('WEBUI') is None, reason="These tests are only for WebUI environment")
20 pytest.importorskip('playwright')
21
22 SERVER_ID = 'standalone1'
23
24
25 def test_no_instance(topology_st, page, browser_name, setup_page):
26 """ Test page of Red Hat Directory Server when no instance is created
27
28 :id: 04c962b1-df5e-470d-8e19-aa6b77988c75
29 :setup: Standalone instance
30 :steps:
31 1. Go to Red Hat Directory server side tab page
32 2. Check there is Create New Instance button when no instance exists
33 :expectedresults:
34 1. Success
35 2. Button is visible
36 """
37 time.sleep(1)
38 frame = check_frame_assignment(page, browser_name)
39 log.info('Check the Create New instance button is present')
40 frame.wait_for_selector('#noInsts')
41 assert frame.is_visible('#noInsts')
42
43
44 def test_instance_button_disabled_passwd_short(topology_st, page, browser_name, setup_page):
45 """ Test Create Instance button is disabled when password is too short
46
47 :id: 9d413b70-7746-45ef-b389-9b67fcbc945a
48 :setup: Standalone instance
49 :steps:
50 1. Click on Create New Instance button
51 2. Fill serverID
52 3. Fill password shorter than eight characters
53 4. Fill passwordConfirm shorter than eight character
54 5. Check the Create Instance button is disabled when password is too short
55 :expectedresults:
56 1. A pop-up window should appear with create instance details
57 2. Success
58 3. Success
59 4. Success
60 5. Button is disabled
61 """
62 time.sleep(1)
63 frame = check_frame_assignment(page, browser_name)
64
65 log.info('Click on Create New Instance button')
66 frame.click("#no-inst-create-btn")
67 frame.wait_for_selector('#createServerId')
68
69 log.info('Fill serverID and short password')
70 frame.fill('#createServerId', SERVER_ID)
71 frame.fill('#createDMPassword', 'redhat')
72 frame.fill('#createDMPasswordConfirm', 'redhat')
73
74 log.info('Check Create Instance button is disabled')
75 assert frame.is_disabled("text=Create Instance")
76
77
78 def test_create_instance_without_database(topology_st, page, browser_name, setup_page):
79 """ Test create instance without database
80
81 :id: 7390c009-cb0d-406a-962a-4a1f0f02cfe6
82 :setup: Standalone instance
83 :steps:
84 1. Click on Create New Instance button
85 2. Fill serverID
86 3. Fill password longer than eight characters
87 4. Fill passwordConfirm longer than eight character
88 5. Click on the Create Instance button
89 :expectedresults:
90 1. A pop-up window should appear with create instance details
91 2. Success
92 3. Success
93 4. Success
94 5. Page redirection successful and instance is created
95 """
96 time.sleep(1)
97 frame = check_frame_assignment(page, browser_name)
98
99 log.info('Click on Create New Instance button')
100 frame.click("#no-inst-create-btn")
101 frame.wait_for_selector('#createServerId')
102
103 log.info('Fill serverID and password longer than eight characters')
104 frame.fill('#createServerId', SERVER_ID)
105 frame.fill('#createDMPassword', 'password')
106 frame.fill('#createDMPasswordConfirm', 'password')
107
108 log.info('Click Create Instance button')
109 frame.click("text=Create Instance")
110 frame.wait_for_selector("#serverId")
111
112 log.info('Check that created serverID is present')
113 assert frame.is_visible("#serverId")
114
115
116 def test_create_instance_database_suffix_entry(topology_st, page, browser_name, setup_page):
117 """ Test create instance with database and suffix entry
118
119 :id: 52703fc9-2f5b-49f9-b80b-bd0703008118
120 :setup: Standalone instance
121 :steps:
122 1. Click on Create New Instance button
123 2. Fill serverID, user and password
124 3. Check Create Database checkbox
125 4. Fill database suffix and name
126 5. Select Create Suffix Entry from drop-down list
127 6. Click on the Create Instance button
128 :expectedresults:
129 1. A pop-up window should appear with create instance details
130 2. Success
131 3. Success
132 4. Success
133 5. Success
134 6. Page redirection successful and instance is created
135 """
136 time.sleep(1)
137 frame = check_frame_assignment(page, browser_name)
138
139 log.info('Click on Create New Instance button')
140 frame.click("#no-inst-create-btn")
141 frame.wait_for_selector('#createServerId')
142
143 log.info('Fill serverID and password longer than eight characters')
144 frame.fill('#createServerId', SERVER_ID)
145 frame.fill('#createDMPassword', 'password')
146 frame.fill('#createDMPasswordConfirm', 'password')
147
148 log.info('Choose to create database with suffix entry')
149 if ds_is_older('2.0.10'):
150 frame.check('text="Create Database" >> input[type="checkbox"]')
151 frame.fill('input[placeholder="e.g. dc=example,dc=com"]', 'dc=example,dc=com')
152 frame.fill('input[placeholder="e.g. userRoot"]', 'userRoot')
153 else:
154 frame.check('#createDBCheckbox')
155 frame.fill('#createDBSuffix','dc=example,dc=com')
156 frame.fill('#createDBName','userRoot')
157
158 frame.select_option('#createInitDB', 'createSuffix')
159
160 frame.click("text=Create Instance")
161 frame.wait_for_selector("#serverId")
162
163 log.info('Check that created serverID is present')
164 assert frame.is_visible("#serverId")
165
166
167 def test_create_instance_database_sample_entries(topology_st, page, browser_name, setup_page):
168 """ Test create instance with database and sample entries
169
170 :id: d6d8cb10-8a5f-428d-b9a7-1c65b85986b7
171 :setup: Standalone instance
172 :steps:
173 1. Click on Create New Instance button
174 2. Fill serverID, user and password
175 3. Check Create Database checkbox
176 4. Fill database suffix and name
177 5. Select Create Sample Entries from drop-down list
178 6. Click on the Create Instance button
179 :expectedresults:
180 1. A pop-up window should appear with create instance details
181 2. Success
182 3. Success
183 4. Success
184 5. Success
185 6. Page redirection successful and instance is created
186 """
187 time.sleep(1)
188 frame = check_frame_assignment(page, browser_name)
189
190 log.info('Click on Create New Instance button')
191 frame.click("#no-inst-create-btn")
192 frame.wait_for_selector('#createServerId')
193
194 log.info('Fill serverID and password longer than eight characters')
195 frame.fill('#createServerId', SERVER_ID)
196 frame.fill('#createDMPassword', 'password')
197 frame.fill('#createDMPasswordConfirm', 'password')
198
199 log.info('Choose to create database with sample entries')
200 if ds_is_older('2.0.10'):
201 frame.check('text="Create Database" >> input[type="checkbox"]')
202 frame.fill('input[placeholder="e.g. dc=example,dc=com"]', 'dc=example,dc=com')
203 frame.fill('input[placeholder="e.g. userRoot"]', 'userRoot')
204 else:
205 frame.check('#createDBCheckbox')
206 frame.fill('#createDBSuffix','dc=example,dc=com')
207 frame.fill('#createDBName','userRoot')
208
209 frame.select_option('#createInitDB', 'createSample')
210
211 log.info('Click Create Instance button')
212 frame.click("text=Create Instance")
213 frame.wait_for_selector("#serverId")
214
215 log.info('Check that created serverID is present')
216 assert frame.is_visible("#serverId")
217
218
219 if __name__ == '__main__':
220 # Run isolated
221 # -s for DEBUG mode
222 CURRENT_FILE = os.path.realpath(__file__)
223 pytest.main("-s %s" % CURRENT_FILE)