You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by fo...@apache.org on 2018/05/04 07:02:37 UTC
[41/50] incubator-airflow git commit: [AIRFLOW-2409] Supply password
as a parameter
[AIRFLOW-2409] Supply password as a parameter
Supply the password as a parameter on the cli
Closes #3304 from Fokko/supply-password
Project: http://git-wip-us.apache.org/repos/asf/incubator-airflow/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-airflow/commit/2a079b95
Tree: http://git-wip-us.apache.org/repos/asf/incubator-airflow/tree/2a079b95
Diff: http://git-wip-us.apache.org/repos/asf/incubator-airflow/diff/2a079b95
Branch: refs/heads/v1-10-test
Commit: 2a079b953fe35049805079684fe43a1499694e4b
Parents: 71954a5
Author: Fokko Driesprong <fo...@godatadriven.com>
Authored: Thu May 3 08:32:51 2018 +0200
Committer: Fokko Driesprong <fo...@godatadriven.com>
Committed: Thu May 3 08:32:51 2018 +0200
----------------------------------------------------------------------
airflow/bin/cli.py | 8 +++++++-
tests/core.py | 15 +++++++++++----
2 files changed, 18 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/2a079b95/airflow/bin/cli.py
----------------------------------------------------------------------
diff --git a/airflow/bin/cli.py b/airflow/bin/cli.py
index f26cbe4..3097dce 100644
--- a/airflow/bin/cli.py
+++ b/airflow/bin/cli.py
@@ -1221,6 +1221,8 @@ def create_user(args):
if args.use_random_password:
password = ''.join(random.choice(string.printable) for _ in range(16))
+ elif args.password:
+ password = args.password
else:
password = getpass.getpass('Password:')
password_confirmation = getpass.getpass('Repeat for confirmation:')
@@ -1622,6 +1624,10 @@ class CLIFactory(object):
('-u', '--username',),
help='Username of the user',
type=str),
+ 'password': Arg(
+ ('-p', '--password',),
+ help='Password of the user',
+ type=str),
'use_random_password': Arg(
('--use_random_password',),
help='Do not prompt for password. Use random string instead',
@@ -1768,7 +1774,7 @@ class CLIFactory(object):
'func': create_user,
'help': "Create an admin account",
'args': ('role', 'username', 'email', 'firstname', 'lastname',
- 'use_random_password'),
+ 'password', 'use_random_password'),
},
)
subparsers_dict = {sp['func'].__name__: sp for sp in subparsers}
http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/2a079b95/tests/core.py
----------------------------------------------------------------------
diff --git a/tests/core.py b/tests/core.py
index 6d18ffe..4cece16 100644
--- a/tests/core.py
+++ b/tests/core.py
@@ -7,9 +7,9 @@
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -983,13 +983,20 @@ class CliTests(unittest.TestCase):
args = self.parser.parse_args(['list_dags', '--report'])
cli.list_dags(args)
- def test_cli_create_user(self):
+ def test_cli_create_user_random_password(self):
args = self.parser.parse_args([
- 'create_user', '-u', 'test', '-l', 'doe', '-f', 'jon',
+ 'create_user', '-u', 'test1', '-l', 'doe', '-f', 'jon',
'-e', 'jdoe@foo.com', '-r', 'Viewer', '--use_random_password'
])
cli.create_user(args)
+ def test_cli_create_user_supplied_password(self):
+ args = self.parser.parse_args([
+ 'create_user', '-u', 'test2', '-l', 'doe', '-f', 'jon',
+ '-e', 'jdoe@apache.org', '-r', 'Viewer', '-p', 'test'
+ ])
+ cli.create_user(args)
+
def test_cli_list_tasks(self):
for dag_id in self.dagbag.dags.keys():
args = self.parser.parse_args(['list_tasks', dag_id])