From 6d4d238b3e790bd0170a82feb13b89f0540795d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Sowa?= Date: Thu, 7 Jan 2021 16:22:44 +0100 Subject: [PATCH] feat: Report update available --- cmd/root.go | 3 +- go.mod | 2 + go.sum | 12 ++++ internal/app/loophole/loophole.go | 38 +++++++++-- .../app/loophole/models/DisplayOptions.go | 1 + internal/pkg/apiclient/apiclient.go | 65 ++++++++++++++++--- internal/pkg/apiclient/apiclient_test.go | 18 ++--- 7 files changed, 116 insertions(+), 23 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index 5e9cf09..4d86e80 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -59,7 +59,8 @@ func initLogger() { // Execute runs command parsing chain func Execute(version string, commit string) { rootCmd.Version = fmt.Sprintf("%s (%s)", version, commit) - displayOptions.Version = fmt.Sprintf("%s-%s", version, commit) + displayOptions.Version = version + displayOptions.CommitHash = commit if err := rootCmd.Execute(); err != nil { os.Exit(1) } diff --git a/go.mod b/go.mod index 4ad7661..301fdee 100644 --- a/go.mod +++ b/go.mod @@ -4,8 +4,10 @@ go 1.14 require ( github.com/abbot/go-http-auth v0.4.0 + github.com/blang/semver/v4 v4.0.0 github.com/briandowns/spinner v1.11.1 github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381 + github.com/markbates/pkger v0.17.1 github.com/mattn/go-colorable v0.1.2 github.com/mdp/qrterminal/v3 v3.0.0 github.com/mitchellh/go-homedir v1.1.0 diff --git a/go.sum b/go.sum index fbad015..8f054bf 100644 --- a/go.sum +++ b/go.sum @@ -8,6 +8,10 @@ github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRF github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= +github.com/blang/semver v1.1.0 h1:ol1rO7QQB5uy7umSNV7VAmLugfLRD+17sYJujRNYPhg= +github.com/blang/semver v2.2.0+incompatible h1:DIb+hEi/XKX6t9Cvy5+oSlANqmc0eenMxbNBvLqpV2A= +github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM= +github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ= github.com/briandowns/spinner v1.11.1 h1:OixPqDEcX3juo5AjQZAnFPbeUA0jvkp2qzB5gOZJ/L0= github.com/briandowns/spinner v1.11.1/go.mod h1:QOuQk7x+EaDASo80FEXwlwiA+j/PPIcX3FScO+3/ZPQ= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= @@ -20,6 +24,7 @@ github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7 github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= @@ -32,6 +37,8 @@ github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2 github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/gobuffalo/here v0.6.0 h1:hYrd0a6gDmWxBM4TnrGw8mQg24iSVoIkHEk7FodQcBI= +github.com/gobuffalo/here v0.6.0/go.mod h1:wAG085dHOYqUpf+Ap+WOdrPTp5IYcDAs/x7PLa8Y5fM= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= @@ -64,6 +71,8 @@ github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381 h1:bqDmpDG49ZRn github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4= github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= +github.com/markbates/pkger v0.17.1 h1:/MKEtWqtc0mZvu9OinB9UzVN9iYCwLWuyUv4Bw+PCno= +github.com/markbates/pkger v0.17.1/go.mod h1:0JoVlrol20BSywW79rN3kdFFsE5xYM+rSCQDXbLhiuI= github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU= github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE= @@ -119,8 +128,10 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.4.0 h1:yXHLWeravcrgGyFSyCgdYpXQ9dR9c/WED3pg1RhxqEU= github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= @@ -183,6 +194,7 @@ gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bl gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/internal/app/loophole/loophole.go b/internal/app/loophole/loophole.go index 7f047da..2cb2edb 100644 --- a/internal/app/loophole/loophole.go +++ b/internal/app/loophole/loophole.go @@ -7,6 +7,7 @@ import ( "net/http" "time" + "github.com/blang/semver/v4" lm "github.com/loophole/cli/internal/app/loophole/models" "github.com/loophole/cli/internal/pkg/apiclient" "github.com/loophole/cli/internal/pkg/closehandler" @@ -53,9 +54,9 @@ func handleClient(client net.Conn, local net.Conn) { <-chDone } -func registerDomain(apiURL string, publicKey *ssh.PublicKey, requestedSiteID, version string) string { +func registerDomain(apiURL string, publicKey *ssh.PublicKey, requestedSiteID, version, commitHash string) string { communication.StartLoading("Registering your domain...") - siteID, err := apiclient.RegisterSite(apiURL, *publicKey, requestedSiteID, version) + siteID, err := apiclient.RegisterSite(apiURL, *publicKey, requestedSiteID, version, commitHash) if err != nil { communication.LoadingFailure() if requestErr, ok := err.(apiclient.RequestError); ok { @@ -247,6 +248,7 @@ func listenOnRemoteEndpoint(serverSSHConnHTTPS *ssh.Client) net.Listener { // ForwardPort is used to forward external URL to locally available port func ForwardPort(config lm.ExposeHttpConfig) { communication.PrintWelcomeMessage() + checkVersion(config.Remote.APIEndpoint.URI(), config.Display.Version) protocol := "http" if config.Local.HTTPS { @@ -259,7 +261,7 @@ func ForwardPort(config lm.ExposeHttpConfig) { } publicKeyAuthMethod, publicKey := parsePublicKey(config.Remote.IdentityFile) - siteID := registerDomain(config.Remote.APIEndpoint.URI(), &publicKey, config.Remote.SiteID, config.Display.Version) + siteID := registerDomain(config.Remote.APIEndpoint.URI(), &publicKey, config.Remote.SiteID, config.Display.Version, config.Display.CommitHash) server := createTLSReverseProxy(localEndpoint, siteID, config.Remote.BasicAuthUsername, config.Remote.BasicAuthPassword, config.Display) forward(config.Remote, config.Display, publicKeyAuthMethod, siteID, server, localEndpoint.URI(), []string{"https"}) } @@ -267,9 +269,10 @@ func ForwardPort(config lm.ExposeHttpConfig) { // ForwardDirectory is used to expose local directory via HTTP (download only) func ForwardDirectory(config lm.ExposeDirectoryConfig) { communication.PrintWelcomeMessage() + checkVersion(config.Remote.APIEndpoint.URI(), config.Display.Version) publicKeyAuthMethod, publicKey := parsePublicKey(config.Remote.IdentityFile) - siteID := registerDomain(config.Remote.APIEndpoint.URI(), &publicKey, config.Remote.SiteID, config.Display.Version) + siteID := registerDomain(config.Remote.APIEndpoint.URI(), &publicKey, config.Remote.SiteID, config.Display.Version, config.Display.CommitHash) server := getStaticFileServer(config.Local.Path, siteID, config.Remote.BasicAuthUsername, config.Remote.BasicAuthPassword) forward(config.Remote, config.Display, publicKeyAuthMethod, siteID, server, config.Local.Path, []string{"https"}) @@ -278,9 +281,10 @@ func ForwardDirectory(config lm.ExposeDirectoryConfig) { // ForwardDirectoryViaWebdav is used to expose local directory via Webdav (upload and download) func ForwardDirectoryViaWebdav(config lm.ExposeWebdavConfig) { communication.PrintWelcomeMessage() + checkVersion(config.Remote.APIEndpoint.URI(), config.Display.Version) publicKeyAuthMethod, publicKey := parsePublicKey(config.Remote.IdentityFile) - siteID := registerDomain(config.Remote.APIEndpoint.URI(), &publicKey, config.Remote.SiteID, config.Display.Version) + siteID := registerDomain(config.Remote.APIEndpoint.URI(), &publicKey, config.Remote.SiteID, config.Display.Version, config.Display.CommitHash) server := getWebdavServer(config.Local.Path, siteID, config.Remote.BasicAuthUsername, config.Remote.BasicAuthPassword) forward(config.Remote, config.Display, publicKeyAuthMethod, siteID, server, config.Local.Path, []string{"https", "davs", "webdav"}) @@ -347,3 +351,27 @@ func forward(remoteEndpointSpecs lm.RemoteEndpointSpecs, displayOptions lm.Displ }() } } + +func checkVersion(apiURL, currentVersion string) { + availableVersion, err := apiclient.GetLatestAvailableVersion(apiURL, currentVersion) + if err != nil { + communication.LogDebug("There was a problem obtaining info response, skipping further checking") + return + } + currentVersionParsed, err := semver.Make(currentVersion) + if err != nil { + communication.LogDebug(fmt.Sprintf("Cannot parse current version '%s' as semver version, skipping further checking", currentVersion)) + return + } + availableVersionParsed, err := semver.Make(availableVersion) + if err != nil { + communication.LogDebug(fmt.Sprintf("Cannot parse available version '%s' as semver version, skipping further checking", availableVersion)) + return + } + if currentVersionParsed.LT(availableVersionParsed) { + communication.WriteCyan( + fmt.Sprintf("There is new version available, to get it please visit %s", + fmt.Sprintf("https://github.com/loophole/cli/releases/tag/%s", availableVersion))) + communication.NewLine() + } +} diff --git a/internal/app/loophole/models/DisplayOptions.go b/internal/app/loophole/models/DisplayOptions.go index e294d5f..9c7bc47 100644 --- a/internal/app/loophole/models/DisplayOptions.go +++ b/internal/app/loophole/models/DisplayOptions.go @@ -7,4 +7,5 @@ type DisplayOptions struct { FeedbackFormURL string DisableProxyErrorPage bool Version string + CommitHash string } diff --git a/internal/pkg/apiclient/apiclient.go b/internal/pkg/apiclient/apiclient.go index 311af78..a8611f2 100644 --- a/internal/pkg/apiclient/apiclient.go +++ b/internal/pkg/apiclient/apiclient.go @@ -17,11 +17,16 @@ import ( "golang.org/x/crypto/ssh" ) -// SuccessResponse defines the json format in which the success response is returned -type SuccessResponse struct { +// RegistrationSuccessResponse defines the json format in which the registration success response is returned +type RegistrationSuccessResponse struct { SiteID string `json:"siteId"` } +// InfoSuccessResponse defines the json format in which the info success response is returned +type InfoSuccessResponse struct { + Version string `json:"version"` +} + // ErrorResponse defines the json format in which the error response is returned type ErrorResponse struct { StatusCode int32 `json:"statusCode"` @@ -44,7 +49,7 @@ var getAccessToken = token.GetAccessToken var tokenWasRefreshed = false // RegisterSite is a funtion used to obtain site id and register keys in the gateway -func RegisterSite(apiURL string, publicKey ssh.PublicKey, siteID, version string) (string, error) { +func RegisterSite(apiURL string, publicKey ssh.PublicKey, siteID, version, commitHash string) (string, error) { publicKeyString := publicKey.Type() + " " + base64.StdEncoding.EncodeToString(publicKey.Marshal()) if !isTokenSaved() { @@ -82,8 +87,7 @@ func RegisterSite(apiURL string, publicKey ssh.PublicKey, siteID, version string } req.Header.Set("Content-Type", "application/json") - req.Header.Set("Content-Type", "application/json") - req.Header.Set("User-Agent", fmt.Sprintf("loophole/%s (%s/%s) %s", version, runtime.GOOS, runtime.GOARCH, urlmaker.HostURL)) + req.Header.Set("User-Agent", fmt.Sprintf("loophole/%s-%s (%s/%s) %s", version, commitHash, runtime.GOOS, runtime.GOARCH, urlmaker.HostURL)) req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", accessToken)) var netTransport = &http.Transport{ @@ -130,7 +134,7 @@ func RegisterSite(apiURL string, publicKey ssh.PublicKey, siteID, version string } } tokenWasRefreshed = true - return RegisterSite(apiURL, publicKey, siteID, version) + return RegisterSite(apiURL, publicKey, siteID, version, commitHash) } return "", RequestError{ Message: "Authentication failed, try logging out and logging in again", @@ -168,7 +172,7 @@ func RegisterSite(apiURL string, publicKey ssh.PublicKey, siteID, version string } } - result := SuccessResponse{} + result := RegistrationSuccessResponse{} err = json.NewDecoder(resp.Body).Decode(&result) if err != nil { return "", err @@ -176,8 +180,53 @@ func RegisterSite(apiURL string, publicKey ssh.PublicKey, siteID, version string if el := log.Debug(); el.Enabled() { fmt.Println() - el.Interface("result", result).Msg("Response") + el.Interface("result", result).Msg("Site registration response") } return result.SiteID, nil } + +func GetLatestAvailableVersion(apiURL string, version string) (string, error) { + + req, err := http.NewRequest("GET", fmt.Sprintf("%s/api/info", apiURL), bytes.NewBuffer([]byte{})) + if err != nil { + return "", err + } + + req.Header.Set("Content-Type", "application/json") + req.Header.Set("User-Agent", fmt.Sprintf("loophole/%s (%s/%s) %s", version, runtime.GOOS, runtime.GOARCH, urlmaker.HostURL)) + + var netTransport = &http.Transport{ + Dial: (&net.Dialer{ + Timeout: 5 * time.Second, + }).Dial, + TLSHandshakeTimeout: 5 * time.Second, + } + var netClient = &http.Client{ + Timeout: time.Second * 30, + Transport: netTransport, + } + + resp, err := netClient.Do(req) + if err != nil { + return "", err + } + defer resp.Body.Close() + + if resp.StatusCode != http.StatusOK { + return "", fmt.Errorf("Request for information failed, skipping") + } + + result := InfoSuccessResponse{} + err = json.NewDecoder(resp.Body).Decode(&result) + if err != nil { + return "", err + } + + if el := log.Debug(); el.Enabled() { + fmt.Println() + el.Interface("result", result).Msg("Info response") + } + + return result.Version, nil +} diff --git a/internal/pkg/apiclient/apiclient_test.go b/internal/pkg/apiclient/apiclient_test.go index 39ad204..34d214e 100644 --- a/internal/pkg/apiclient/apiclient_test.go +++ b/internal/pkg/apiclient/apiclient_test.go @@ -29,7 +29,7 @@ func TestRegisterSiteSuccessOKShouldPropagateWithoutIdProvided(t *testing.T) { if err != nil { t.Fatal(err) } - result, err := RegisterSite(srv.URL, publicKey, "", "1.0.0") + result, err := RegisterSite(srv.URL, publicKey, "", "1.0.0", "asd123") if err != nil { t.Fatalf("Unexpected error returned: %v", err) @@ -57,7 +57,7 @@ func TestRegisterSiteSuccessCreatedShouldPropagateWithoutIdProvided(t *testing.T if err != nil { t.Fatal(err) } - result, err := RegisterSite(srv.URL, publicKey, "", "1.0.0") + result, err := RegisterSite(srv.URL, publicKey, "", "1.0.0", "asd123") if err != nil { t.Fatalf("Unexpected error returned: %v", err) @@ -86,7 +86,7 @@ func TestRegisterSiteSuccessOKShouldPropagateWithIdProvided(t *testing.T) { if err != nil { t.Fatal(err) } - result, err := RegisterSite(srv.URL, publicKey, expectedSiteID, "1.0.0") + result, err := RegisterSite(srv.URL, publicKey, expectedSiteID, "1.0.0", "asd123") if err != nil { t.Fatalf("Unexpected error returned: %v", err) @@ -114,7 +114,7 @@ func TestRegisterSiteSuccessCreatedShouldPropagateWithIdProvided(t *testing.T) { if err != nil { t.Fatal(err) } - result, err := RegisterSite(srv.URL, publicKey, expectedSiteID, "1.0.0") + result, err := RegisterSite(srv.URL, publicKey, expectedSiteID, "1.0.0", "asd123") if err != nil { t.Fatalf("Unexpected error returned: %v", err) @@ -145,7 +145,7 @@ func TestRegisterSiteError400ShouldPropagateError(t *testing.T) { if err != nil { t.Fatal(err) } - result, err := RegisterSite(srv.URL, publicKey, "", "1.0.0") + result, err := RegisterSite(srv.URL, publicKey, "", "1.0.0", "asd123") if err == nil { t.Fatalf("Expected an error to be returned") @@ -186,7 +186,7 @@ func TestRegisterSiteError401ShouldPropagateError(t *testing.T) { if err != nil { t.Fatal(err) } - result, err := RegisterSite(srv.URL, publicKey, "", "1.0.0") + result, err := RegisterSite(srv.URL, publicKey, "", "1.0.0", "asd123") if err == nil { t.Fatalf("Expected an error to be returned") @@ -227,7 +227,7 @@ func TestRegisterSiteError403ShouldPropagateError(t *testing.T) { if err != nil { t.Fatal(err) } - result, err := RegisterSite(srv.URL, publicKey, "", "1.0.0") + result, err := RegisterSite(srv.URL, publicKey, "", "1.0.0", "asd123") if err == nil { t.Fatalf("Expected an error to be returned") @@ -264,7 +264,7 @@ func TestRegisterTokenNotSavedReturns401(t *testing.T) { if err != nil { t.Fatal(err) } - result, err := RegisterSite(srv.URL, publicKey, "", "1.0.0") + result, err := RegisterSite(srv.URL, publicKey, "", "1.0.0", "asd123") if err == nil { t.Fatalf("Expected an error to be returned") @@ -298,7 +298,7 @@ func TestRegisterTokenReadingProblemReturns401(t *testing.T) { if err != nil { t.Fatal(err) } - result, err := RegisterSite(srv.URL, publicKey, "", "1.0.0") + result, err := RegisterSite(srv.URL, publicKey, "", "1.0.0", "asd123") if err == nil { t.Fatalf("Expected an error to be returned")