From 9854e8c719d16718219049ce02206b83c93bf2c6 Mon Sep 17 00:00:00 2001 From: ocket8888 Date: Mon, 8 Jun 2020 10:28:40 -0600 Subject: [PATCH 1/4] Added email and full name to user-add CiaB script --- infrastructure/cdn-in-a-box/traffic_ops/adduser.pl | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/infrastructure/cdn-in-a-box/traffic_ops/adduser.pl b/infrastructure/cdn-in-a-box/traffic_ops/adduser.pl index 31503c8ff8..371f8fb91f 100755 --- a/infrastructure/cdn-in-a-box/traffic_ops/adduser.pl +++ b/infrastructure/cdn-in-a-box/traffic_ops/adduser.pl @@ -24,23 +24,27 @@ use Crypt::ScryptKDF qw{ scrypt_hash }; if ($#ARGV < 2) { - die "Usage: $ARGV[0] \n"; + die "Usage: $ARGV[0] USERNAME PASSWORD [ROLE] [TENANT] [EMAIL] [FULL_NAME]\n"; } my $username = shift // 'admin'; my $password = shift or die "Password is required\n"; my $role = shift // 'admin'; my $tenant = shift // 'root'; +my $email = shift // 'admin@no-reply.trafficops.infra.ciab.test'; +my $full_name = shift // 'James Cole' # Skip the insert if the admin 'username' is already there. my $hashed_passwd = hash_pass( $password ); print <<"EOSQL"; -INSERT INTO tm_user (username, role, local_passwd, confirm_local_passwd, tenant_id) +INSERT INTO tm_user (username, role, local_passwd, confirm_local_passwd, tenant_id, email, full_name) VALUES ('$username', (SELECT id FROM role WHERE name = '$role'), '$hashed_passwd', '$hashed_passwd', - (SELECT id FROM tenant WHERE name='$tenant')) + (SELECT id FROM tenant WHERE name='$tenant'), + '$email', + '$full_name') ON CONFLICT (username) DO UPDATE SET local_passwd='$hashed_passwd', confirm_local_passwd='$hashed_passwd'; EOSQL From 98ad8db8e77c5f5b7d2ce742456ece129b6657d4 Mon Sep 17 00:00:00 2001 From: ocket8888 Date: Mon, 8 Jun 2020 10:29:05 -0600 Subject: [PATCH 2/4] Made CiaB admin password compliant with TP min-length --- infrastructure/cdn-in-a-box/variables.env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infrastructure/cdn-in-a-box/variables.env b/infrastructure/cdn-in-a-box/variables.env index 8a9bdfa60f..f887c7dd80 100644 --- a/infrastructure/cdn-in-a-box/variables.env +++ b/infrastructure/cdn-in-a-box/variables.env @@ -68,7 +68,7 @@ TM_LOG_ERROR=stdout TM_LOG_WARNING=stdout TM_LOG_INFO=stdout TM_LOG_DEBUG=stdout -TO_ADMIN_PASSWORD=twelve +TO_ADMIN_PASSWORD=twelve12 TO_ADMIN_USER=admin # Set TM_DEBUG_ENABLE to true`to debug Traffic Monitor with Delve TM_DEBUG_ENABLE=false From 85ad511a6f68fadc7812f3029fb475ba8e442a30 Mon Sep 17 00:00:00 2001 From: ocket8888 Date: Mon, 8 Jun 2020 10:35:38 -0600 Subject: [PATCH 3/4] Fixed TP integration test to use env vars for creds --- .../cdn-in-a-box/traffic_portal_integration_test/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infrastructure/cdn-in-a-box/traffic_portal_integration_test/run.sh b/infrastructure/cdn-in-a-box/traffic_portal_integration_test/run.sh index 1186c29195..d42a9ac9ec 100755 --- a/infrastructure/cdn-in-a-box/traffic_portal_integration_test/run.sh +++ b/infrastructure/cdn-in-a-box/traffic_portal_integration_test/run.sh @@ -44,7 +44,7 @@ done cat conf.js -protractor conf.js --params.adminUser 'admin' --params.adminPassword 'twelve' +protractor conf.js --params.adminUser "$TO_ADMIN_USER" --params.adminPassword "$TO_ADMIN_PASSWORD" rc=$? cp /portaltestresults/* /junit/ From 8e2669a05aee437ec796e356effb9ba6f6b47632 Mon Sep 17 00:00:00 2001 From: ocket8888 Date: Mon, 8 Jun 2020 13:37:08 -0600 Subject: [PATCH 4/4] Using env vars for user defaults --- infrastructure/cdn-in-a-box/traffic_ops/adduser.pl | 6 +++--- infrastructure/cdn-in-a-box/variables.env | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/infrastructure/cdn-in-a-box/traffic_ops/adduser.pl b/infrastructure/cdn-in-a-box/traffic_ops/adduser.pl index 371f8fb91f..31dba2d9d2 100755 --- a/infrastructure/cdn-in-a-box/traffic_ops/adduser.pl +++ b/infrastructure/cdn-in-a-box/traffic_ops/adduser.pl @@ -27,12 +27,12 @@ die "Usage: $ARGV[0] USERNAME PASSWORD [ROLE] [TENANT] [EMAIL] [FULL_NAME]\n"; } -my $username = shift // 'admin'; +my $username = shift // $ENV{TO_ADMIN_USER}; my $password = shift or die "Password is required\n"; my $role = shift // 'admin'; my $tenant = shift // 'root'; -my $email = shift // 'admin@no-reply.trafficops.infra.ciab.test'; -my $full_name = shift // 'James Cole' +my $email = shift // $ENV{TO_EMAIL}; +my $full_name = shift // $ENV{TO_ADMIN_FULL_NAME}; # Skip the insert if the admin 'username' is already there. my $hashed_passwd = hash_pass( $password ); diff --git a/infrastructure/cdn-in-a-box/variables.env b/infrastructure/cdn-in-a-box/variables.env index f887c7dd80..b99cbdd872 100644 --- a/infrastructure/cdn-in-a-box/variables.env +++ b/infrastructure/cdn-in-a-box/variables.env @@ -70,6 +70,7 @@ TM_LOG_INFO=stdout TM_LOG_DEBUG=stdout TO_ADMIN_PASSWORD=twelve12 TO_ADMIN_USER=admin +TO_ADMIN_FULL_NAME=James Cole # Set TM_DEBUG_ENABLE to true`to debug Traffic Monitor with Delve TM_DEBUG_ENABLE=false # Set TO_DEBUG_ENABLE to true`to debug Traffic Ops with Delve