コード例 #1
0
ファイル: server_test.py プロジェクト: kimdwkimdw/geofront
def test_remote_dict():
    remote = Remote('username', '127.0.0.1', 2222)
    assert remote_dict(remote) == {
        'user': '******',
        'host': '127.0.0.1',
        'port': 2222
    }
コード例 #2
0
ファイル: server_test.py プロジェクト: kimdwkimdw/geofront
def test_authorize_remote(fx_app, fx_authorized_servers, fx_master_key,
                          fx_authorized_remote_set, fx_authorized_identity,
                          fx_token_id, fx_key_store):
    public_key = RSAKey.generate(1024)
    fx_key_store.register(fx_authorized_identity, public_key)
    alias, remote = dict(fx_authorized_remote_set).popitem()
    with fx_app.test_client() as client:
        response = client.post(
            get_url('authorize_remote', token_id=fx_token_id, alias=alias)
        )
        assert response.status_code == 200
        assert response.mimetype == 'application/json'
        result = json.loads(response.data)
        assert result['success'] == 'authorized'
        assert result['remote'] == remote_dict(remote)
        expires_at = parse_date(result['expires_at'])
    thread, path, ev = fx_authorized_servers[remote.port]
    authorized_keys_path = path.join('.ssh', 'authorized_keys')
    with authorized_keys_path.open() as f:
        saved_keys = map(parse_openssh_pubkey, f)
        assert frozenset(saved_keys) == {fx_master_key, public_key}
    while datetime.datetime.now(datetime.timezone.utc) <= expires_at:
        time.sleep(1)
    time.sleep(1)
    with authorized_keys_path.open() as f:
        saved_keys = map(parse_openssh_pubkey, f)
        assert frozenset(saved_keys) == {fx_master_key}
コード例 #3
0
ファイル: server_test.py プロジェクト: allanice001/geofront
def test_authorize_remote(fx_app, fx_authorized_servers, fx_master_key,
                          fx_authorized_remote_set, fx_authorized_identity,
                          fx_token_id, fx_key_store):
    public_key = RSAKey.generate(1024)
    fx_key_store.register(fx_authorized_identity, public_key)
    alias, remote = dict(fx_authorized_remote_set).popitem()
    with fx_app.test_client() as client:
        response = client.post(
            get_url('authorize_remote', token_id=fx_token_id, alias=alias))
        assert response.status_code == 200
        assert response.mimetype == 'application/json'
        result = json.loads(response.get_data())
        assert result['success'] == 'authorized'
        assert result['remote'] == remote_dict(remote)
        expires_at = parse_date(result['expires_at'])
    thread, path, ev = fx_authorized_servers[remote.port]
    authorized_keys_path = path.join('.ssh', 'authorized_keys')
    with authorized_keys_path.open() as f:
        saved_keys = map(parse_openssh_pubkey, f)
        assert frozenset(saved_keys) == {fx_master_key, public_key}
    while datetime.datetime.now(datetime.timezone.utc) <= expires_at:
        time.sleep(1)
    time.sleep(1)
    with authorized_keys_path.open() as f:
        saved_keys = map(parse_openssh_pubkey, f)
        assert frozenset(saved_keys) == {fx_master_key}
コード例 #4
0
ファイル: server_test.py プロジェクト: allanice001/geofront
def test_remote_dict():
    remote = Remote('username', '127.0.0.1', 2222)
    assert remote_dict(remote) == {
        'user': '******',
        'host': '127.0.0.1',
        'port': 2222
    }
コード例 #5
0
ファイル: server_test.py プロジェクト: kimdwkimdw/geofront
def test_list_remotes(fx_app, fx_mock_remote_set,
                      fx_authorized_identity, fx_token_id):
    with fx_app.test_client() as client:
        response = client.get(get_url('list_remotes', token_id=fx_token_id))
        assert response.status_code == 200
        assert response.mimetype == 'application/json'
        assert json.loads(response.data) == {
            alias: remote_dict(remote)
            for alias, remote in fx_mock_remote_set.items()
        }
コード例 #6
0
ファイル: server_test.py プロジェクト: allanice001/geofront
def test_list_remotes(fx_app, fx_mock_remote_set, fx_authorized_identity,
                      fx_token_id):
    with fx_app.test_client() as client:
        response = client.get(get_url('list_remotes', token_id=fx_token_id))
        assert response.status_code == 200
        assert response.mimetype == 'application/json'
        assert json.loads(response.get_data()) == {
            alias: remote_dict(remote)
            for alias, remote in fx_mock_remote_set.items()
        }
コード例 #7
0
ファイル: server_test.py プロジェクト: gitter-badger/geofront
def test_remote_dict():
    remote = Remote("username", "127.0.0.1", 2222)
    assert remote_dict(remote) == {"user": "******", "host": "127.0.0.1", "port": 2222}