Commit Graph

10 Commits

Author SHA1 Message Date
brian m. carlson
9e006ac4e2
Rename default branch in tests to "main"
Currently, our default branch in tests is "master".  This is the Git
default, but the Git default will likely change in the future, so it
makes sense to update our testsuite to be explicit about the branch
name.  We'll ensure this continues by building against older versions of
Git as well as newer versions.

We use "main" for the new branch name, since that's the proposed value
upstream.

This commit was made entirely by automated means using the following
command:

  git grep -l master t | xargs sed -i -e 's/master/main/g'
2020-07-08 15:38:17 +00:00
brian m. carlson
65e8a8b8cb
t: fix flaky tests in CI
When we download objects, it's possible that one or more messages may
not be printed because the transfer meter is paused.  This is not
normally a problem for production use, since we'll print a later update
out, but in our tests, we check for specific success messages, which
leads to flaky tests when those exact messages happen to be skipped.
Since our CI hosts are very fast and good at triggering race conditions,
we see this frequently there.

Instead of checking for these exact messages, let's instead check that
the objects we want to have downloaded have in fact been downloaded and
that git lfs fsck passes, which are more reliable indicators of a
successful download.  In many cases, we're already doing one or more of
these, so we already have confidence that everything's working
correctly.
2019-10-30 20:21:12 +00:00
Rafal Kupka
bcb9eb3b07 Add comment about "rm $CREDSDIR/localhost"
The `t-credentials.sh` requires no credentials for localhost
2019-09-29 09:14:05 +01:00
Rafal Kupka
a07cd388a2 It'a subshell - no need to save GITSERVER 2019-09-29 09:01:08 +01:00
Rafal Kupka
bb87944770 Add http.cookieFile test
The script has to overwrite GITSERVER because golang http library refuses to
accept cookies for 127.0.0.1.
2019-09-28 19:02:20 +01:00
brian m. carlson
706becaf20
lfsapi: add support for encrypted client TLS private keys
When using client certificates for TLS, it's possible to specify a
private key file with an encrypted private key.  Previously, we silently
returned a nil Certificate object in this case which promptly resulted
in a panic in crypto/tls when attempting to push.

Instead, let's detect that the key is encrypted and prompt for a
passphrase.  Git usually handles this with a prompt from OpenSSL, which
we aren't using, although it can be configured to use the credential
helper as well.

Since there isn't a portable way to turn off the echo in order to prompt
for a passphrase, even among Unix systems, let's use the credential
helper route for this purpose by prompting for credentials using a cert:
URL for the file holding the private key; this is the type of URL that
Git uses with the credential helper for this purpose.

In order to make things as intuitive as possible, tell the credential
code to always include the path for cert: URLs (so we don't just prompt
for "cert:///") and provide the user's current username in the username
field so they don't get a useless username prompt.  Provide as much
helpful trace output as possible for debugging; note that credential
filling success and failure already have trace logging enabled
elsewhere.

Note that we create our own credential helper for the client object to
avoid having to pass it into the HTTP client context from the LFS API
context; this should be fine, since we're going to prompt and use this
value only within this context and for this purpose.

Finally, since we're in a context where we can't really return an error
up the chain, if for whatever reason an error occurs, ensure that we
don't pass nil to crypto/tls and instead skip passing a certificate
altogether.  This will at least make the failure case obvious later on
and provide a better user experience than a panic.
2018-09-24 15:09:22 +00:00
brian m. carlson
4500e2008b
t: ensure client cert integration test runs completely
The shell function that performed the clone for the client certificate
test contained several branches, each of which ended with an exit.  This
caused the test to always exit early (and in the normal case,
successfully) without running the rest of the test.

Change this function to use "return" instead of "exit" so that the test
runs to completion, and fix the single failing assertion.  Ignore this
test on Travis CI, just like we do for the other SSL test, for exactly
the same reason.

Note that this appears to be the only test helper that has this problem:
the other uses of "exit" in the test helpers are all either to skip
tests or to exit unsuccessfully, the latter of which is equivalent to
returning unsuccessfully under set -e (which we use).
2018-09-24 15:09:20 +00:00
brian m. carlson
b2ddccd90d t: avoid using shell variables in printf's first argument
The printf(1) command, like it's C cousin, takes a format string as its
first argument.  If a shell variable is passed as the first argument, it
will be interpreted as a format string; this can lead to surprising
behavior and can cause the test suite to fail if we accidentally insert
a format string character into the variable.

Modify all the places in the individual tests that we use a plain quoted
variable as the format string by running the following Ruby one-liner:

  ruby -i -pe '$_.gsub!(/printf "\$/, %q(printf "%s" "$))' t/t-*.sh

Avoid modifying the test helpers, as there are places (such as calc_oid)
where we want to pass text containing escapes (such as "\n") and have
those be properly interpreted by printf(1).
2018-09-10 14:57:10 +00:00
Taylor Blau
de9152049c t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
Taylor Blau
219b7e0a3d t: prefix all existing tests with t- 2018-07-09 16:24:25 -05:00