@@ -14,6 +14,7 @@ import (
14
14
coreunix "github.com/ipfs/go-ipfs/core/coreunix"
15
15
namesys "github.com/ipfs/go-ipfs/namesys"
16
16
ci "github.com/ipfs/go-ipfs/p2p/crypto"
17
+ id "github.com/ipfs/go-ipfs/p2p/protocol/identify"
17
18
path "github.com/ipfs/go-ipfs/path"
18
19
repo "github.com/ipfs/go-ipfs/repo"
19
20
config "github.com/ipfs/go-ipfs/repo/config"
@@ -95,6 +96,7 @@ func newTestServerAndNode(t *testing.T, ns mockNamesys) (*httptest.Server, *core
95
96
96
97
dh .Handler , err = makeHandler (n ,
97
98
ts .Listener ,
99
+ VersionOption (),
98
100
IPNSHostnameOption (),
99
101
GatewayOption (false ),
100
102
)
@@ -397,3 +399,39 @@ func TestIPNSHostnameBacklinks(t *testing.T) {
397
399
t .Fatalf ("expected file in directory listing" )
398
400
}
399
401
}
402
+
403
+ func TestVersion (t * testing.T ) {
404
+ config .CurrentCommit = "theshortcommithash"
405
+
406
+ ns := mockNamesys {}
407
+ ts , _ := newTestServerAndNode (t , ns )
408
+ t .Logf ("test server url: %s" , ts .URL )
409
+ defer ts .Close ()
410
+
411
+ req , err := http .NewRequest ("GET" , ts .URL + "/version" , nil )
412
+ if err != nil {
413
+ t .Fatal (err )
414
+ }
415
+
416
+ res , err := doWithoutRedirect (req )
417
+ if err != nil {
418
+ t .Fatal (err )
419
+ }
420
+ body , err := ioutil .ReadAll (res .Body )
421
+ if err != nil {
422
+ t .Fatalf ("error reading response: %s" , err )
423
+ }
424
+ s := string (body )
425
+
426
+ if ! strings .Contains (s , "Commit: theshortcommithash" ) {
427
+ t .Fatalf ("response doesn't contain commit:\n %s" , s )
428
+ }
429
+
430
+ if ! strings .Contains (s , "Client Version: " + id .ClientVersion ) {
431
+ t .Fatalf ("response doesn't contain client version:\n %s" , s )
432
+ }
433
+
434
+ if ! strings .Contains (s , "Protocol Version: " + id .IpfsVersion ) {
435
+ t .Fatalf ("response doesn't contain protocol version:\n %s" , s )
436
+ }
437
+ }
0 commit comments