infracloudio / ifc-rw-codecollection

test codebundle for runwhen
Apache License 2.0
0 stars 0 forks source link

RW.Core.Import Secret MYSQL_PASSWORD not decoded when passed to bash file #9

Closed saurabh3460 closed 5 months ago

saurabh3460 commented 5 months ago

We are running runbook.robot which runs kill-mysql-sleep-processes.sh file and it need mysql password.

What we did first:

Using RW.Core.Import Secret MYSQL_PASSWORD env to pass password:

on line number 52 in runbook.robot we set the suite variable "MYSQL_PASSWORD":"${MYSQL_PASSWORD}"

    Set Suite Variable
    ...    ${env}    {"MYSQL_USER":"${MYSQL_USER}", "MYSQL_PASSWORD":"${MYSQL_PASSWORD}" ...}
Result:
[ ERROR ] Error in library 'RW.Core': Adding keyword 'add_datagrid_to_report' failed: Union cannot be empty.
[ ERROR ] Error in library 'RW.Core': Adding keyword 'add_table_to_report' failed: Union cannot be empty.
[ ERROR ] Error in file '/app/codecollection/codebundles/rds-mysql-conn-count/runbook.robot' on line 13: Setting variable '${MYSQL_PASSWORD_ENV}' failed: Environment variable '%{MYSQL_PASSWORD_ENV}' not found. Did you mean:
    %{MYSQL_PASSWORD}
==============================================================================
Runbook :: This taskset Kills the numbers of sleep process created in MySQL
==============================================================================
Run Bash File :: Runs a bash file to kill sleep processes created ...
Command Stdout:
MYSQL_USER admin
MYSQL_PASSWORD **********
MYSQL_HOST robotshopmysql.c4eo4uy3mys1.us-west-2.rds.amazonaws.com
PROCESS_USER shipping
Error connecting to MySQL

Command Stderr:
ERROR 1045 (28000): Access denied for user 'admin'@'192.168.160.216' (using password: YES)

| PASS |
------------------------------------------------------------------------------
Runbook :: This taskset Kills the numbers of sleep process created... | PASS |
1 task, 1 passed, 0 failed
==============================================================================
Output:  /robot_logs/rds-mysql-conn-count/runbook-output.xml
Log:     /robot_logs/rds-mysql-conn-count/runbook-log.html
Report:  /robot_logs/rds-mysql-conn-count/runbook-report.html

Temporary workaround to test the runbook.robot

We used robot framework env variables to pass password to bash script, refer to this line

*** Variables ***
${MYSQL_PASSWORD_ENV}      %{MYSQL_PASSWORD_ENV}

then on line number 52 we set the suite variable "MYSQL_PASSWORD":"${MYSQL_PASSWORD_ENV}"

    Set Suite Variable
    ...    ${env}    {"MYSQL_USER":"${MYSQL_USER}", "MYSQL_PASSWORD":"${MYSQL_PASSWORD_ENV}" ...}

Result we get:


[ ERROR ] Error in library 'RW.Core': Adding keyword 'add_datagrid_to_report' failed: Union cannot be empty.
[ ERROR ] Error in library 'RW.Core': Adding keyword 'add_table_to_report' failed: Union cannot be empty.
==============================================================================
Runbook :: This taskset Kills the numbers of sleep process created in MySQL
==============================================================================
Run Bash File :: Runs a bash file to kill sleep processes created ...
Command Stdout:
MYSQL_USER admin
MYSQL_PASSWORD docdb3421z
MYSQL_HOST robotshopmysql.c5eo4uy8mys1.us-west-2.rds.amazonaws.com
PROCESS_USER shipping
Terminated connection with ID 38 for user 'shipping'
Terminated connection with ID 70 for user 'shipping'
Terminated connection with ID 83 for user 'shipping'
Terminated connection with ID 76 for user 'shipping'
Terminated connection with ID 66 for user 'shipping'
Terminated connection with ID 68 for user 'shipping'
saurabh3460 commented 5 months ago

This issue is resolved by adding secret__ prefix to the environment variable e.g secret__mysql_password. Hence closing it.