summaryrefslogtreecommitdiff
path: root/server/pkg
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2016-04-08 02:14:20 -0400
committerKali Kaneko <kali@leap.se>2016-06-06 19:58:50 -0400
commit4c1269f37ad67337d9ad65bcb24ccc5e8eeb1950 (patch)
treefdf22dd62665f6d1951ee4499fb8e0eca659d05b /server/pkg
parent1fd07f013736599159c364b774ca5b3c6c6747c0 (diff)
[refactor] adapt create-user-db script to bypass auth for local tests
Diffstat (limited to 'server/pkg')
-rwxr-xr-xserver/pkg/create-user-db30
1 files changed, 20 insertions, 10 deletions
diff --git a/server/pkg/create-user-db b/server/pkg/create-user-db
index 54856643..5e48d4de 100755
--- a/server/pkg/create-user-db
+++ b/server/pkg/create-user-db
@@ -25,6 +25,9 @@ from leap.soledad.common.couch import list_users_dbs
from leap.soledad.server import load_configuration
+BYPASS_AUTH = os.environ.get('SOLEDAD_BYPASS_AUTH', False)
+
+
description = """
Creates a user database.
This is meant to be used by Soledad Server.
@@ -40,16 +43,23 @@ NETRC_PATH = CONF['soledad-server']['admin_netrc']
def url_for_db(dbname):
- if not os.path.exists(NETRC_PATH):
- print ('netrc not found in %s' % NETRC_PATH)
- sys.exit(1)
- parsed_netrc = netrc.netrc(NETRC_PATH)
- host, (login, _, password) = parsed_netrc.hosts.items()[0]
- url = ('http://%(login)s:%(password)s@%(host)s:5984/%(dbname)s' % {
- 'login': login,
- 'password': password,
- 'host': host,
- 'dbname': dbname})
+ if BYPASS_AUTH:
+ login = ''
+ password = ''
+ host = 'localhost'
+ url = 'http://localhost:5984/%(dbname)s' % {
+ 'dbname': dbname}
+ else:
+ if not os.path.exists(NETRC_PATH):
+ print ('netrc not found in %s' % NETRC_PATH)
+ sys.exit(1)
+ parsed_netrc = netrc.netrc(NETRC_PATH)
+ host, (login, _, password) = parsed_netrc.hosts.items()[0]
+ url = ('http://%(login)s:%(password)s@%(host)s:5984/%(dbname)s' % {
+ 'login': login,
+ 'password': password,
+ 'host': host,
+ 'dbname': dbname})
return url