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
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
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
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)
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