github.com/git-lfs/git-lfs@v2.5.2+incompatible/t/t-askpass.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  . "$(dirname "$0")/testlib.sh"
     4  
     5  begin_test "askpass: push with GIT_ASKPASS"
     6  (
     7    set -e
     8  
     9    reponame="askpass-with-git-environ"
    10    setup_remote_repo "$reponame"
    11    clone_repo "$reponame" "$reponame"
    12  
    13    git lfs track "*.dat"
    14    echo "hello" > a.dat
    15  
    16    git add .gitattributes a.dat
    17    git commit -m "initial commit"
    18  
    19    # $password is defined from test/cmd/lfstest-gitserver.go (see: skipIfBadAuth)
    20    export LFS_ASKPASS_USERNAME="user"
    21    export LFS_ASKPASS_PASSWORD="pass"
    22    git config "credential.helper" ""
    23    GIT_ASKPASS="lfs-askpass" SSH_ASKPASS="dont-call-me" GIT_TRACE=1 GIT_CURL_VERBOSE=1 git push origin master 2>&1 | tee push.log
    24  
    25    GITSERVER_USER="$(printf $GITSERVER | sed -e 's/http:\/\//http:\/\/user@/')"
    26  
    27    grep "filling with GIT_ASKPASS: lfs-askpass Username for \"$GITSERVER/$reponame\"" push.log
    28    grep "filling with GIT_ASKPASS: lfs-askpass Password for \"$GITSERVER_USER/$reponame\"" push.log
    29    grep "master -> master" push.log
    30  )
    31  end_test
    32  
    33  begin_test "askpass: push with core.askPass"
    34  (
    35    set -e
    36  
    37    if [ ! -z "$TRAVIS" ] ; then
    38      # This test is known to be broken on Travis, so we skip it if the $TRAVIS
    39      # environment variable is set.
    40      #
    41      # See: https://github.com/git-lfs/git-lfs/pull/2500 for more.
    42      exit 0
    43    fi
    44  
    45    reponame="askpass-with-config"
    46    setup_remote_repo "$reponame"
    47    clone_repo "$reponame" "$reponame"
    48  
    49    git lfs track "*.dat"
    50    echo "hello" > a.dat
    51  
    52    git add .gitattributes a.dat
    53    git commit -m "initial commit"
    54  
    55    # $password is defined from test/cmd/lfstest-gitserver.go (see: skipIfBadAuth)
    56    export LFS_ASKPASS_PASSWORD="pass"
    57    git config "credential.helper" ""
    58    git config "core.askPass" "lfs-askpass"
    59    cat .git/config
    60    SSH_ASKPASS="dont-call-me" GIT_TRACE=1 GIT_CURL_VERBOSE=1 git push origin master 2>&1 | tee push.log
    61  
    62    GITSERVER_USER="$(printf $GITSERVER | sed -e 's/http:\/\//http:\/\/user@/')"
    63  
    64    grep "filling with GIT_ASKPASS: lfs-askpass Username for \"$GITSERVER/$reponame\"" push.log
    65    grep "filling with GIT_ASKPASS: lfs-askpass Password for \"$GITSERVER_USER/$reponame\"" push.log
    66    grep "master -> master" push.log
    67  )
    68  end_test
    69  
    70  begin_test "askpass: push with SSH_ASKPASS"
    71  (
    72    set -e
    73  
    74    if [ ! -z "$TRAVIS" ] ; then
    75      # This test is known to be broken on Travis, so we skip it if the $TRAVIS
    76      # environment variable is set.
    77      #
    78      # See: https://github.com/git-lfs/git-lfs/pull/2500 for more.
    79      exit 0
    80    fi
    81  
    82    reponame="askpass-with-ssh-environ"
    83    setup_remote_repo "$reponame"
    84    clone_repo "$reponame" "$reponame"
    85  
    86    git lfs track "*.dat"
    87    echo "hello" > a.dat
    88  
    89    git add .gitattributes a.dat
    90    git commit -m "initial commit"
    91  
    92    # $password is defined from test/cmd/lfstest-gitserver.go (see: skipIfBadAuth)
    93    export LFS_ASKPASS_USERNAME="user"
    94    export LFS_ASKPASS_PASSWORD="pass"
    95    git config "credential.helper" ""
    96    SSH_ASKPASS="lfs-askpass" GIT_TRACE=1 GIT_CURL_VERBOSE=1 git push origin master 2>&1 | tee push.log
    97  
    98    GITSERVER_USER="$(printf $GITSERVER | sed -e 's/http:\/\//http:\/\/user@/')"
    99  
   100    grep "filling with GIT_ASKPASS: lfs-askpass Username for \"$GITSERVER/$reponame\"" push.log
   101    grep "filling with GIT_ASKPASS: lfs-askpass Password for \"$GITSERVER_USER/$reponame\"" push.log
   102    grep "master -> master" push.log
   103  )
   104  end_test
   105  
   106  begin_test "askpass: defaults to provided credentials"
   107  (
   108    set -e
   109  
   110    reponame="askpass-provided-creds"
   111    setup_remote_repo "$reponame"
   112    clone_repo "$reponame" "$reponame"
   113  
   114    git lfs track "*.dat"
   115    echo "hello" > a.dat
   116  
   117    git add .gitattributes a.dat
   118    git commit -m "initial commit"
   119  
   120    # $password is defined from test/cmd/lfstest-gitserver.go (see: skipIfBadAuth)
   121    export LFS_ASKPASS_USERNAME="fakeuser"
   122    export LFS_ASKPASS_PASSWORD="fakepass"
   123    git config --local "credential.helper" ""
   124  
   125    url=$(git config --get remote.origin.url)
   126    newurl=${url/http:\/\//http:\/\/user\:pass@}
   127    git remote set-url origin "$newurl"
   128  
   129    GIT_ASKPASS="lfs-askpass" GIT_TRACE=1 GIT_CURL_VERBOSE=1 git push origin master 2>&1 | tee push.log
   130  
   131    [ ! $(grep "filling with GIT_ASKPASS" push.log) ]
   132    grep "master -> master" push.log
   133  )
   134  end_test