github.com/grailbio/base@v0.0.11/cmd/grail-access/manual_google_test.bash (about)

     1  #!/bin/bash
     2  
     3  # The grail-access Google authentication flow is difficult to exercise in a unit test because the
     4  # outh2 server isn't trivial to fake (at least not for josh@).
     5  
     6  # Instead, we provide a manual test script. Please run this yourself.
     7  
     8  set -euo pipefail
     9  
    10  echo "Instructions:"
    11  echo
    12  echo "Running manual tests. If the script exits with a non-zero error code, the tests failed."
    13  echo "You'll also be prompted to review output manually. If it doesn't look right, the tests failed."
    14  echo
    15  dir="$(mktemp -d)"
    16  echo "Using temporary directory for test: $dir"
    17  echo "Building grail-access for the test..."
    18  cd "$( dirname "${BASH_SOURCE[0]}" )"
    19  go build -o "$dir/grail-access" github.com/grailbio/base/cmd/grail-access
    20  cd "$dir"
    21  echo
    22  echo "Step 1/3: Starting grail-access Google authentication flow. Please complete it."
    23  echo
    24  echo "************************************************************************"
    25  ./grail-access -dir ./v23
    26  echo "************************************************************************"
    27  echo
    28  echo "Done with authentication flow."
    29  echo "If it succeeded, you should lines like these above:"
    30  echo "    Default Blessings      v23.grail.com:google:YOUR_USERNAME@grailbio.com"
    31  echo "and"
    32  echo "    ...                    v23.grail.com:google:YOUR_USERNAME@grailbio.com"
    33  echo "and an expiration date in the future."
    34  echo
    35  read -p "Continue with next test? [Y] "
    36  echo
    37  echo "Step 2/3: Next, running the same flow, but automatically canceling."
    38  echo
    39  echo "************************************************************************"
    40  set +e
    41  cat /dev/null | ./grail-access -dir ./v23 -browser=false
    42  set -e
    43  echo "************************************************************************"
    44  echo
    45  echo "Step 3/3: Finally, make sure our Step 1 credentials survived. "
    46  echo
    47  echo "************************************************************************"
    48  ./grail-access -dir ./v23 -dump
    49  echo "************************************************************************"
    50  echo
    51  echo "You should see the same blessing lines as in Step 1, and a consistent expiry time."
    52  echo "If not, the tests failed."
    53  echo
    54  echo "Cleaning up test directory: $dir"
    55  rm -rf "$dir"