Esempio n. 1
0
def test_validate_grid_conflicting_servers(monkeypatch, tmpdir_factory):
    config_dir = str(tmpdir_factory.mktemp('config_dir'))
    monkeypatch.setattr('gridsync.setup.config_dir', config_dir)
    private_dir = os.path.join(config_dir, 'ExistingGrid', 'private')
    os.makedirs(private_dir)
    servers = {
        'storage': {
            'v0-aaaaaaaa': {
                'ann': {
                    'anonymous-storage-FURL': 'pb://11111111',
                    'nickname': 'node-1'
                }
            }
        }
    }
    with open(os.path.join(private_dir, 'servers.yaml'), 'w') as f:
        f.write(yaml.safe_dump(servers, default_flow_style=False))
    monkeypatch.setattr('gridsync.setup.prompt_for_grid_name', lambda x, y:
                        ('NewGridName', 1))
    settings = {
        'nickname': 'ExistingGrid',
        'storage': {
            'anonymous-storage-FURL': 'pb://11111111',
            'nickname': 'node-1'
        }
    }
    assert validate_grid(settings) == {
        'nickname': 'NewGridName',
        'storage': {
            'anonymous-storage-FURL': 'pb://11111111',
            'nickname': 'node-1'
        }
    }
Esempio n. 2
0
def test_validate_grid_conflicting_servers(monkeypatch, tmpdir_factory):
    config_dir = str(tmpdir_factory.mktemp("config_dir"))
    monkeypatch.setattr("gridsync.setup.config_dir", config_dir)
    private_dir = os.path.join(config_dir, "ExistingGrid", "private")
    os.makedirs(private_dir)
    servers = {
        "storage": {
            "v0-aaaaaaaa": {
                "ann": {
                    "anonymous-storage-FURL": "pb://11111111",
                    "nickname": "node-1",
                }
            }
        }
    }
    with open(os.path.join(private_dir, "servers.yaml"), "w") as f:
        f.write(yaml.safe_dump(servers, default_flow_style=False))
    monkeypatch.setattr(
        "gridsync.setup.prompt_for_grid_name", lambda x, y: ("NewGridName", 1)
    )
    settings = {
        "nickname": "ExistingGrid",
        "storage": {
            "anonymous-storage-FURL": "pb://11111111",
            "nickname": "node-1",
        },
    }
    assert validate_grid(settings) == {
        "nickname": "NewGridName",
        "storage": {
            "anonymous-storage-FURL": "pb://11111111",
            "nickname": "node-1",
        },
    }
Esempio n. 3
0
def test_validate_grid_no_nickname(monkeypatch, tmpdir_factory):
    monkeypatch.setattr(
        "gridsync.setup.config_dir", str(tmpdir_factory.mktemp("config_dir"))
    )
    monkeypatch.setattr(
        "gridsync.setup.prompt_for_grid_name", lambda x, y: ("NewGridName", 1)
    )
    assert validate_grid({"nickname": None}) == {"nickname": "NewGridName"}
Esempio n. 4
0
def test_validate_grid_conflicting_introducer(monkeypatch, tmpdir_factory):
    config_dir = str(tmpdir_factory.mktemp('config_dir'))
    monkeypatch.setattr('gridsync.setup.config_dir', config_dir)
    nodedir = os.path.join(config_dir, 'ExistingGrid')
    os.makedirs(nodedir)
    with open(os.path.join(nodedir, 'tahoe.cfg'), 'w') as f:
        f.write('[client]\nintroducer.furl = pb://11111\n')
    monkeypatch.setattr('gridsync.setup.prompt_for_grid_name', lambda x, y:
                        ('NewGridName', 1))
    settings = {'nickname': 'ExistingGrid', 'introducer': 'pb://22222'}
    assert validate_grid(settings) == {
        'nickname': 'NewGridName',
        'introducer': 'pb://22222'
    }
Esempio n. 5
0
def test_validate_grid_conflicting_introducer(monkeypatch, tmpdir_factory):
    config_dir = str(tmpdir_factory.mktemp("config_dir"))
    monkeypatch.setattr("gridsync.setup.config_dir", config_dir)
    nodedir = os.path.join(config_dir, "ExistingGrid")
    os.makedirs(nodedir)
    with open(os.path.join(nodedir, "tahoe.cfg"), "w") as f:
        f.write("[client]\nintroducer.furl = pb://11111\n")
    monkeypatch.setattr(
        "gridsync.setup.prompt_for_grid_name", lambda x, y: ("NewGridName", 1)
    )
    settings = {"nickname": "ExistingGrid", "introducer": "pb://22222"}
    assert validate_grid(settings) == {
        "nickname": "NewGridName",
        "introducer": "pb://22222",
    }
Esempio n. 6
0
def test_validate_grid_no_nickname(monkeypatch, tmpdir_factory):
    monkeypatch.setattr('gridsync.setup.config_dir',
                        str(tmpdir_factory.mktemp('config_dir')))
    monkeypatch.setattr('gridsync.setup.prompt_for_grid_name', lambda x, y:
                        ('NewGridName', 1))
    assert validate_grid({'nickname': None}) == {'nickname': 'NewGridName'}