def create_database() -> None: try: # try to access the system database with default credentials. # this only works if arango has been started with default settings. http_client = ArangoHTTPClient(args.graphdb_request_timeout, not args.graphdb_no_ssl_verify) root_pw = args.graphdb_root_password secure_root = not args.graphdb_bootstrap_do_not_secure root_db = ArangoClient( hosts=args.graphdb_server, http_client=http_client).db(password=root_pw) root_db.echo( ) # this call will fail, if we are not allowed to access the system db user = args.graphdb_username passwd = args.graphdb_password database = args.graphdb_database change = False if not root_db.has_user(user): log.info( "Configured graph db user does not exist. Create it.") root_db.create_user(user, passwd, active=True) change = True if not root_db.has_database(database): log.info( "Configured graph db database does not exist. Create it." ) root_db.create_database( database, [{ "username": user, "password": passwd, "active": True, "extra": { "generated": "resoto" } }], ) change = True if change and secure_root and root_pw == "" and passwd != "" and passwd not in { "test" }: root_db.replace_user("root", passwd, True) log.info( "Database is using an empty password. " "Secure the root account with the provided user password. " "Login to the Resoto database via provided username and password. " "Login to the System database via `root` and provided password!" ) if not change: log.info( "Not allowed to access database, while user and database exist. Wrong password?" ) except Exception as ex: log.error( "Database or user does not exist or does not have enough permissions. " f"Attempt to create user/database via default system account is not possible. Reason: {ex}. " "You can provide the password of the root user via --graphdb-root-password to setup " "a Resoto user and database automatically.")
from __future__ import absolute_import, unicode_literals import pytest from arango import ArangoClient from arango.exceptions import (WALConfigureError, WALFlushError, WALPropertiesError, WALTransactionListError) from .utils import generate_user_name arango_client = ArangoClient() wal = arango_client.wal username = generate_user_name(arango_client) user = arango_client.create_user(username, 'password') def teardown_module(*_): arango_client.delete_user(username, ignore_missing=True) @pytest.mark.order1 def test_wal_properties(): properties = wal.properties() assert 'ArangoDB write-ahead log' in repr(wal) assert 'oversized_ops' in properties assert 'log_size' in properties assert 'historic_logs' in properties assert 'reserve_logs' in properties @pytest.mark.order2
from .utils import ( generate_db_name, generate_col_name, generate_user_name ) arango_client = ArangoClient() db_name = generate_db_name(arango_client) db = arango_client.create_database(db_name) col_name = generate_col_name(db) db.create_collection(col_name) username = generate_user_name(arango_client) user = arango_client.create_user(username, 'password') func_name = '' func_body = '' def teardown_module(*_): arango_client.delete_database(db_name, ignore_missing=True) arango_client.delete_user(username, ignore_missing=True) @pytest.mark.order1 def test_init(): assert isinstance(db.aql, AQL) assert 'ArangoDB AQL' in repr(db.aql) @pytest.mark.order2