def test_set_email_to_config_file(self, tmpdir):
        server_config = self._setup_server_config(oprp_dir_path=str(tmpdir))
        ports = [8001, 8002, 8003, 8004]
        existing_key = "srv_discovery_url"
        client_attribute = json.dumps({existing_key: 'https://example.com'})
        self._create_temp_config_module_files(ports, tmpdir, client_attribute=client_attribute)
        set_email_to_file(ports[:3], "*****@*****.**", server_config)
        for port in ports[:3]:
            config_module = identify_existing_config_file(port, server_config.OPRP_DIR_PATH)
            assert CONTACT_EMAIL in config_module
            assert existing_key in config_module

        config_module = identify_existing_config_file(8004, server_config.OPRP_DIR_PATH)
        assert CONTACT_EMAIL not in config_module
 def test_identify_existing_config_file(self, load_config_module_mock, tmpdir):
     load_config_module_mock.return_value = {"client_conf": ""}
     _port = 1
     ports = [_port, -_port]
     self._create_temp_config_module_files(ports, tmpdir)
     self._create_temp_config_module_files([_port], tmpdir, ".pyc")
     config_client_dict = identify_existing_config_file(_port, str(tmpdir))
     assert config_client_dict
Example #3
0
def handle_load_existing_config(response_encoder, session, parameters):
    if ISSUER_QUERY_KEY in parameters and INSTANCE_ID_QUERY_KEY in parameters:
        configurations = load_configuration_from_database(parameters)

        if not configurations:
            issuer = remove_last_slash(parameters[ISSUER_QUERY_KEY])
            instance_id = parameters[INSTANCE_ID_QUERY_KEY]
            port_db = PortDatabase(CONF.PORT_DATABASE_FILE)
            port = port_db.get_port(issuer, instance_id)
            configurations = identify_existing_config_file(port, CONF.OPRP_DIR_PATH)

        store_query_parameter(parameters, session, ISSUER_QUERY_KEY)
        store_query_parameter(parameters, session, INSTANCE_ID_QUERY_KEY)

        if configurations:
            session[OP_CONFIG] = configurations
        else:
            session[OP_CONFIG] = get_default_client()

        session[IS_RECONFIGURING] = True
        return response_encoder.return_json("{}")
    return response_encoder.bad_request()
Example #4
0
def handle_load_existing_config(response_encoder, session, parameters):
    if ISSUER_QUERY_KEY in parameters and INSTANCE_ID_QUERY_KEY in parameters:
        configurations = load_configuration_from_database(parameters)

        if not configurations:
            issuer = remove_last_slash(parameters[ISSUER_QUERY_KEY])
            instance_id = parameters[INSTANCE_ID_QUERY_KEY]
            port_db = PortDatabase(CONF.PORT_DATABASE_FILE)
            port = port_db.get_port(issuer, instance_id)
            configurations = identify_existing_config_file(port, CONF.OPRP_DIR_PATH)

        store_query_parameter(parameters, session, ISSUER_QUERY_KEY)
        store_query_parameter(parameters, session, INSTANCE_ID_QUERY_KEY)

        if configurations:
            session[OP_CONFIG] = configurations
        else:
            session[OP_CONFIG] = get_default_client()

        session[IS_RECONFIGURING] = True
        return response_encoder.return_json("{}")
    return response_encoder.bad_request()
 def test_identify_config_file_which_does_not_exist(self):
     assert None == identify_existing_config_file(-1, ".")