Commit Graph

50 Commits

Author SHA1 Message Date
Mateusz Kwapich
6688b1c845 hooks: add HG_NODE_LAST to txnclose and changegroup hook environments
Sometimes a txnclose or changegroup hook wants to iterate through all
the changesets in transaction: in that situation usually the revset
`$HG_NODE:` is used to select the revisions. Unfortunately this revset
sometimes may contain too many changesets because we don't have the
write lock while the hook runs newer changes may be added to
repository in the meantime.

That's why there is a need for extra variable carrying the information about
the last change in the transaction.
2016-01-05 17:37:59 -08:00
Matt Mackall
36e5db11e5 tests: simplify printenv calls
Make printenv executable so that we don't need python, TESTDIR, or
quoting.
2015-06-08 15:10:15 -05:00
Matt Mackall
3ad28905f6 tests: drop explicit $TESTDIR from executables
$TESTDIR is added to the path, so this is superfluous. Also,
inconsistent use of quotes means we might have broken on tests with
paths containing spaces.
2015-06-08 14:44:30 -05:00
Yuya Nishihara
4f362c44b2 test-https: kill only hgweb daemon to restart for client-auth test
This avoids a test failure on Mac OS X. Because tinyproxy.py isn't detached
from the shell, it may complain that a child process is terminated by a signal.
2015-06-05 07:49:06 +09:00
Yuya Nishihara
1bf0df3c69 ssl: prompt passphrase of client key file via ui.getpass() (issue4648)
This is necessary to communicate with third-party tools through command-server
channel. This requires SSLContext backported to Python 2.7.9+.

It doesn't look nice to pass ui by sslkwargs, but I think it is the only way
to do without touching various client codes including httpclient (aka http2).
ui is mandatory if certfile is specified, so it has no default value.

BTW, test-check-commit-hg.t complains that ssl_wrap_socket() has foo_bar
naming. Should I bulk-replace it to sslwrapsocket() ?
2015-05-07 17:15:24 +09:00
Yuya Nishihara
b87e06a760 test-https: test basic functions of client certificate authentication
Because hgweb doesn't support client certificates, I just patched it to
require client certificates that are signed and verified by the server
certificate. This won't be ideal for production servers, but should be okay
for the test.

The encrypted key file will be used by future patches. I couldn't figure out
a way to redirect a password prompt provided by OpenSSL, so it isn't tested
for now.
2015-05-07 17:38:22 +09:00
Pierre-Yves David
502fe91f02 transaction: introduce a transaction ID, to be available to all hooks
The transaction ID is built from the object ID and creation time stamp to make
sure it is unique.
2015-04-15 11:11:54 -04:00
Yuya Nishihara
29fb442439 ssl: set explicit symbol "!" to web.cacerts to disable SSL verification (BC)
The next patch will enable verification by using the system's CA store if
possible, which means we would have to distinguish None (=use default) from
'' (=--insecure). This smells bug-prone and provides no way to override
web.cacerts to forcibly use the system's store by --config argument.

This patch changes the meaning of web.cacerts as follows:

  value   behavior
  ------- ---------------------------------------
  None/'' use default
  '!'     never use CA certs (set by --insecure)
  <path>  verify by the specified CA certificates

Values other than <path> are for internal use and therefore undocumented.
2015-03-04 23:27:04 +09:00
Yuya Nishihara
6b95472c9c test-https: enable dummycert test only if Apple python is used (issue4500)
The dummycert trick works only if Python is linked to Apple's patched OpenSSL.
2015-03-04 22:41:48 +09:00
Thomas Arendsen Hein
498dfaa7d6 pull: print "pulling from foo" before accessing the other repo
1. This is consistent with pushing.
2. This allows to see the URL of the other repo in case accessing the repo
   fails, e.g. wrong ssh path or issues with the https certificate, without
   using --debug or showconfig paths.

Additionally add test for this in the context of ssh with a wrong path.
2015-02-24 10:55:24 +01:00
Augie Fackler
7d0ebc57bd test-https: glob error messages more so we pass on Python 2.7.9
Python 2.7.9 cleans up how it stringifies SSL errors, so we have to look only
for the important bit (certificate verify failed) rather than looking for
specific ssl module goop (which is now unstable).
2015-01-13 15:15:37 -05:00
Mads Kiilerich
489de2727b ssl: only use the dummy cert hack if using an Apple Python (issue4410)
The hack for using certificate store in addition to the provided CAs resides in
Apple's OpenSSL. Apple's own Pythons will use it, but other custom built
Pythons might use a custom built OpenSSL without that hack and will fail when
exposed to the dummy cacert introduced in ee8b7fe5e119.

There do not seem to be a simple way to check from Python if we are using a
patched OpenSSL or if it is an Apple OpenSSL.

Instead, check if the Python executable resides in /usr/bin/python* or in
/System/Library/Frameworks/Python.framework/ and assume that all Pythons found
there will be native Pythons using the patched OpenSSL.

Custom built Pythons will not get the benefit of using the CAs from the
certificate store.
2014-10-17 18:56:12 +02:00
Mike Hommey
14669879bf changegroup: use a copy of hookargs when invoking the changegroup hook
addchangegroup creates a runhook function that is used to invoke the
changegroup and incoming hooks, but at the time the function is called,
the contents of hookargs associated with the transaction may have been
modified externally. For instance, bundle2 code affects it with
obsolescence markers and bookmarks info.

It also creates problems when a single transaction is used with multiple
changegroups added (as per an upcoming change), whereby the contents
of hookargs are that of after adding a latter changegroup when invoking
the hook for the first changegroup.
2014-10-16 15:54:53 +09:00
Pierre-Yves David
578b6cd317 phases: inform transaction-related hooks that a phase was moved
We do not have enough information to provide finer data, but this is still
useful information.
2014-10-12 08:03:20 -07:00
Mads Kiilerich
69f5c2ecc6 ssl: on OS X, use a dummy cert to trick Python/OpenSSL to use system CA certs
This will give PKI-secure behaviour out of the box, without any configuration.

Setting web.cacerts to any value or empty will disable this trick.

This dummy cert trick only works on OS X 10.6+, but 10.5 had Python 2.5 which
didn't have certificate validation at all.
2014-09-26 02:19:48 +02:00
Matt Mackall
11be5cc27c tests: replace exit 80 with #require 2014-08-06 11:43:59 -05:00
Simon Heimberg
9897a9583e tests: remove glob from output lines containing no glob character 2013-02-13 22:05:30 +01:00
Augie Fackler
35b5aef714 test-https.t: stop using kill cat $pidfile 2013-02-09 05:26:16 -06:00
Mads Kiilerich
3cb021c3b0 serve: use chunked encoding in hgweb responses
'hg serve' used to close connections when sending a response with unknown
length ... such as a bundle or archive.

Now chunked encoding will be used for responses with unknown length, and the
connection do thus not have to be closed to indicate the end of the response.

Chunked encoding is only used if the length is unknown, if the connection
wouldn't be closed for other reasons, AND if it is a HTTP 1.1 request.

This will not benefit other users of hgweb ... but it can serve as an example
that it can be done.
2013-01-15 01:10:08 +01:00
Pierre-Yves David
fd393b84f3 pushkey: do not exchange obsole markers if feature is disabled
This apply to both push and pull both when client or server.
2012-07-28 13:33:06 +02:00
Pierre-Yves.David@ens-lyon.org
d60eedc2d6 obsolete: exchange obsolete marker over pushkey
For a version of the exchange, all markers are exchange. This won't
scale and we will need a better protocol later.
2012-06-07 19:21:59 +02:00
Adrian Buehlmann
41fcaa827d test-http and test-https: partially adapt for Windows 2012-06-19 19:45:00 +02:00
Mads Kiilerich
a8107f523f tests: consistently use printenv.py the same MSYS/Windows-compatible way
This will remove some reasons some tests are disabled on Windows.
2012-06-21 03:05:02 +02:00
Adrian Buehlmann
b761076e81 tests/printenv.py: eliminate trailing spaces on output 2012-06-17 00:27:31 +02:00
Mads Kiilerich
f64bae7ea3 tests: use 'do sleep 0' instead of 'do true', also on first line of command
2cd44a791e66 established that '... do true ...' shouldn't be used, but that was
only enforced on continued lines.
2012-04-23 01:56:48 +02:00
Matt Mackall
18bf05f2aa tests: fix startup/shutdown races in test-https
tinyproxy now writes its own pid when it's ready to accept connections
2012-03-28 19:23:25 -05:00
Matt Mackall
31ad230c52 pull: backout change to return code
This bit a number of people.
2012-02-10 16:09:30 -06:00
Matt Mackall
902bee47a8 pull: return 1 when no changes found (BC)
Currently we have the following return codes if nothing is found:

                commit   incoming    outgoing      pull     push
intended           1        1           1            1       1
documented         1        1           1            0       1
actual             1        1           1            0       1

This makes pull agree with the rest of the table and makes it easy to
detect "nothing was pulled" in scripts.
2012-01-30 16:01:54 -06:00
Matt Mackall
5a379a202e sslutil: more helpful fingerprint mismatch message
This will aid debugging for users of sites that renew certs.
2012-01-26 11:23:15 -06:00
Mads Kiilerich
142d372dec sslutil: show fingerprint when cacerts validation fails 2012-01-09 14:43:24 +01:00
Pierre-Yves David
c8f1983f55 phases: exchange phase boundaries on pull
Add an extra argument to addchangegroup to all phase code to execute before the
lock is released.
2011-12-15 11:28:42 +01:00
Arne Babenhauserheide
eaac554b05 clone: get all bookmarks before updating 2011-11-04 10:18:40 +01:00
Mads Kiilerich
8415df7277 tests: use 'hghave serve' to guard tests that requires serve daemon management 2011-11-07 03:24:53 +01:00
Augie Fackler
e362108b3a test-https.t: clean up superfluous trailing whitespace 2011-05-04 10:32:08 -05:00
David Soria Parra
2def9dba3a test-https: match output from b396ee1c907c 2011-03-16 09:05:59 +01:00
Martin Geisler
be8aa69be9 test-https: update to match output from 6eebab86aebc 2011-03-14 09:20:05 +01:00
timeless
49d2d3233b cacert: improve error report when web.cacert file does not exist 2011-03-06 10:27:07 -06:00
Mads Kiilerich
e4660104cf util: flush stdout before calling external processes
stdout could have content in its buffer while a subprocess ran and emitted
output.

Flushing stdout ensures that output now comes in the right order.
2011-02-18 03:35:01 +01:00
Mads Kiilerich
733fae3e0f tests: update test-https.t output
I must have lost the insecure cert warning in a last minute patch series
cleanup of 117f170f7437.
2011-02-18 03:34:47 +01:00
Mads Kiilerich
1edc9de542 url: merge BetterHTTPS with httpsconnection to get some proxy https validation 2011-02-16 04:36:36 +01:00
Mads Kiilerich
88522bde9b tests: test https through http proxy
These tests fails for me with Python 2.6(.nothing)
2011-02-16 04:28:11 +01:00
Matt Mackall
792783a5de bookmarks: fix up test-https 2011-02-14 18:04:20 -06:00
Yuya Nishihara
da93c3bd0b url: add --insecure option to bypass verification of ssl certificates
If --insecure specified, it behaves in the same way as no web.cacerts
configured.

Also shows hint for --insecure option when _verifycert() failed. But currently
the hint isn't displayed on SSLError, because it needs a certain level of
changes.
2011-01-29 23:23:24 +09:00
Mads Kiilerich
e10e504454 url: 'ssh known host'-like checking of fingerprints of HTTPS certificates
Known fingerprints of HTTPS servers can now be configured in the
hostfingerprints section. That makes it possible to verify the identify of web
servers without configuring and trusting the CA chain.

Limitations:
* Portnumbers are ignored, just like with ordinary certificates.
* Host name matching is case sensitive.
2011-01-28 02:57:59 +01:00
Eduard-Cristian Stefan
c66ec9cf09 url: expand path for web.cacerts 2011-01-02 15:30:12 +02:00
Mads Kiilerich
d9f11887ef https: use web.cacerts configuration from local repo to validate remote repo 2010-12-27 17:49:58 +01:00
Mads Kiilerich
97213d6b00 https: warn when server certificate isn't verified
Mercurial will verify HTTPS server certificates if web.cacerts is configured,
but it will by default silently not verify any certificates.

We now warn the user that when the certificate isn't verified she won't get the
security she might expect from https:
  warning: localhost certificate not verified (check web.cacerts config setting)

Self-signed certificates can be accepted silently by configuring web.cacerts to
point to a suitable certificate file.
2010-12-18 21:58:52 +01:00
Mads Kiilerich
affe4fdcad hgweb: use Pythons ssl module for HTTPS serve when using Python 2.6 or later
pyOpenSSL apparently doesn't work for Python 2.7 and isn't very actively
maintained.

The built-in ssl module seems like a long-term winner, so we now use that with
Python 2.6 and higher.
2010-10-20 20:19:34 +02:00
Mads Kiilerich
26f5319c13 test-https: test web.cacerts functionality 2010-10-17 04:13:50 +02:00
Mads Kiilerich
c627f511ce serve: fix https mode and add test
The https mode failed in super because BaseRequestHandler is an old-style
class.

This introduces the first test of https client/server functionality - and
"hghave ssl". The test is currently only run on Python 2.6.
2010-10-17 04:13:35 +02:00