Пример #1
0
def test_list_instances__oidc_file__file_config_does_not_exist__oidc_should_be_disabled(
        mocker):
    mock_instances = [{
        "name": "escape",
        "display_name": "ESCAPE",
        "mode": "replica",
        "rucio_base_url": "https://rucio-cms",
        "destination_rse": "SWAN-EOS",
        "rse_mount_path": "/eos/user/rucio",
        "path_begins_at": 4,
        "oidc_auth": "file",
    }]

    mocker.patch('rucio_jupyterlab.config.config.get_oidc_token',
                 return_value=None)

    mock_config = Struct(instances=mock_instances)
    config = Config(mock_config)

    expected_instances = [
        {
            'display_name': 'ESCAPE',
            'name': 'escape',
            'oidc_enabled': False
        },
    ]

    assert config.list_instances() == expected_instances, "Invalid instances"
Пример #2
0
def test_list_instances__oidc_disabled():
    mock_instances = [{
        "name": "atlas",
        "display_name": "ATLAS",
        "mode": "replica",
        "rucio_base_url": "https://rucio",
        "destination_rse": "SWAN-EOS",
        "rse_mount_path": "/eos/user/rucio",
        "path_begins_at": 4
    }, {
        "name": "cms",
        "display_name": "CMS",
        "mode": "replica",
        "rucio_base_url": "https://rucio-cms",
        "destination_rse": "SWAN-EOS",
        "rse_mount_path": "/eos/user/rucio",
        "path_begins_at": 4
    }]

    mock_config = Struct(instances=mock_instances)
    config = Config(mock_config)

    expected_instances = [{
        'display_name': 'ATLAS',
        'name': 'atlas',
        'oidc_enabled': False
    }, {
        'display_name': 'CMS',
        'name': 'cms',
        'oidc_enabled': False
    }]

    assert config.list_instances() == expected_instances, "Invalid instances"
Пример #3
0
def test_config_init__remote_config__schema_valid__overlapping_item(
        requests_mock):
    mock_instances = [{
        "name": "cms",
        "display_name": "CMS-Local",
        "mode": "replica",
        "$url": "http://localhost/rucio.json"
    }]

    mock_config = Struct(instances=mock_instances)

    remote_config = {
        "display_name": "CMS-Remote",
        "rucio_base_url": "https://rucio",
        "destination_rse": "SWAN-EOS",
        "rse_mount_path": "/eos/user/rucio",
        "path_begins_at": 1
    }

    requests_mock.get("http://localhost/rucio.json", json=remote_config)
    config = Config(mock_config)

    expected_config = {
        "name": "cms",
        "display_name": "CMS-Local",
        "mode": "replica",
        "$url": "http://localhost/rucio.json",
        "rucio_base_url": "https://rucio",
        "destination_rse": "SWAN-EOS",
        "rse_mount_path": "/eos/user/rucio",
        "path_begins_at": 1
    }

    assert config.get_instance_config(
        'cms') == expected_config, "Invalid remote config format"
Пример #4
0
def test_config_init__local_config__download_mode__schema_valid():
    mock_instances = [{
        "name": "atlas",
        "display_name": "ATLAS",
        "rucio_base_url": "https://rucio",
        "mode": "download",
        "rucio_ca_cert": '/opt/rucio.pem'
    }]

    mock_config = Struct(instances=mock_instances)
    config = Config(mock_config)

    assert config.get_instance_config(
        'atlas') == mock_instances[0], "Invalid instances"
Пример #5
0
def setup_handlers(web_app):  # pragma: no cover
    host_pattern = ".*$"

    rucio_config = RucioConfig(config=web_app.settings['config'])
    config = Config(rucio_config)
    rucio_factory = RucioAPIFactory(config=config)

    handler_params = dict(rucio_config=config, rucio=rucio_factory)

    base_url = web_app.settings["base_url"]
    base_path = url_path_join(base_url, 'rucio-jupyterlab')
    handlers = [
        (url_path_join(base_path,
                       'instances'), InstancesHandler, handler_params),
        (url_path_join(base_path, 'auth'), AuthConfigHandler, handler_params),
        (url_path_join(base_path, 'files'), DIDBrowserHandler, handler_params),
        (url_path_join(base_path, 'did'), DIDDetailsHandler, handler_params),
        (url_path_join(base_path,
                       'did-search'), DIDSearchHandler, handler_params),
        (url_path_join(base_path, 'did', 'make-available'),
         DIDMakeAvailableHandler, handler_params),
        (url_path_join(base_path,
                       'file-browser'), FileBrowserHandler, handler_params),
        (url_path_join(base_path,
                       'purge-cache'), PurgeCacheHandler, handler_params)
    ]
    web_app.add_handlers(host_pattern, handlers)
Пример #6
0
def test_config_init__local_config__replica_mode__schema_valid():
    mock_instances = [{
        "name": "atlas",
        "display_name": "ATLAS",
        "rucio_base_url": "https://rucio",
        "mode": "replica",
        "destination_rse": "SWAN-EOS",
        "rse_mount_path": "/eos/user/rucio",
        "path_begins_at": 4
    }]

    mock_config = Struct(instances=mock_instances)
    config = Config(mock_config)

    assert config.get_instance_config(
        'atlas') == mock_instances[0], "Invalid instances"
Пример #7
0
def test_config_init__local_config__download_mode__schema_invalid():
    mock_instances = [{
        "display_name": "ATLAS",
        "rucio_base_url": "https://rucio",
        "mode": "download"
    }]

    mock_config = Struct(instances=mock_instances)

    with pytest.raises(ValidationError):
        Config(mock_config)
Пример #8
0
def test_config_init__local_config__replica_mode__schema_invalid():
    mock_instances = [{
        "display_name": "ATLAS",
        "rucio_base_url": "https://rucio",
        "mode": "replica",
        "rse_mount_path": "/eos/user/rucio",
        "path_begins_at": 4
    }]

    mock_config = Struct(instances=mock_instances)

    with pytest.raises(ValidationError):
        Config(mock_config)
Пример #9
0
def test_config_init__remote_config__schema_invalid(requests_mock):
    mock_instances = [{
        "name": "cms",
        "display_name": "CMS",
        "mode": "replica",
        "$url": "http://localhost/rucio.json"
    }]

    mock_config = Struct(instances=mock_instances)

    remote_config = {"rse_mount_path": "/eos/user/rucio", "path_begins_at": 1}

    requests_mock.get("http://localhost/rucio.json", json=remote_config)

    with pytest.raises(ValidationError):
        Config(mock_config)