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)
31 The last "blah" is because it executed the command
33 Now lets see that it actually checks the shasum value
37 $ rm $ENV_AUTHORIZATION_FILE
38 $ echo "$PWD/.env:$(echo mischief | shasum)" > $ENV_AUTHORIZATION_FILE
40 Attempting to load unauthorized env: /tmp/cramtests-??????/autoenv.t/.env (glob)
42 **********************************************
46 **********************************************
48 Would you like to authorize it? (y/n)
51 Now, will it take no for an answer?
53 $ rm $ENV_AUTHORIZATION_FILE
54 $ _dotenv_read_answer() { answer='n' }
56 Attempting to load unauthorized env: /tmp/cramtests-??????/autoenv.t/.env (glob)
58 **********************************************
62 **********************************************
64 Would you like to authorize it? (y/n)
66 Lets also try one more time to ensure it didnt add it
69 Attempting to load unauthorized env: /tmp/cramtests-??????/autoenv.t/.env (glob)
71 **********************************************
75 **********************************************
77 Would you like to authorize it? (y/n)