Commit 5be622fb by Carlos Martín Nieto

Test SSH in travis

Set up the ssh credentials so we are able to talk to localhost and
issue git commands. Move to use a script, as the command list is
getting somewhat long.

While here, delay installing valgrind until we need it, as it and its
dependencies are by far the largest downloads and this allows us to
start compiling (and failing) faster and we only incur this cost when
the test suite runs successfully.
parent 2af9bcb2
# Travis-CI Build for libgit2 # Travis-CI Build for libgit2
# see travis-ci.org for details # see travis-ci.org for details
# As CMake is not officially supported we use erlang VMs
language: c language: c
compiler: compiler:
...@@ -18,25 +17,17 @@ matrix: ...@@ -18,25 +17,17 @@ matrix:
- compiler: i586-mingw32msvc-gcc - compiler: i586-mingw32msvc-gcc
env: OPTIONS="-DBUILD_CLAR=OFF -DWIN32=ON -DMINGW=ON" env: OPTIONS="-DBUILD_CLAR=OFF -DWIN32=ON -DMINGW=ON"
# Make sure CMake is installed
install: install:
- sudo apt-get update >/dev/null - sudo apt-get -qq update
- sudo apt-get -q install cmake valgrind - sudo apt-get -qq install cmake libssh2-1-dev openssh-client openssh-server
# Run the Build script # Run the Build script and tests
script: script:
- mkdir _temp - script/cibuild.sh
- git init --bare _temp/test.git
- git daemon --listen=localhost --export-all --enable=receive-pack --base-path=_temp _temp 2>/dev/null &
- export GITTEST_REMOTE_URL="git://localhost/test.git"
- mkdir _build
- cd _build
- cmake .. -DCMAKE_INSTALL_PREFIX=../_install $OPTIONS
- cmake --build . --target install
- ctest -V .
# Run Tests # Run Tests
after_success: after_success:
- sudo apt-get -qq install valgrind
- valgrind --leak-check=full --show-reachable=yes --suppressions=../libgit2_clar.supp ./libgit2_clar -ionline - valgrind --leak-check=full --show-reachable=yes --suppressions=../libgit2_clar.supp ./libgit2_clar -ionline
# Only watch the development branch # Only watch the development branch
......
...@@ -148,7 +148,9 @@ ELSE() ...@@ -148,7 +148,9 @@ ELSE()
FILE(GLOB SRC_ZLIB deps/zlib/*.c deps/zlib/*.h) FILE(GLOB SRC_ZLIB deps/zlib/*.c deps/zlib/*.h)
ENDIF() ENDIF()
FIND_PACKAGE(LIBSSH2 QUIET) IF (NOT MINGW)
FIND_PACKAGE(LIBSSH2 QUIET)
ENDIF()
IF (LIBSSH2_FOUND) IF (LIBSSH2_FOUND)
ADD_DEFINITIONS(-DGIT_SSH) ADD_DEFINITIONS(-DGIT_SSH)
INCLUDE_DIRECTORIES(${LIBSSH2_INCLUDE_DIR}) INCLUDE_DIRECTORIES(${LIBSSH2_INCLUDE_DIR})
......
#!/bin/sh
# Create a test repo which we can use for the online::push tests
mkdir $HOME/_temp
git init --bare $HOME/_temp/test.git
git daemon --listen=localhost --export-all --enable=receive-pack --base-path=$HOME/_temp $HOME/_temp 2>/dev/null &
export GITTEST_REMOTE_URL="git://localhost/test.git"
mkdir _build
cd _build
cmake .. -DCMAKE_INSTALL_PREFIX=../_install $OPTIONS
cmake --build . --target install
ctest -V .
# Now that we've tested the raw git protocol, let's set up ssh to we
# can do the push tests over it
killall git-daemon
sudo start ssh
ssh-keygen -t rsa -f ~/.ssh/id_rsa -N "" -q
cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys
ssh-keyscan -t rsa localhost >>~/.ssh/known_hosts
export GITTEST_REMOTE_URL="ssh://localhost/$HOME/_temp/test.git"
export GITTEST_REMOTE_USER=$USER
export GITTEST_REMOTE_SSH_KEY="$HOME/.ssh/id_rsa"
export GITTEST_REMOTE_SSH_PUBKEY="$HOME/.ssh/id_rsa.pub"
export GITTEST_REMOTE_SSH_PASSPHRASE=""
if [ -e ./libgit2_clar ]; then
./libgit2_clar -sonline::push
fi
...@@ -9,6 +9,10 @@ ...@@ -9,6 +9,10 @@
static git_repository *_repo; static git_repository *_repo;
static char *_remote_ssh_key;
static char *_remote_ssh_pubkey;
static char *_remote_ssh_passphrase;
static char *_remote_url; static char *_remote_url;
static char *_remote_user; static char *_remote_user;
static char *_remote_pass; static char *_remote_pass;
...@@ -42,6 +46,9 @@ static int cred_acquire_cb( ...@@ -42,6 +46,9 @@ static int cred_acquire_cb(
*((bool*)payload) = true; *((bool*)payload) = true;
if (GIT_CREDTYPE_SSH_PUBLICKEY & allowed_types)
return git_cred_ssh_keyfile_passphrase_new(cred, _remote_user, _remote_ssh_pubkey, _remote_ssh_key, _remote_ssh_passphrase);
if ((GIT_CREDTYPE_USERPASS_PLAINTEXT & allowed_types) == 0 || if ((GIT_CREDTYPE_USERPASS_PLAINTEXT & allowed_types) == 0 ||
git_cred_userpass_plaintext_new(cred, _remote_user, _remote_pass) < 0) git_cred_userpass_plaintext_new(cred, _remote_user, _remote_pass) < 0)
return -1; return -1;
...@@ -277,6 +284,9 @@ void test_online_push__initialize(void) ...@@ -277,6 +284,9 @@ void test_online_push__initialize(void)
_remote_url = cl_getenv("GITTEST_REMOTE_URL"); _remote_url = cl_getenv("GITTEST_REMOTE_URL");
_remote_user = cl_getenv("GITTEST_REMOTE_USER"); _remote_user = cl_getenv("GITTEST_REMOTE_USER");
_remote_pass = cl_getenv("GITTEST_REMOTE_PASS"); _remote_pass = cl_getenv("GITTEST_REMOTE_PASS");
_remote_ssh_key = cl_getenv("GITTEST_REMOTE_SSH_KEY");
_remote_ssh_pubkey = cl_getenv("GITTEST_REMOTE_SSH_PUBKEY");
_remote_ssh_passphrase = cl_getenv("GITTEST_REMOTE_SSH_PASSPHRASE");
_remote = NULL; _remote = NULL;
if (_remote_url) { if (_remote_url) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment