Пример #1
0
def test_validate_ssl_keys_with_non_existant_key_file(mock_os_path_exists):
    mock_os_path_exists.file_names_that_exist = ['test.pem']
    with pytest.raises(SystemExit) as pytest_wrapped_e:
        serve._validate_ssl_keys('test.pem', 'test-key.pem')

    assert pytest_wrapped_e.type == SystemExit
    assert pytest_wrapped_e.value.code == "Private key file can't be found"
Пример #2
0
def test_validate_ssl_keys_with_actual_keys(mock_os_path_exists):
    mock_os_path_exists.file_names_that_exist = ['test.pem', 'test-key.pem']
    return_value = serve._validate_ssl_keys('test.pem', 'test-key.pem')

    assert type(return_value) is tuple
    assert return_value[0] == 'test.pem'
    assert return_value[1] == 'test-key.pem'
Пример #3
0
def test_validate_ssl_keys_with_sys_exit_for_missing_key():
    with pytest.raises(SystemExit) as pytest_wrapped_e:
        serve._validate_ssl_keys('test.pem', None)

    assert pytest_wrapped_e.type == SystemExit
    assert pytest_wrapped_e.value.code == "Missing either cert file or private key file (hint: --ssl-pub <file> and --ssl-pri <file>)"
Пример #4
0
def test_validate_ssl_keys_with_non_existant_cert_file(mock_os_path_exists):
    with pytest.raises(SystemExit) as pytest_wrapped_e:
        serve._validate_ssl_keys('test.pem', 'test-key.pem')

    assert pytest_wrapped_e.type == SystemExit
    assert pytest_wrapped_e.value.code == "Cert file can't be found"
Пример #5
0
def test_validate_ssl_keys_with_no_keys_passed():
    return_value = serve._validate_ssl_keys(None, None)
    assert return_value is None