1 Ensure we have our mocked out ENV_AUTHORIZATION_FILE
3 $ [[ $ENV_AUTHORIZATION_FILE[0,4] == '/tmp' ]] || return 1
5 Lets set a simple .env action
7 $ echo 'echo ENTERED' >> .env
9 Manually create auth file
11 $ echo "$PWD/.env:$(echo echo ENTERED | shasum)" > $ENV_AUTHORIZATION_FILE
15 Now try to make it accept it
17 $ unset _dotenv_stack_entered
18 $ rm $ENV_AUTHORIZATION_FILE
19 $ _dotenv_read_answer() { echo 'y' }
21 Attempting to load unauthorized env file: /tmp/cramtests-??????/autoenv.t/.env (glob)
23 **********************************************
27 **********************************************
29 Would you like to authorize it? [y/N]
36 The last "ENTERED" is because it executed the command
38 Now lets see that it actually checks the shasum value
40 $ unset _dotenv_stack_entered
44 $ unset _dotenv_stack_entered
45 $ rm $ENV_AUTHORIZATION_FILE
46 $ echo "$PWD/.env:$(echo mischief | shasum)" > $ENV_AUTHORIZATION_FILE
48 Attempting to load unauthorized env file: /tmp/cramtests-??????/autoenv.t/.env (glob)
50 **********************************************
54 **********************************************
56 Would you like to authorize it? [y/N]
63 Now, will it take no for an answer?
65 $ unset _dotenv_stack_entered
66 $ rm $ENV_AUTHORIZATION_FILE
67 $ _dotenv_read_answer() { echo 'n' }
69 Attempting to load unauthorized env file: /tmp/cramtests-??????/autoenv.t/.env (glob)
71 **********************************************
75 **********************************************
77 Would you like to authorize it? [y/N]
83 Lets also try one more time to ensure it didnt add it
86 Attempting to load unauthorized env file: /tmp/cramtests-??????/autoenv.t/.env (glob)
88 **********************************************
92 **********************************************
94 Would you like to authorize it? [y/N]