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 blah' >> .env
9 Manually create auth file
11 $ echo "$PWD/.env:$(echo echo blah | shasum)" > $ENV_AUTHORIZATION_FILE
15 Now try to make it accept it
17 $ rm $ENV_AUTHORIZATION_FILE
18 $ _dotenv_read_answer() { answer='y' }
20 Attempting to load unauthorized env: /tmp/cramtests-??????/autoenv.t/.env (glob)
22 **********************************************
26 **********************************************
28 Would you like to authorize it? (y/n)
35 The last "blah" is because it executed the command
37 Now lets see that it actually checks the shasum value
41 $ rm $ENV_AUTHORIZATION_FILE
42 $ echo "$PWD/.env:$(echo mischief | shasum)" > $ENV_AUTHORIZATION_FILE
44 Attempting to load unauthorized env: /tmp/cramtests-??????/autoenv.t/.env (glob)
46 **********************************************
50 **********************************************
52 Would you like to authorize it? (y/n)
59 Now, will it take no for an answer?
61 $ rm $ENV_AUTHORIZATION_FILE
62 $ _dotenv_read_answer() { answer='n' }
64 Attempting to load unauthorized env: /tmp/cramtests-??????/autoenv.t/.env (glob)
66 **********************************************
70 **********************************************
72 Would you like to authorize it? (y/n)
78 Lets also try one more time to ensure it didnt add it
81 Attempting to load unauthorized env: /tmp/cramtests-??????/autoenv.t/.env (glob)
83 **********************************************
87 **********************************************
89 Would you like to authorize it? (y/n)