-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathtest_configuration_page_account_tab.py
More file actions
1390 lines (1290 loc) · 58.3 KB
/
Copy pathtest_configuration_page_account_tab.py
File metadata and controls
1390 lines (1290 loc) · 58.3 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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
from pytest_splunk_addon_ui_smartx.base_test import UccTester
from selenium.webdriver.common.by import By
from tests.ui.pages.account_page import AccountPage
import pytest
import copy
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
_ACCOUNT_CONFIG = {
"name": "TestAccount",
"account_checkbox": 1,
"account_multiple_select": "one",
"account_radio": "yes",
"auth_type": "basic",
"custom_endpoint": "login.example.com",
"username": "TestUser",
"password": "TestPassword",
"token": "TestToken",
"client_id": "",
"client_secret": "",
"redirect_url": "",
"endpoint": "",
"example_help_link": "",
"url": "https://test.example.com",
"example_textarea_field_basic_oauth": "line1\nline2\nline3\nline4\nline5",
}
_ACCOUNT_CONFIG_OAUTH = {
"name": "TestAccountOauth2",
}
@pytest.fixture
def _add_account(ucc_smartx_rest_helper):
account = AccountPage(
ucc_smartx_rest_helper=ucc_smartx_rest_helper, open_page=False
)
url = account._get_account_endpoint()
kwargs = _ACCOUNT_CONFIG
yield account.backend_conf.post_stanza(url, kwargs)
@pytest.fixture
def _add_multiple_account(ucc_smartx_rest_helper):
account = AccountPage(
ucc_smartx_rest_helper=ucc_smartx_rest_helper, open_page=False
)
url = account._get_account_endpoint()
for i in range(12):
account_config = copy.copy(_ACCOUNT_CONFIG)
new_account_config_name = f"{account_config['name']}{i}"
account_config["name"] = new_account_config_name
account.backend_conf.post_stanza(url, account_config)
@pytest.fixture(autouse=True)
def _delete_accounts(ucc_smartx_rest_helper):
yield
account = AccountPage(
ucc_smartx_rest_helper=ucc_smartx_rest_helper, open_page=False
)
account.backend_conf.delete_all_stanzas()
class TestAccount(UccTester):
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
def test_account_default_rows_in_table(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper
):
"""Verifies the default number of rows in the table"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
self.assert_util(account.table.get_row_count, 0)
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
def test_account_sort_functionality(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper, _add_multiple_account
):
"""Verifies sorting functionality for name column"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
account.table.sort_column("Name")
sort_order = account.table.get_sort_order()
column_values = list(account.table.get_column_values("Name"))
column_values = list(str(item) for item in column_values)
sorted_values = sorted(column_values, key=str.lower)
self.assert_util(sort_order["header"].lower(), "name")
self.assert_util(column_values, sorted_values)
self.assert_util(sort_order["ascending"], True)
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
def test_account_count(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper, _add_multiple_account
):
"""Verifies count on table"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
self.assert_util(
account.table.get_count_title,
f"{len(account.backend_conf.get_all_stanzas())} Items",
)
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
def test_account_filter_functionality_negative(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper, _add_account
):
"""Verifies the filter functionality (Negative)"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
account.table.set_filter("hello")
self.assert_util(account.table.get_row_count, 0)
self.assert_util(
account.table.get_count_title,
f"{account.table.get_row_count()} Item",
)
account.table.clean_filter()
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
def test_account_filter_functionality_positive(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper, _add_account
):
"""Verifies the filter functionality (Positive)"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
account.table.set_filter("TestAccount")
self.assert_util(account.table.get_row_count, 1)
self.assert_util(
account.table.get_count_title,
f"{account.table.get_row_count()} Item",
)
account.table.clean_filter()
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
def test_account_pagination(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper, _add_multiple_account
):
"""Verifies pagination list"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
name_column_page1 = account.table.get_column_values("name")
account.table.switch_to_next()
name_column_page2 = account.table.get_column_values("name")
self.assert_util(name_column_page1, name_column_page2, "!=")
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
def test_account_add_valid_title(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper
):
"""Verifies the title of the 'Add Entity'"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
account.entity.open()
self.assert_util(
account.entity.title.container.get_attribute("textContent").strip(),
"Add Account",
)
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
def test_account_edit_valid_title(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper, _add_account
):
"""Verifies the title of the 'Edit Entity'"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
account.table.edit_row(_ACCOUNT_CONFIG["name"])
self.assert_util(
account.entity.title.container.get_attribute("textContent").strip(),
"Update Account",
)
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
def test_account_clone_valid_title(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper, _add_account
):
"""Verifies the title of the 'Clone Entity'"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
account.table.clone_row(_ACCOUNT_CONFIG["name"])
self.assert_util(
account.entity.title.container.get_attribute("textContent").strip(),
"Clone Account",
)
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
def test_account_delete_valid_title(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper, _add_account
):
"""Verifies the title of the 'Delete Entity'"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
account.table.delete_row(_ACCOUNT_CONFIG["name"], prompt_msg=True)
self.assert_util(
account.entity.title.container.get_attribute("textContent").strip(),
"Delete Confirmation",
)
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
def test_account_add_close_entity(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper
):
"""Verifies close functionality at time of add"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
account.entity.open()
self.assert_util(account.entity.close, True)
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
def test_account_add_cancel_entity(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper
):
"""Verifies cancel functionality at time of add"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
account.entity.open()
self.assert_util(account.entity.cancel, True)
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
def test_account_delete_close_entity(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper, _add_account
):
"""Verifies close functionality at time of delete"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
self.assert_util(
account.table.delete_row,
True,
left_args={"name": _ACCOUNT_CONFIG["name"], "close": True},
)
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
def test_account_delete_cancel_entity(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper, _add_account
):
"""Verifies cancel functionality at time of delete"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
self.assert_util(
account.table.delete_row,
True,
left_args={"name": _ACCOUNT_CONFIG["name"], "cancel": True},
)
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
def test_account_edit_close_entity(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper, _add_account
):
"""Verifies close functionality at time of edit"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
account.table.edit_row(_ACCOUNT_CONFIG["name"])
self.assert_util(account.entity.close, True)
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
def test_account_edit_cancel_entity(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper, _add_account
):
"""Verifies cancel functionality at time of edit"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
account.table.edit_row(_ACCOUNT_CONFIG["name"])
self.assert_util(account.entity.cancel, True)
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
def test_account_clone_close_entity(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper, _add_account
):
"""Verifies close functionality at time of clone"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
account.table.clone_row(_ACCOUNT_CONFIG["name"])
self.assert_util(account.entity.close, True)
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
def test_account_clone_cancel_entity(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper, _add_account
):
"""Verifies cancel functionality at time of clone"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
account.table.clone_row(_ACCOUNT_CONFIG["name"])
self.assert_util(account.entity.cancel, True)
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
def test_account_delete_valid_prompt_message(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper, _add_account
):
"""Verifies the prompt message of the 'Delete Entity'"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
prompt_message = account.table.delete_row(
_ACCOUNT_CONFIG["name"], prompt_msg=True
)
self.assert_util(
prompt_message,
'Are you sure you want to delete "{}" ? Ensure that no input is '
'configured with "{}" as this will stop data collection for '
"that input.".format(_ACCOUNT_CONFIG["name"], _ACCOUNT_CONFIG["name"]),
)
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
def test_account_required_field_username(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper
):
"""Verifies required field username"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
account.entity.open()
account.entity.name.set_value(_ACCOUNT_CONFIG["name"])
account.entity.environment.select("Value2")
account.entity.multiple_select.select("Option Two")
account.entity.password.set_value("TestEditPassword")
account.entity.security_token.set_value("TestEditToken")
account.entity.account_radio.select("No")
self.assert_util(
account.entity.save,
"Field Username is required",
left_args={"expect_error": True},
)
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
def test_account_required_field_password(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper
):
"""Verifies required field password"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
account.entity.open()
account.entity.name.set_value(_ACCOUNT_CONFIG["name"])
account.entity.environment.select("Value2")
account.entity.multiple_select.select("Option Two")
account.entity.username.set_value("TestEditUser")
account.entity.security_token.set_value("TestEditToken")
account.entity.account_radio.select("No")
self.assert_util(
account.entity.save,
"Field Password is required",
left_args={"expect_error": True},
)
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
def test_account_encrypted_field_password(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper
):
"""Verifies if the password field is masked or not in the Textbox"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
account.entity.open()
textbox_type = account.entity.password.get_type()
self.assert_util(textbox_type, "password")
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
def test_account_required_field_name(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper
):
"""Verifies required field name"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
account.entity.open()
account.entity.environment.select("Value2")
account.entity.multiple_select.select("Option Two")
account.entity.username.set_value("TestEditUser")
account.entity.password.set_value("TestEditPassword")
account.entity.security_token.set_value("TestEditToken")
account.entity.account_radio.select("No")
self.assert_util(
account.entity.save,
"Field Name is required",
left_args={"expect_error": True},
)
account.entity.name.set_value("abc")
self.assert_util(account.entity.is_error_closed, True)
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
def test_account_basic_fields_label_entity(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper
):
"""Verifies basic account field label"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
account.entity.open()
self.assert_util(account.entity.name.get_input_label, "Name")
self.assert_util(
account.entity.environment.get_input_label, "Example Environment"
)
self.assert_util(
account.entity.example_checkbox.get_input_label, "Example Checkbox"
)
self.assert_util(account.entity.account_radio.get_input_label, "Example Radio")
self.assert_util(
account.entity.multiple_select.get_input_label, "Example Multiple Select"
)
self.assert_util(account.entity.auth_key.get_input_label, "Auth Type")
self.assert_util(account.entity.username.get_input_label, "Username")
self.assert_util(account.entity.password.get_input_label, "Password")
self.assert_util(
account.entity.security_token.get_input_label, "Security Token"
)
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
def test_account_oauth_fields_label_entity(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper
):
"""Verifies oauth account field label"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
account.entity.open()
account.entity.auth_key.select("OAuth 2.0 - Authorization Code Grant Type")
self.assert_util(account.entity.name.get_input_label, "Name")
self.assert_util(
account.entity.environment.get_input_label, "Example Environment"
)
self.assert_util(
account.entity.example_checkbox.get_input_label, "Example Checkbox"
)
self.assert_util(account.entity.account_radio.get_input_label, "Example Radio")
self.assert_util(
account.entity.multiple_select.get_input_label, "Example Multiple Select"
)
self.assert_util(account.entity.auth_key.get_input_label, "Auth Type")
self.assert_util(account.entity.client_id.get_input_label, "Client Id")
self.assert_util(account.entity.client_secret.get_input_label, "Client Secret")
self.assert_util(account.entity.redirect_url.get_input_label, "Redirect url")
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
def test_account_oauth_fields_different_tab(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper
):
"""Verifies oauth account field label"""
account = AccountPage(
ucc_smartx_selenium_helper, ucc_smartx_rest_helper, name="organization"
)
account.entity.open()
self.assert_util(account.entity.client_id.get_input_label, "Client Id")
self.assert_util(account.entity.client_secret.get_input_label, "Client Secret")
self.assert_util(account.entity.redirect_url.get_input_label, "Redirect url")
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
def test_account_oauth_login(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper, oauth_server_port
):
"""Verifies oauth account field label"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
account.entity.open()
account.entity.name.set_value(_ACCOUNT_CONFIG_OAUTH["name"])
account.entity.multiple_select.select("Option One")
account.entity.auth_key.select("OAuth 2.0 - Authorization Code Grant Type")
account.entity.client_id.set_value("demo")
account.entity.client_secret.set_value("demo")
account.entity.endpoint_authorize.set_value(f"localhost:{oauth_server_port}")
# Use host.docker.internal to access host from container
account.entity.endpoint_token.set_value(
f"host.docker.internal:{oauth_server_port}"
)
# Get current window handle before triggering OAuth flow
original_window = ucc_smartx_selenium_helper.browser.current_window_handle
original_windows = set(ucc_smartx_selenium_helper.browser.window_handles)
# Trigger OAuth flow - this will open a new window
account.entity.save()
# Wait for new window to appear and switch to it
wait = WebDriverWait(ucc_smartx_selenium_helper.browser, 5)
wait.until(lambda driver: len(driver.window_handles) > len(original_windows))
# Find and switch to the new window
all_windows = set(ucc_smartx_selenium_helper.browser.window_handles)
new_window = (all_windows - original_windows).pop()
ucc_smartx_selenium_helper.browser.switch_to.window(new_window)
# Interact with OAuth login form
wait.until(EC.presence_of_element_located((By.ID, "email")))
email_field = ucc_smartx_selenium_helper.browser.find_element(By.ID, "email")
password_field = ucc_smartx_selenium_helper.browser.find_element(
By.ID, "password"
)
submit_button = ucc_smartx_selenium_helper.browser.find_element(
By.CSS_SELECTOR, "button[type='submit']"
)
# Fill and submit the OAuth login form
email_field.send_keys("test@example.com")
password_field.send_keys("good") # The test server expects "good" as password
submit_button.click()
# Wait for redirect back to original application
wait.until(lambda driver: len(driver.window_handles) == len(original_windows))
# Switch back to original window
ucc_smartx_selenium_helper.browser.switch_to.window(original_window)
# Wait for the OAuth flow to complete and verify no errors
wait.until(lambda driver: account.entity.is_error_closed())
self.assert_util(account.entity.is_error_closed, True)
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.account
def test_account_help_text_entity(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper
):
"""Verifies help text for the field name"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
account.entity.open()
self.assert_util(
account.entity.name.get_help_text, "Enter a unique name for this account."
)
self.assert_util(
account.entity.example_checkbox.get_help_text,
"This is an example checkbox for the account entity",
)
self.assert_util(
account.entity.account_radio.get_help_text,
"This is an example radio button for the account entity. "
"Read more about it here\u2060 (Opens new window)",
)
self.assert_util(
account.entity.multiple_select.get_help_text,
"This is an example multipleSelect for account entity",
)
self.assert_util(
account.entity.username.get_help_text,
"Enter the username for this account.",
)
self.assert_util(
account.entity.password.get_help_text,
"Enter the password for this account.",
)
self.assert_util(
account.entity.security_token.get_help_text, "Enter the security token."
)
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
def test_account_required_field_example_multiple_select(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper
):
"""Verifies required field example multiple select"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
account.entity.open()
account.entity.name.set_value(_ACCOUNT_CONFIG["name"])
account.entity.environment.select("Value2")
account.entity.username.set_value("TestEditUser")
account.entity.password.set_value("TestEditPassword")
account.entity.security_token.set_value("TestEditToken")
account.entity.account_radio.select("No")
self.assert_util(
account.entity.save,
"Field Example Multiple Select is required",
left_args={"expect_error": True},
)
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
def test_account_required_field_client_id(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper
):
"""Verifies required field client id"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
account.entity.open()
account.entity.name.set_value(_ACCOUNT_CONFIG["name"])
account.entity.environment.select("Value2")
account.entity.account_radio.select("No")
account.entity.multiple_select.select("Option Two")
account.entity.auth_key.select("OAuth 2.0 - Authorization Code Grant Type")
self.assert_util(
account.entity.save,
"Field Client Id is required",
left_args={"expect_error": True},
)
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
def test_account_required_field_client_secret(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper
):
"""Verifies required field client secret"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
account.entity.open()
account.entity.auth_key.select("OAuth 2.0 - Authorization Code Grant Type")
account.entity.name.set_value(_ACCOUNT_CONFIG["name"])
account.entity.multiple_select.select("Option One")
account.entity.account_radio.select("No")
account.entity.client_id.set_value("TestClientId")
self.assert_util(
account.entity.save,
"Field Client Secret is required",
left_args={"expect_error": True},
)
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
def test_account_encrypted_field_client_secret(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper
):
"""Verifies if the password field is masked or not in the Textbox"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
account.entity.open()
account.entity.auth_key.select("OAuth 2.0 - Authorization Code Grant Type")
textbox_type = account.entity.client_secret.get_type()
self.assert_util(textbox_type, "password")
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
def test_account_valid_account_name(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper
):
"""Verifies whether adding special characters, number in starting of name field displays validation error"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
account.entity.open()
account.entity.username.set_value(_ACCOUNT_CONFIG["username"])
account.entity.password.set_value(_ACCOUNT_CONFIG["password"])
account.entity.name.set_value("123TestAccount")
self.assert_util(
account.entity.save,
"Name must begin with a letter and consist exclusively of alphanumeric characters and underscores.",
left_args={"expect_error": True},
)
account.entity.name.set_value("TestAccount&")
self.assert_util(
account.entity.save,
"Name must begin with a letter and consist exclusively of alphanumeric characters and underscores.",
left_args={"expect_error": True},
)
account.entity.name.set_value("a" * 51)
self.assert_util(
account.entity.save,
"Length of ID should be between 1 and 50",
left_args={"expect_error": True},
)
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
def test_account_valid_length_name(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper
):
"""Verifies the name field should not be more than 50 characters"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
account.entity.open()
account.entity.username.set_value(_ACCOUNT_CONFIG["username"])
account.entity.password.set_value(_ACCOUNT_CONFIG["password"])
account.entity.name.set_value("t" * 51)
self.assert_util(
account.entity.save,
"Length of ID should be between 1 and 50",
left_args={"expect_error": True},
)
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
def test_account_default_value_example_environment(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper
):
"""Verifies default value of example environment"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
account.entity.open()
account.entity.name.set_value(_ACCOUNT_CONFIG["name"])
account.entity.username.set_value(_ACCOUNT_CONFIG["username"])
self.assert_util(account.entity.environment.get_value, "Value1")
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
def test_account_list_example_environment(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper
):
"""Verifies example environment list dropdown"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
account.entity.open()
self.assert_util(
account.entity.environment.list_of_values, ["Value1", "Value2", "Other"]
)
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
def test_account_default_value_auth_type(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper
):
"""Verifies default value of auth type"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
account.entity.open()
self.assert_util(account.entity.auth_key.get_value, "basic")
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
def test_account_list_auth_type(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper
):
"""Verifies auth type list dropdown"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
account.entity.open()
self.assert_util(
account.entity.auth_key.list_of_values(),
[
"Basic Authentication/Authorization",
"OAuth 2.0 - Authorization Code Grant Type",
"OAuth 2.0 - Client Credentials Grant Type",
"Certificate Authorization",
],
)
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
def test_account_checked_example_checkbox(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper
):
"""Verifies Check/Uncheck in example checkbox"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
account.entity.open()
account.entity.example_checkbox.check()
self.assert_util(account.entity.example_checkbox.is_checked, True)
account.entity.example_checkbox.uncheck()
self.assert_util(account.entity.example_checkbox.is_checked, False)
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
def test_account_select_value_example_environment(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper
):
"""Verifies example environment select value"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
account.entity.open()
account.entity.environment.select("Value2")
self.assert_util(account.entity.environment.get_value, "Value2")
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
@pytest.mark.flaky(reruns=5, reruns_delay=5)
def test_account_list_example_multiple_select(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper
):
"""Verifies example multiple select list dropdown"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
account.entity.open()
account.entity.multiple_select.wait_for("input")
account.entity.multiple_select.wait_for_values()
self.assert_util(
account.entity.multiple_select.list_of_values(),
["Option One", "Option Two"],
)
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
def test_account_select_value_example_multiple_select(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper
):
"""Verifies example multiple select value"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
account.entity.open()
account.entity.multiple_select.select("Option One")
account.entity.multiple_select.select("Option Two")
self.assert_util(
account.entity.multiple_select.get_values, ["Option One", "Option Two"]
)
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
def test_account_search_value_example_multiple_select(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper
):
"""Verifies example multiple select search functionality"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
account.entity.open()
self.assert_util(
account.entity.multiple_select.search_get_list,
["Option One"],
left_args={"value": "Option One"},
)
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
def test_account_default_value_example_radio(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper
):
"""Verifies default value of example radio"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
account.entity.open()
self.assert_util(account.entity.account_radio.get_value, "Yes")
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
def test_add_account_duplicate_name(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper, _add_account
):
"""Verifies by saving an entity with duplicate name at time of add it displays and error"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
account.entity.open()
account.entity.name.set_value(_ACCOUNT_CONFIG["name"])
account.entity.multiple_select.select("Option One")
account.entity.username.set_value(_ACCOUNT_CONFIG["username"])
account.entity.password.set_value(_ACCOUNT_CONFIG["password"])
account.entity.account_radio.select("Yes")
self.assert_util(
account.entity.save,
"Name {} is already in use".format(_ACCOUNT_CONFIG["name"]),
left_args={"expect_error": True},
)
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
@pytest.mark.sanity_test
def test_account_delete_row_frontend_validation(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper, _add_account
):
"""Verifies the frontend delete functionlity"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
account.table.delete_row(_ACCOUNT_CONFIG["name"])
account.table.wait_for_rows_to_appear(0)
self.assert_util(_ACCOUNT_CONFIG["name"], account.table.get_table, "not in")
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
def test_account_edit_uneditable_field_name(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper, _add_account
):
"""Verifies the frontend uneditable fields at time of edit of the account"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
account.table.edit_row(_ACCOUNT_CONFIG["name"])
self.assert_util(account.entity.name.is_editable, False)
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
def test_account_credentials_encrypted_value(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper, _add_account
):
"""Verifies the default number of rows in the table"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
account.table.wait_for_rows_to_appear(1)
assert account.backend_conf.get_stanza(_ACCOUNT_CONFIG["name"]) == {
"account_checkbox": "1",
"account_multiple_select": _ACCOUNT_CONFIG["account_multiple_select"],
"account_radio": "1",
"auth_type": _ACCOUNT_CONFIG["auth_type"],
"username": _ACCOUNT_CONFIG["username"],
"custom_endpoint": _ACCOUNT_CONFIG["custom_endpoint"],
"disabled": False,
"example_textarea_field_basic_oauth": _ACCOUNT_CONFIG[
"example_textarea_field_basic_oauth"
],
"password": "******",
"token": "******",
"url": "https://test.example.com",
}
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
@pytest.mark.sanity_test
def test_account_add_frontend_validation(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper
):
"""Verifies the frontend after adding account"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
account.entity.open()
account.entity.name.set_value(_ACCOUNT_CONFIG["name"])
account.entity.username.set_value(_ACCOUNT_CONFIG["username"])
account.entity.multiple_select.select("Option One")
account.entity.password.set_value(_ACCOUNT_CONFIG["password"])
account.entity.security_token.set_value("TestToken")
account.entity.text_area_basic_oauth.set_value(
_ACCOUNT_CONFIG["example_textarea_field_basic_oauth"]
)
self.assert_util(account.entity.save, True)
account.table.wait_for_rows_to_appear(1)
self.assert_util(
account.table.get_table()[_ACCOUNT_CONFIG["name"]],
{
"name": _ACCOUNT_CONFIG["name"],
"auth type": "basic",
"test custom cell": "Option One",
"actions": "Edit | Clone | Delete",
},
)
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
@pytest.mark.sanity_test
def test_account_edit_frontend_validation(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper, _add_account
):
"""Verifies the frontend edit functionality"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
account.table.edit_row(_ACCOUNT_CONFIG["name"])
account.entity.environment.select("Value2")
account.entity.multiple_select.select("Option Two")
account.entity.username.set_value("TestEditUser")
account.entity.password.set_value("TestEditPassword")
account.entity.security_token.set_value("TestEditToken")
account.entity.account_radio.select("No")
self.assert_util(account.entity.save, True)
account.table.wait_for_rows_to_appear(1)
self.assert_util(
account.table.get_table()[_ACCOUNT_CONFIG["name"]],
{
"name": "TestAccount",
"auth type": "basic",
"test custom cell": "Option is not available",
"actions": "Edit | Clone | Delete",
},
)
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
def test_clone_account_duplicate_name(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper, _add_account
):
"""Verifies by saving an entity with duplicate name at time of clone it displays and error"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
account.table.clone_row(_ACCOUNT_CONFIG["name"])
account.entity.name.set_value(_ACCOUNT_CONFIG["name"])
self.assert_util(
account.entity.save,
"Name {} is already in use".format(_ACCOUNT_CONFIG["name"]),
left_args={"expect_error": True},
)
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
@pytest.mark.account
@pytest.mark.sanity_test
def test_account_clone_frontend_validation(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper, _add_account
):
"""Verifies the frontend clone functionality"""
account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
account.table.wait_for_rows_to_appear(1)
account.table.clone_row(_ACCOUNT_CONFIG["name"])
account.entity.name.set_value("TestAccount2")
account.entity.username.set_value("TestUserClone")
account.entity.password.set_value("TestPasswordClone")
account.entity.security_token.set_value("TestTokenClone")
account.entity.account_radio.select("Yes")
self.assert_util(account.entity.save, True)
self.assert_util(
account.table.get_table()["TestAccount2"],
{
"name": "TestAccount2",
"auth type": "basic",
"test custom cell": "Option One",
"actions": "Edit | Clone | Delete",
},
)
@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder