File: test-serve-ci.t

package info (click to toggle)
hg-git 1.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 1,244 kB
  • sloc: python: 8,702; sh: 185; makefile: 23
file content (134 lines) | stat: -rw-r--r-- 3,952 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
Load commonly used test logic
  $ . "$TESTDIR/testutil"

We assume the git server is unavailable elsewhere.

  $ if test -z "$CI_TEST_GIT_NETWORKING"
  > then
  >   echo 'requires CI networking'
  >   exit 80
  > fi

Allow password prompts without a TTY:

  $ cat >> $HGRCPATH << EOF
  > [extensions]
  > getpass = $TESTDIR/testlib/ext-get-password-from-env.py
  > EOF

Create a silly SSH configuration:

  $ cat >> $HGRCPATH << EOF
  > [ui]
  > ssh = ssh -o UserKnownHostsFile=$TESTDIR/known_hosts -o StrictHostKeyChecking=no -i $TESTTMP/id_ed25519
  > EOF
  $ cp $RUNTESTDIR/../contrib/docker/git-server/ssh/id_ed25519 $TESTTMP
  $ chmod 0600 $TESTTMP/id_ed25519

Clone using the git protocol:

  $ hg clone git://git-server/repo.git repo-git
  updating to branch default
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved

..and HTTP:

  $ hg clone http://git-server/repo.git repo-http
  abort: http authorization required for http://git-server/repo.git
  [255]
  $ hg clone --config ui.interactive=yes \
  >    --config ui.interactive=yes \
  >    --config auth.git.prefix=http://git-server \
  >    --config auth.git.username=git \
  >    http://git-server/repo.git repo-http
  http authorization required for http://git-server/repo.git
  realm: Git Access
  user: git
  password: nope
  abort: authorization failed
  [255]
  $ PASSWD=git hg clone --config ui.interactive=yes \
  >          http://git-server/repo.git repo-http <<EOF
  > git
  > EOF
  http authorization required for http://git-server/repo.git
  realm: Git Access
  user: git
  password: git
  updating to branch default
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved

..and finally SSH:

  $ hg clone git@git-server:/srv/repo.git repo-ssh
  Warning: Permanently added * (glob)
  updating to branch default
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved

..but also try SSH with GIT_SSH_COMMAND, which we just ignore:

  $ GIT_SSH_COMMAND="ignored" \
  > hg clone git@git-server:/srv/repo.git repo-ssh-2
  updating to branch default
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ rm -rf repo-ssh-2

So, that went well; now push...

  $ cd repo-ssh
  $ echo thefile > thefile
  $ hg add thefile
  $ fn_hg_commit -m 'add the file'
  $ hg book -r tip master
  $ hg path default
  git@git-server:/srv/repo.git
  $ hg push
  pushing to git@git-server:/srv/repo.git
  searching for changes
  adding objects
  remote: found 0 deltas to reuse
  added 1 commits with 1 trees and 1 blobs
  adding reference refs/heads/master
  $ cd ..

And finally, pull the new commit:

  $ hg -R repo-git pull -u
  pulling from git://git-server/repo.git
  remote: warning: unable to access '/root/.config/git/attributes': Permission denied
  importing 1 git commits
  adding bookmark master
  new changesets fa22339f4ab8
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved

Straight HTTP doesn't work:

  $ hg -R repo-http pull -u
  pulling from http://git-server/repo.git
  abort: http authorization required for http://git-server/repo.git
  [255]

But we can specify authentication in the configuration:

  $ hg -R repo-http \
  >    --config auth.git.prefix=http://git-server \
  >    --config auth.git.username=git \
  >    --config auth.git.password=git \
  >    pull -u
  pulling from http://git-server/repo.git
  remote: warning: unable to access '/root/.config/git/attributes': Permission denied
  importing 1 git commits
  adding bookmark master
  new changesets fa22339f4ab8
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved

Try using git credentials:

NB: the use of printf is deliberate; otherwise the test fails due to
dulwich considering the newline part of the url

  $ printf http://git:git@git-server > $TESTTMP/.git-credentials
  $ hg -R repo-http pull
  pulling from http://git-server/repo.git
  no changes found
  $ rm -f $TESTTMP/.git-credentials