def test_full_property_example(self): actual = load_auth_provider(construct_config_path('full_plain_text_example')) _assert_auth_provider_matches( actual, PlainTextAuthProvider, {"username": '******', "password": '******'})
def test_partial_property_example(self): actual = load_auth_provider(construct_config_path('partial_example')) _assert_auth_provider_matches( actual, NoUserNamePlainTextAuthProvider, {"username": '', "password": ''})
def test_plaintextauth_when_not_defined(self): creds_file = construct_config_path('plain_text_full_creds') actual = load_auth_provider(cred_file=creds_file) _assert_auth_provider_matches( actual, PlainTextAuthProvider, {"username": '******', "password": '******'})
def test_legacy_example_no_password(self): cqlshrc = construct_config_path('plain_text_partial_example') creds_file = None actual = load_auth_provider(cqlshrc, creds_file, 'user3') _assert_auth_provider_matches( actual, PlainTextAuthProvider, {"username": '******', "password": None})
def test_legacy_example_no_auth_provider_given(self): cqlshrc = construct_config_path('empty_example') creds_file = construct_config_path('complex_auth_provider_creds') actual = load_auth_provider(cqlshrc, creds_file, 'user3', 'pass3') _assert_auth_provider_matches( actual, PlainTextAuthProvider, {"username": '******', "password": '******'})
def test_shouldnt_pass_no_password_when_alt_auth_provider(self): cqlshrc = construct_config_path('complex_auth_provider') creds_file = None actual = load_auth_provider(cqlshrc, creds_file, 'user3') _assert_auth_provider_matches( actual, ComplexTextAuthProvider, {"username": '******', "password": '******', "extra_flag": 'flag1'})
def test_creds_example(self): creds_file = construct_config_path('complex_auth_provider_creds') cqlshrc = construct_config_path('complex_auth_provider') actual = load_auth_provider(cqlshrc, creds_file) _assert_auth_provider_matches( actual, ComplexTextAuthProvider, {"username": '******', "password": '******', "extra_flag": 'flag2'})
def test_username_password_passed_from_commandline(self): creds_file = construct_config_path('complex_auth_provider_creds') cqlshrc = construct_config_path('complex_auth_provider') actual = load_auth_provider(cqlshrc, creds_file, 'user-from-legacy', 'pass-from-legacy') _assert_auth_provider_matches( actual, ComplexTextAuthProvider, {"username": '******', "password": '******', "extra_flag": 'flag2'})
def test_empty_example(self): actual = load_auth_provider(construct_config_path('empty_example')) assert actual is None
def test_creds_not_checked_for_non_plaintext(self): load_auth_provider(construct_config_path('complex_auth_provider_with_pass')) err_msg = self._captured_std_err.getvalue() assert err_msg == ''
def test_insecure_creds(self): load_auth_provider(construct_config_path('full_plain_text_example')) err_msg = self._captured_std_err.getvalue() assert "Notice:" in err_msg assert "Warning:" in err_msg
def test_no_warning_insecure_if_no_pass(self): load_auth_provider(construct_config_path('plain_text_partial_example')) err_msg = self._captured_std_err.getvalue() assert err_msg == ''
def test_improper_config_example(self): with pytest.raises(ModuleNotFoundError) as error: load_auth_provider(construct_config_path('illegal_example')) assert error is not None
def test_no_classname_example(self): actual = load_auth_provider(construct_config_path('no_classname_example')) assert actual is None
def test_no_cqlshrc_file(self): actual = load_auth_provider() assert actual is None