Exemple #1
0
def test_user_management(zeo_server):
    storage = client_storage(zeo_server,
            username="******", password=TEST_PASSPHRASE, realm="ZERO")

    pk0 = ecc.private("passY").get_pubkey()
    pk = ecc.private("passX").get_pubkey()
    storage.add_user("userX", pk0)
    storage.change_key("userX", pk)

    storage = client_storage(zeo_server,
            username="******", password="******", realm="ZERO")
    with pytest.raises(AssertionError):
        storage.add_user("shouldfail", pk)
Exemple #2
0
def run(username, passphrase, sock):
    logging.basicConfig()
    username = str(username)
    passphrase = str(passphrase)
    sock = str(sock)
    if not sock.startswith("/"):
        sock = (sock.split(":")[0], int(sock.split(":")[1]))
    DB.auth_module.register_auth()
    DB.encrypter.register_class(default=True)
    init_crypto(passphrase=passphrase)

    def useradd(username, password):
        storage.add_user(username, password)

    def userdel(username):
        storage.del_user(username)

    def chpass(username, password):
        storage.change_key(username, password)

    print "Usage:"
    print "========"
    print "useradd(username, password) - add user"
    print "userdel(username) - remove user"
    print "chpass(username, password) - change passphrase"
    print "exit() or ^D - exit"

    storage = client_storage(sock,
            username=username, password=passphrase, realm="ZERO")
    embed(display_banner=False)
Exemple #3
0
def console():
    """
    Console for managing users (add, remove, change password)
    """

    def useradd(username, password):
        storage.add_user(username, password)

    def userdel(username):
        storage.del_user(username)

    def chpass(username, password):
        storage.change_key(username, password)

    banner = "\n".join([
            "Usage:",
            "========",
            "useradd(username, password) - add user",
            "userdel(username) - remove user",
            "chpass(username, password) - change passphrase",
            "exit() or ^D - exit"
            ])

    DB.auth_module.register_auth()
    DB.encrypter.register_class(default=True)
    init_crypto(passphrase=_passphrase)

    storage = client_storage(_sock,
            username=_username, password=_passphrase, realm="ZERO")
    embed(banner1=banner)
Exemple #4
0
def console():
    """
    Console for managing users (add, remove, change password)
    """
    def useradd(username, password):
        storage.add_user(username, password)

    def userdel(username):
        storage.del_user(username)

    def chpass(username, password):
        storage.change_key(username, password)

    banner = "\n".join([
        "Usage:", "========", "useradd(username, password) - add user",
        "userdel(username) - remove user",
        "chpass(username, password) - change passphrase", "exit() or ^D - exit"
    ])

    DB.auth_module.register_auth()
    DB.encrypter.register_class(default=True)
    init_crypto(passphrase=_passphrase)

    storage = client_storage(_sock,
                             username=_username,
                             password=_passphrase,
                             realm="ZERO")
    embed(banner1=banner)
Exemple #5
0
def console():
    """
    Console for managing users (add, remove, change password)
    """

    def useradd(username, pubkey):
        storage.add_user(username, binascii.unhexlify(pubkey))

    def userdel(username):
        storage.del_user(username)

    def chkey(username, pubkey):
        storage.change_key(username, binascii.unhexlify(pubkey))

    banner = "\n".join([
            "Usage:",
            "========",
            "useradd(username, pubkey) - add user",
            "userdel(username) - remove user",
            "chkey(username, pubkey) - change pubkey",
            "get_pubkey(username, password) - get public key from passphrase",
            "exit() or ^D - exit"])

    DB.auth_module.register_auth()
    DB._init_default_crypto(passphrase=_passphrase)

    storage = client_storage(
            _sock, username=_username, password=_passphrase, realm=_realm)
    embed(banner1=banner)
Exemple #6
0
 def _init_db(self):
     """We need this to be executed each time we are in a new process"""
     self.__conn_refs = {}
     self.__thread_local = threading.local()
     self.__thread_watcher = ThreadWatcher()
     self._storage = client_storage(**self.__storage_kwargs)
     self._db = DB.db_factory(self._storage, **self.__db_kwargs)
     self._conn_open()
def test_user_management(zeo_server):
    storage = client_storage(zeo_server,
                             username="******",
                             password=TEST_PASSPHRASE,
                             realm="ZERO")

    pk0 = ecc.private("passY").get_pubkey()
    pk = ecc.private("passX").get_pubkey()
    storage.add_user("userX", pk0)
    storage.change_key("userX", pk)

    storage = client_storage(zeo_server,
                             username="******",
                             password="******",
                             realm="ZERO")
    with pytest.raises(AssertionError):
        storage.add_user("shouldfail", pk)
Exemple #8
0
 def _init_db(self):
     """We need this to be executed each time we are in a new process"""
     self.__conn_refs = {}
     self.__thread_local = threading.local()
     self.__thread_watcher = ThreadWatcher()
     self._storage = client_storage(**self.__storage_kwargs)
     self._db = DB.db_factory(self._storage, **self.__db_kwargs)
     self._conn_open()
def test_user_management(zeo_server, abort):
    storage = client_storage(
            zeo_server, username="******", password=TEST_PASSPHRASE, realm="ZERO")

    pk1 = ecc.private("passY", ("userX", "ZERO"), kdf=kdf).get_pubkey()
    pk2 = ecc.private("passX", ("userX", "ZERO"), kdf=kdf).get_pubkey()

    with transaction.manager:
        storage.add_user("userX", pk1)
        storage.change_key("userX", pk2)

    with pytest.raises(LookupError):
        storage.add_user("userX", pk1)

    storage = client_storage(
            zeo_server, username="******", password="******", realm="ZERO")

    with pytest.raises(AssertionError):
        storage.add_user("shouldfail", pk1)
def test_user_management_abort(zeo_server, abort):
    storage = client_storage(
            zeo_server, username="******", password=TEST_PASSPHRASE, realm="ZERO")

    pk1 = ecc.private("passY", ("userY", "ZERO"), kdf=kdf).get_pubkey()

    storage.add_user("userY", pk1)

    with pytest.raises(LookupError):
        storage.add_user("userY", pk1)

    transaction.abort()
Exemple #11
0
    def _init_db(self):
        """We need this to be executed each time we are in a new process"""
        if self._autoreindex:
            subscribers.init()

        Random.atfork()

        self.__conn_refs = {}
        self.__thread_local = threading.local()
        self.__thread_watcher = ThreadWatcher()
        self._storage = client_storage(**self.__storage_kwargs)
        self._db = SubDB(self._storage, **self.__db_kwargs)
        self._conn_open()
Exemple #12
0
    def _init_db(self):
        """We need this to be executed each time we are in a new process"""
        if self._autoreindex:
            subscribers.init()

        Random.atfork()

        self.__conn_refs = {}
        self.__thread_local = threading.local()
        self.__thread_watcher = ThreadWatcher()
        self._storage = client_storage(**self.__storage_kwargs)
        self._db = SubDB(self._storage, **self.__db_kwargs)
        self._conn_open()
Exemple #13
0
def test_ecc_auth(zeo_server):
    # Presumably, ecc_server already registered auth protocol
    storage = client_storage(zeo_server,
            username="******", password=TEST_PASSPHRASE, realm="ZERO")

    with pytest.raises(StorageError):  # Cannot access common root
        storage.load(z64)

    db = subdb.DB(storage)
    conn = db.open()
    conn.root()

    assert db._root_oid != z64
    assert type(db._root_oid) == str

    conn.close()
Exemple #14
0
def test_ecc_auth(zeo_server):
    # Presumably, ecc_server already registered auth protocol
    storage = client_storage(zeo_server,
                             username="******",
                             password=TEST_PASSPHRASE,
                             realm="ZERO")

    with pytest.raises(StorageError):  # Cannot access common root
        storage.load(z64)

    db = subdb.DB(storage)
    conn = db.open()
    conn.root()

    assert db._root_oid != z64
    assert type(db._root_oid) == str

    conn.close()
Exemple #15
0
def zeo_storage(request, zeo_server):
    return client_storage(zeo_server,
            username="******", password=TEST_PASSPHRASE, realm="ZERO", debug=True)
Exemple #16
0
def zeo_storage(request, zeo_server):
    return client_storage(zeo_server,
                          username="******",
                          password=TEST_PASSPHRASE,
                          realm="ZERO",
                          debug=True)