Exemple #1
0
 def test_get_credentials_empty_configuration(self):
     test_obj = JenkinsConfigParser()
     sample_config=StringIO("")
     test_obj.readfp(sample_config)
     
     self.assertEqual(test_obj.get_credentials("http://localhost:8080"), None, 
                      "Empty config files should provide empty credentials")
Exemple #2
0
 def test_empty_section(self):
     test_url = "http://localhost:8080"
     sample_config=StringIO("[http://localhost:8080]")
     test_obj = JenkinsConfigParser()
     test_obj.readfp(sample_config)
     
     self.assertEqual(test_obj.get_credentials(test_url), None, 
                      "Undefined credentials should be reported as empty")
Exemple #3
0
def test_get_credentials_empty_configuration():
    test_obj = JenkinsConfigParser()
    sample_config = StringIO("")
    if six.PY3:
        test_obj.read_file(sample_config)
    else:
        test_obj.readfp(sample_config)

    assert test_obj.get_credentials("http://localhost:8080") is None
Exemple #4
0
 def test_get_credentials_no_password(self):
     test_url = "http://localhost:8080"
     
     sample_config=StringIO("[http://localhost:8080]\n" +
     "username=jdoe\n")
     test_obj = JenkinsConfigParser()
     test_obj.readfp(sample_config)
     
     self.assertRaises(InvalidUserParamsError, test_obj.get_credentials, test_url)
Exemple #5
0
def test_empty_section():
    test_url = "http://localhost:8080"
    sample_config = StringIO("[http://localhost:8080]")
    test_obj = JenkinsConfigParser()
    if six.PY3:
        test_obj.read_file(sample_config)
    else:
        test_obj.readfp(sample_config)

    assert test_obj.get_credentials(test_url) is None
Exemple #6
0
 def test_get_credentials_anonymous(self):
     test_url = "http://localhost:8080"
     sample_config=StringIO("[http://localhost:8080]\n" +
     "username=\n" +
     "password=\n")
     test_obj = JenkinsConfigParser()
     test_obj.readfp(sample_config)
     
     self.assertEqual(test_obj.get_credentials(test_url), None, 
                      "Config explicitly declares empty username and password which should \
                      be reported as empty credentials")
Exemple #7
0
def test_get_credentials_anonymous():
    test_url = "http://localhost:8080"
    sample_config = StringIO("""[http://localhost:8080]
username=
password=
""")
    test_obj = JenkinsConfigParser()
    if six.PY3:
        test_obj.read_file(sample_config)
    else:
        test_obj.readfp(sample_config)

    assert test_obj.get_credentials(test_url) is None
Exemple #8
0
def test_get_credentials_no_username():
    test_url = "http://localhost:8080"

    sample_config = StringIO("""[http://localhost:8080]
password=Password123
""")
    test_obj = JenkinsConfigParser()
    if six.PY3:
        test_obj.read_file(sample_config)
    else:
        test_obj.readfp(sample_config)

    with pytest.raises(InvalidUserParamsError):
        test_obj.get_credentials(test_url)
Exemple #9
0
 def test_get_credentials(self):
     test_url = "http://localhost:8080"
     expected_username = "******"
     expected_password = "******"
             
     sample_config=StringIO("[http://localhost:8080]\n" +
                            "username=jdoe\n" +
                            "password=Password123\n")
     test_obj = JenkinsConfigParser()
     test_obj.readfp(sample_config)
     
     actual_credentials = test_obj.get_credentials(test_url)
     self.assertEqual(actual_credentials[0], expected_username)
     self.assertEqual(actual_credentials[1], expected_password)
Exemple #10
0
def test_get_credentials():
    test_url = "http://localhost:8080"
    expected_username = "******"
    expected_password = "******"

    sample_config = StringIO("""[http://localhost:8080]
username=jdoe
password=Password123
""")
    test_obj = JenkinsConfigParser()
    if six.PY3:
        test_obj.read_file(sample_config)
    else:
        test_obj.readfp(sample_config)

    actual_credentials = test_obj.get_credentials(test_url)
    assert actual_credentials[0] == expected_username
    assert actual_credentials[1] == expected_password