Ejemplo n.º 1
0
 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": '******'})
Ejemplo n.º 2
0
 def test_partial_property_example(self):
     actual = load_auth_provider(construct_config_path('partial_example'))
     _assert_auth_provider_matches(
             actual,
             NoUserNamePlainTextAuthProvider,
             {"username": '',
              "password": ''})
Ejemplo n.º 3
0
 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": '******'})
Ejemplo n.º 4
0
    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})
Ejemplo n.º 5
0
    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": '******'})
Ejemplo n.º 6
0
    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'})
Ejemplo n.º 7
0
    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'})
Ejemplo n.º 8
0
    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'})
Ejemplo n.º 9
0
 def test_empty_example(self):
     actual = load_auth_provider(construct_config_path('empty_example'))
     assert actual is None
Ejemplo n.º 10
0
 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 == ''
Ejemplo n.º 11
0
 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
Ejemplo n.º 12
0
 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 == ''
Ejemplo n.º 13
0
 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
Ejemplo n.º 14
0
 def test_no_classname_example(self):
     actual = load_auth_provider(construct_config_path('no_classname_example'))
     assert actual is None
Ejemplo n.º 15
0
 def test_no_cqlshrc_file(self):
     actual = load_auth_provider()
     assert actual is None