# handle entire auth

`5fd1eea`→[main](/content/gh/entireio/git-sync/commits/main/index.html)·  Soph·3mo ago·6 files·+700 added/-7 removed

## Sessions

33dc63f83cffView transcript

## Changes

6

- MREADME.md+29

- internal/syncer

- Mauth\_test.go+119

- Mentire\_local\_smoke\_test.go+40/-2

- Mintegration\_test.go+151/-2

- Msyncer.go+353/-3

- Mmise.toml+8

````
316 unmodified lines

317
318
319
320
321
322
323
324
325
326
10 unmodified lines

337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367

316 unmodified lines

- `mise run test:linux-smoke`
- `mise run test:linux-smoke:batched`
- `mise run test:entire-local-smoke`
- `mise run test:entire-local-smoke:linux`
- `mise run test:entire-local-smoke:linux:single`

`test:linux-smoke` and `test:linux-smoke:batched` use a disposable local bare Git target served through `git-http-backend`. They do not talk to a running Entire instance.

The Entire local smoke expects:

10 unmodified lines

- `GITSYNC_E2E_ENTIRE_TOKEN=...`
- `GITSYNC_E2E_ENTIRE_SKIP_TLS_VERIFY=true`

To sync the public Linux repo into a local Entire instance, use:

```bash
mise run test:entire-local-smoke:linux
```

That task sets:

- `GITSYNC_E2E_ENTIRE_SOURCE_URL=https://github.com/torvalds/linux.git`
- `GITSYNC_E2E_ENTIRE_BRANCH=master`
- `GITSYNC_E2E_ENTIRE_PROTOCOL=v2`
- `GITSYNC_E2E_ENTIRE_BATCH_MAX_PACK_BYTES=536870912`

The batched default matters for Entire targets with request body limits around `2 GiB`; a single Linux bootstrap push can exceed that. If you explicitly want the old single-pack behavior, use:

```bash
mise run test:entire-local-smoke:linux:single
```

If you use `test:entire-local-smoke` directly, the test falls back to `https://github.com/entireio/cli.git` on `main` unless you override both the source URL and branch yourself. The Entire-local smoke also accepts:

- `GITSYNC_E2E_ENTIRE_MAX_PACK_BYTES`
- `GITSYNC_E2E_ENTIRE_BATCH_MAX_PACK_BYTES`
- `GITSYNC_E2E_ENTIRE_PROTOCOL`

For local/self-signed targets, `git-sync` also supports:

- `--source-insecure-skip-tls-verify`
````

MREADME.md+29

``
1 unmodified line

2
3
4
5
6
7
8
9
10
11
12
53 unmodified lines

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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183

1 unmodified line

import (
	"context"
	"encoding/json"
	"net/http"
	"net/http/httptest"
	"os"
	"path/filepath"
	"testing"
	
	"github.com/go-git/go-git/v5/plumbing/transport"
53 unmodified lines

t.Fatalf("expected InsecureSkipVerify transport, got %#v", base.TLSClientConfig)
	}
}

func TestResolveAuthMethodUsesEntireDBStoredToken(t *testing.T) {
	configDir := t.TempDir()
	tokenStorePath := filepath.Join(t.TempDir(), "tokens.json")
	...
}

func TestResolveAuthMethodRefreshesExpiredEntireDBToken(t *testing.T) {
	...
}

func writeEntireDBHostsFile(t *testing.T, configDir, host, username string) {
	...
}
```

Minternal/syncer/auth\_test.go+119

``
7 unmodified lines

8
9
10
11
12
13
14
35 unmodified lines

50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
29 unmodified lines

97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
2 unmodified lines

115
116
117
95
96
118
119
120
121
122
123
124
125
179 unmodified lines

305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322

7 unmodified lines

"os"
	"os/exec"
	"path/filepath"
	"strconv"
	"strings"
	"testing"

35 unmodified lines

os.Getenv("GITSYNC_E2E_ENTIRE_BRANCH"),
	"main",
)
maxPackBytes, err := envInt64Default("GITSYNC_E2E_ENTIRE_MAX_PACK_BYTES", 0)
if err != nil {
	t.Fatalf("parse GITSYNC_E2E_ENTIRE_MAX_PACK_BYTES: %v", err)
}
batchMaxPackBytes, err := envInt64Default("GITSYNC_E2E_ENTIRE_BATCH_MAX_PACK_BYTES", 0)
if err != nil {
	t.Fatalf("parse GITSYNC_E2E_ENTIRE_BATCH_MAX_PACK_BYTES: %v", err)
}
protocolMode := firstNonEmpty(
	os.Getenv("GITSYNC_E2E_ENTIRE_PROTOCOL"),
	protocolModeAuto,
)
repoName := firstNonEmpty(
	os.Getenv("GITSYNC_E2E_ENTIRE_REPO"),
	"git-sync-smoke",
29 unmodified lines

...
...
}

``
...

```

func isConnectionCloseError(err error) bool {
	if err == nil {
		return false
	}
	msg := strings.ToLower(err.Error())
	return strings.Contains(msg, "broken pipe") ||
		strings.Contains(msg, "connection reset by peer")
}

func (s *smartHTTPRepoServer) refsMatchingPrefixes(prefixes []string) ([]*plumbing.Reference, error) {
	iter, err := s.repo.Storer.IterReferences()
	if err != nil {
...

Minternal/syncer/integration\_test.go+151/-2

``
8 unmodified lines

9
10
11
12
13
14
15
16
17
18
19
20
21
22
10 unmodified lines

33
34
35
36
37
38
39
1 unmodified line

41
42
43
44
45
46
47
48
49
50
51
52
53
101 unmodified lines

155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
726 unmodified lines

898
899
900
880
901
902
903
884
885
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
1526 unmodified lines

2509
2510
2511
2512
2513
2514
2515
2516
2517
1 unmodified line

2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584

8 unmodified lines

"fmt"
	"io"
	"net/http"
	"net/url"
	"os"
	"os/exec"
	"path/filepath"
	"regexp"
	"runtime"
	"sort"
	"strconv"
	"strings"
	"sync"
	"time"
10 unmodified lines

transporthttp "github.com/go-git/go-git/v5/plumbing/transport/http"
	"github.com/go-git/go-git/v5/storage/memory"
	"github.com/go-git/go-git/v5/utils/ioutil"
	"github.com/zalando/go-keyring"

const (
1 unmodified line

protocolModeAuto = "auto"
	protocolModeV1   = "v1"
	protocolModeV2   = "v2"

defaultAutoBatchMaxPackBytes = 512 * 1024 * 1024
	entireCLIClientID            = "entire-cli"
)

var bodyLimitPattern = regexp.MustCompile(`body exceeded size limit ([0-9]+)`)

...

func TestRun_IntegrationInitialSyncAutoFallsBackToBatchedBootstrapOnTargetBodyLimit(t *testing.T) {
...

}

...
