def test_search_path(): root_path = '/var' assert_equal(utils.search_path(root_path), root_path) existing_input_path = 'mplane' output_path = path.abspath('mplane') assert_equal(utils.search_path(existing_input_path), output_path) unexisting_input_path = 'missing' assert_equal(utils.search_path(unexisting_input_path), '')
def get_config(config_file): """ Open a config file, parse it and return a config object. """ config = configparser.ConfigParser() config.optionxform = str config.read(utils.search_path(config_file)) return config
assert_true(res.check(cap, id_true_role)) assert_false(res.check(cap, id_false_role)) def test_AuthorizationOff(): model.initialize_registry() cap = model.Capability(label="test-log_tcp_complete-core") res = azn.AuthorizationOff() assert_true(isinstance(res, azn.AuthorizationOff)) assert_true(res.check(cap, id_true_role)) ### ### tls.py tests ### cert = utils.search_path(path.join(conf_dir, "Component-SSB.crt")) key = utils.search_path(path.join(conf_dir, "Component-SSB-plaintext.key")) ca_chain = utils.search_path(path.join(conf_dir, "root-ca.crt")) identity = "org.mplane.SSB.Components.Component-1" forged_identity = "org.example.test" host = "127.0.0.1" port = 8080 # No forged_identity tls_with_file = tls.TlsState(config=get_config(config_path)) # No TLS sections but with forged_identity tls_with_file_no_tls = tls.TlsState(config=get_config(config_path_no_tls), forged_identity=forged_identity)
assert_false(res.check(cap, id_false_role)) def test_AuthorizationOff(): model.initialize_registry() cap = model.Capability(label="test-log_tcp_complete-core") res = azn.AuthorizationOff() assert_true(isinstance(res, azn.AuthorizationOff)) assert_true(res.check(cap, id_true_role)) ### ### tls.py tests ### cert = utils.search_path(path.join(conf_dir, "Component-SSB.crt")) key = utils.search_path(path.join(conf_dir, "Component-SSB-plaintext.key")) ca_chain = utils.search_path(path.join(conf_dir, "root-ca.crt")) identity = "org.mplane.SSB.Components.Component-1" forged_identity = "org.example.test" host = "127.0.0.1" port = 8080 # No forged_identity tls_with_file = tls.TlsState(config=get_config(config_path)) # No TLS sections but with forged_identity tls_with_file_no_tls = tls.TlsState(config=get_config(config_path_no_tls), forged_identity=forged_identity)