changelog: Milestone 1 Complete

Adjusted logging to use logrus package. Use application_default_credentials.json for authentication.

BUG=b/160901711
TEST=unittests, run local

Change-Id: I774a1c9b95180bfc092989ec5a058d0bb270b85d
diff --git a/go.mod b/go.mod
index 2c214a4..ad8835c 100644
--- a/go.mod
+++ b/go.mod
@@ -7,14 +7,15 @@
 	github.com/beevik/etree v1.1.0
 	github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
 	github.com/google/go-cmp v0.5.1
-	github.com/google/martian v2.1.0+incompatible
 	github.com/google/subcommands v1.2.0
 	github.com/julienschmidt/httprouter v1.3.0 // indirect
 	github.com/mitchellh/go-homedir v1.1.0 // indirect
 	github.com/pkg/errors v0.9.1
+	github.com/sirupsen/logrus v1.6.0
 	github.com/smartystreets/assertions v1.1.1 // indirect
 	github.com/smartystreets/goconvey v1.6.4 // indirect
 	github.com/urfave/cli/v2 v2.2.0
 	go.chromium.org/luci v0.0.0-20200722211809-bab0c30be68b
+	golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
 	google.golang.org/protobuf v1.25.0
 )
diff --git a/go.sum b/go.sum
index 4002cd1..9fdf0c0 100644
--- a/go.sum
+++ b/go.sum
@@ -48,6 +48,7 @@
 github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
 github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/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/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
 github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
 github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
@@ -119,6 +120,7 @@
 github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U=
 github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
 github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
+github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
 github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
 github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
 github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
@@ -134,12 +136,15 @@
 github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
 github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
 github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
+github.com/sirupsen/logrus v1.6.0 h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I=
+github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
 github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
 github.com/smartystreets/assertions v1.1.1 h1:T/YLemO5Yp7KPzS+lVtu+WsHn8yoSwTfItdAd1r3cck=
 github.com/smartystreets/assertions v1.1.1/go.mod h1:tcbTF8ujkAEcZ8TElKY+i30BzYlVhC/LOxJk7iOWnoo=
 github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
 github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
 github.com/stretchr/objx v0.1.0/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/urfave/cli/v2 v2.2.0 h1:JTTnM6wKzdA0Jqodd966MVj4vWbbquZykeX1sKbe2C4=
 github.com/urfave/cli/v2 v2.2.0/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
@@ -229,6 +234,7 @@
 golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
diff --git a/src/cmd/changelog/README.md b/src/cmd/changelog/README.md
index 56953ed..785094f 100644
--- a/src/cmd/changelog/README.md
+++ b/src/cmd/changelog/README.md
@@ -17,6 +17,8 @@
 
 `--repo | -r`: (optional) Specifies the repository for manifest-snapshot files within the Git on Borg instance. It will use "cos/manifest-snapshots" if not specified.
 
+`--debug | -d`: (optional) Enables debug messages.
+
 ## Output
 
 Creates 2 JSON files representing the changelog between 2 given build numbers. Each output file maps repositories to their repository changelog. A repository changelog consists of all the commits in a repository that were present in between the build numbers.
diff --git a/src/cmd/changelog/main.go b/src/cmd/changelog/main.go
index ca0e8b2..3eb0731 100755
--- a/src/cmd/changelog/main.go
+++ b/src/cmd/changelog/main.go
@@ -29,16 +29,17 @@
 	"errors"
 	"fmt"
 	"io/ioutil"
+	"net/http"
 	"os"
 	"time"
 
 	"cos.googlesource.com/cos/tools/src/pkg/changelog"
+	"golang.org/x/oauth2"
+	"golang.org/x/oauth2/google"
 
-	"github.com/google/martian/log"
+	log "github.com/sirupsen/logrus"
 	"github.com/urfave/cli/v2"
-	"go.chromium.org/luci/auth"
 	"go.chromium.org/luci/common/api/gerrit"
-	"go.chromium.org/luci/hardcoded/chromeinfra"
 )
 
 // Default Manifest location
@@ -47,46 +48,54 @@
 	defaultManifestRepo string = "cos/manifest-snapshots"
 )
 
-func getAuthenticator() *auth.Authenticator {
-	opts := chromeinfra.DefaultAuthOptions()
-	opts.Scopes = []string{gerrit.OAuthScope, auth.OAuthScopeEmail}
-	return auth.NewAuthenticator(context.Background(), auth.InteractiveLogin, opts)
+func getHTTPClient() (*http.Client, error) {
+	log.Info("Creating HTTP client")
+	creds, err := google.FindDefaultCredentials(context.Background(), gerrit.OAuthScope)
+	if err != nil || len(creds.JSON) == 0 {
+		return nil, fmt.Errorf("no application default credentials found - run `gcloud auth application-default login` and try again")
+	}
+	return oauth2.NewClient(oauth2.NoContext, creds.TokenSource), nil
 }
 
 func writeChangelogAsJSON(source string, target string, changes map[string][]*changelog.Commit) error {
+	fileName := fmt.Sprintf("%s -> %s.json", source, target)
+	log.Infof("Writing changelog to %s\n", fileName)
 	jsonData, err := json.MarshalIndent(changes, "", "    ")
 	if err != nil {
-		return fmt.Errorf("writeChangelogAsJSON: Error marshalling changelog from: %s to: %s\n%v", source, target, err)
+		return fmt.Errorf("writeChangelogAsJSON: error marshalling changelog from: %s to: %s\n%v", source, target, err)
 	}
-	fileName := fmt.Sprintf("%s -> %s.json", source, target)
 	if err = ioutil.WriteFile(fileName, jsonData, 0644); err != nil {
-		return fmt.Errorf("writeChangelogAsJSON: Error writing changelog to file: %s\n%v", fileName, err)
+		return fmt.Errorf("writeChangelogAsJSON: error writing changelog to file: %s\n%v", fileName, err)
 	}
 	return nil
 }
 
-func generateChangelog(source, target, instance, manifestRepo string) {
+func generateChangelog(source, target, instance, manifestRepo string) error {
 	start := time.Now()
-	authenticator := getAuthenticator()
-	sourceToTargetChanges, targetToSourceChanges, err := changelog.Changelog(authenticator, source, target, instance, manifestRepo)
+	httpClient, err := getHTTPClient()
 	if err != nil {
-		log.Infof("generateChangelog: error retrieving changelog between builds %s and %s on GoB instance: %s with manifest repository: %s\n%v\n",
+		return fmt.Errorf("generateChangelog: failed to create http client: \n%v", err)
+	}
+	sourceToTargetChanges, targetToSourceChanges, err := changelog.Changelog(httpClient, source, target, instance, manifestRepo)
+	if err != nil {
+		return fmt.Errorf("generateChangelog: error retrieving changelog between builds %s and %s on GoB instance: %s with manifest repository: %s\n%v",
 			source, target, instance, manifestRepo, err)
-		os.Exit(1)
 	}
 	if err := writeChangelogAsJSON(source, target, sourceToTargetChanges); err != nil {
-		log.Infof("generateChangelog: error writing first changelog with source: %s and target: %s\n%v\n",
+		log.Errorf("generateChangelog: error writing first changelog with source: %s and target: %s\n%v\n",
 			source, target, err)
 	}
 	if err := writeChangelogAsJSON(target, source, targetToSourceChanges); err != nil {
-		log.Infof("generateChangelog: Error writing second changelog with source: %s and target: %s\n%v\n",
+		log.Errorf("generateChangelog: Error writing second changelog with source: %s and target: %s\n%v\n",
 			target, source, err)
 	}
 	log.Infof("Retrieved changelog in %s\n", time.Since(start))
+	return nil
 }
 
 func main() {
 	var instance, manifestRepo string
+	var debug bool
 	app := &cli.App{
 		Name:  "changelog",
 		Usage: "get commits between builds",
@@ -105,20 +114,29 @@
 				Usage:       "`REPO` containing Manifest file",
 				Destination: &manifestRepo,
 			},
+			&cli.BoolFlag{
+				Name:        "debug",
+				Value:       false,
+				Aliases:     []string{"d"},
+				Usage:       "Toggle debug messages",
+				Destination: &debug,
+			},
 		},
 		Action: func(c *cli.Context) error {
 			if c.NArg() < 2 {
 				return errors.New("Must specify source and target build number")
 			}
+			if debug {
+				log.SetLevel(log.DebugLevel)
+			}
 			source := c.Args().Get(0)
 			target := c.Args().Get(1)
-			generateChangelog(source, target, instance, manifestRepo)
-			return nil
+			return generateChangelog(source, target, instance, manifestRepo)
 		},
 	}
 	err := app.Run(os.Args)
 	if err != nil {
-		log.Infof("main: error running app with arguments: %v:\n%v", os.Args, err)
+		log.Errorf("main: error running app with arguments: %v:\n%v", os.Args, err)
 		os.Exit(1)
 	}
 }
diff --git a/src/pkg/changelog/changelog.go b/src/pkg/changelog/changelog.go
index 8d25802..e984581 100755
--- a/src/pkg/changelog/changelog.go
+++ b/src/pkg/changelog/changelog.go
@@ -33,12 +33,12 @@
 	"context"
 	"errors"
 	"fmt"
+	"net/http"
 	"strings"
 	"time"
 
 	"github.com/beevik/etree"
-	"github.com/google/martian/log"
-	"go.chromium.org/luci/auth"
+	log "github.com/sirupsen/logrus"
 	gitilesApi "go.chromium.org/luci/common/api/gitiles"
 	gitilesProto "go.chromium.org/luci/common/proto/gitiles"
 )
@@ -76,22 +76,23 @@
 	Err       error
 }
 
-func client(authenticator *auth.Authenticator, remoteURL string) (gitilesProto.GitilesClient, error) {
-	authedClient, err := authenticator.Client()
-	cl, err := gitilesApi.NewRESTClient(authedClient, remoteURL, true)
+func gerritClient(httpClient *http.Client, remoteURL string) (gitilesProto.GitilesClient, error) {
+	log.Debugf("Creating Gerrit client for remote url %s\n", remoteURL)
+	cl, err := gitilesApi.NewRESTClient(httpClient, remoteURL, true)
 	if err != nil {
 		return nil, errors.New("changelog: Failed to establish client to remote url: " + remoteURL)
 	}
 	return cl, nil
 }
 
-func createClients(clients map[string]gitilesProto.GitilesClient, authenticator *auth.Authenticator, repoMap map[string]*repo) error {
+func createGerritClients(clients map[string]gitilesProto.GitilesClient, httpClient *http.Client, repoMap map[string]*repo) error {
+	log.Debug("Creating additional Gerrit clients for manifest file if not already created")
 	for _, repoData := range repoMap {
 		remoteURL := repoData.InstanceURL
 		if _, ok := clients[remoteURL]; ok {
 			continue
 		}
-		client, err := client(authenticator, remoteURL)
+		client, err := gerritClient(httpClient, remoteURL)
 		if err != nil {
 			return fmt.Errorf("createClients: error creating client mapping:\n%v", err)
 		}
@@ -104,6 +105,7 @@
 // This eliminates the need to track remote names and allows lookup
 // of source committish when generating changelog.
 func repoMap(manifest string) (map[string]*repo, error) {
+	log.Debug("Mapping repository to instance URL and committish")
 	doc := etree.NewDocument()
 	if err := doc.ReadFromString(manifest); err != nil {
 		return nil, fmt.Errorf("repoMap: error parsing manifest xml:\n%v", err)
@@ -135,6 +137,7 @@
 
 // mappedManifest retrieves a Manifest file from GoB and unmarshals XML.
 func mappedManifest(client gitilesProto.GitilesClient, repo string, buildNum string) (map[string]*repo, error) {
+	log.Debugf("Retrieving manifest file for build %s\n", buildNum)
 	request := gitilesProto.DownloadFileRequest{
 		Project:    repo,
 		Committish: "refs/tags/" + buildNum,
@@ -156,6 +159,7 @@
 
 // commits get all commits that occur between committish and ancestor for a specific repo.
 func commits(client gitilesProto.GitilesClient, repo string, committish string, ancestor string, outputChan chan commitsResult) {
+	log.Debugf("Fetching changelog for repo: %s on committish %s\n", repo, committish)
 	start := time.Now()
 	pageSize := defaultPageSize
 	request := gitilesProto.LogRequest{
@@ -173,7 +177,7 @@
 	// No nextPageToken means there were less than <defaultPageSize> commits total.
 	// We can immediately return.
 	if response.NextPageToken == "" {
-		log.Infof("Retrieved %d commits from %s in %s\n", len(response.Log), repo, time.Since(start))
+		log.Debugf("Retrieved %d commits from %s in %s\n", len(response.Log), repo, time.Since(start))
 		parsedCommits, err := ParseGitCommitLog(response.Log)
 		if err != nil {
 			outputChan <- commitsResult{Err: fmt.Errorf("commits: Error parsing log response for repo: %s with committish: %s and ancestor %s:\n%v",
@@ -204,7 +208,7 @@
 		}
 		allCommits = append(allCommits, response.Log...)
 	}
-	log.Infof("Retrieved %d commits from %s in %s\n", len(allCommits), repo, time.Since(start))
+	log.Debugf("Retrieved %d commits from %s in %s\n", len(allCommits), repo, time.Since(start))
 	parsedCommits, err := ParseGitCommitLog(allCommits)
 	if err != nil {
 		outputChan <- commitsResult{Err: fmt.Errorf("commits: Error parsing log response for repo: %s with committish: %s and ancestor %s:\n%v",
@@ -217,6 +221,7 @@
 // additions retrieves all commits that occured between 2 parsed manifest files for each repo.
 // Returns a map of repo name -> list of commits.
 func additions(clients map[string]gitilesProto.GitilesClient, sourceRepos map[string]*repo, targetRepos map[string]*repo, outputChan chan additionsResult) {
+	log.Debug("Retrieving commit additions")
 	repoCommits := make(map[string][]*Commit)
 	commitsChan := make(chan commitsResult, len(targetRepos))
 	for repoURL, targetRepoInfo := range targetRepos {
@@ -264,12 +269,13 @@
 //
 // The second changelog contains all commits that are present in the source build
 // but not present in the target build
-func Changelog(authenticator *auth.Authenticator, sourceBuildNum string, targetBuildNum string, host string, repo string) (map[string][]*Commit, map[string][]*Commit, error) {
+func Changelog(httpClient *http.Client, sourceBuildNum string, targetBuildNum string, host string, repo string) (map[string][]*Commit, map[string][]*Commit, error) {
+	log.Infof("Retrieving changelog between %s and %s\n", sourceBuildNum, targetBuildNum)
 	clients := make(map[string]gitilesProto.GitilesClient)
 
 	// Since the manifest file is always in the cos instance, add cos client
 	// so that client knows what URL to use
-	manifestClient, err := client(authenticator, host)
+	manifestClient, err := gerritClient(httpClient, host)
 	if err != nil {
 		return nil, nil, fmt.Errorf("Changelog: error creating client for GoB instance: %s:\n%v", host, err)
 	}
@@ -285,11 +291,11 @@
 	}
 
 	clients[host] = manifestClient
-	err = createClients(clients, authenticator, sourceRepos)
+	err = createGerritClients(clients, httpClient, sourceRepos)
 	if err != nil {
 		return nil, nil, fmt.Errorf("Changelog: error creating source clients:\n%v", err)
 	}
-	err = createClients(clients, authenticator, targetRepos)
+	err = createGerritClients(clients, httpClient, targetRepos)
 	if err != nil {
 		return nil, nil, fmt.Errorf("Changelog: error creating target clients:\n%v", err)
 	}
diff --git a/src/pkg/changelog/changelog_test.go b/src/pkg/changelog/changelog_test.go
index 361750e..6113444 100644
--- a/src/pkg/changelog/changelog_test.go
+++ b/src/pkg/changelog/changelog_test.go
@@ -16,20 +16,24 @@
 
 import (
 	"context"
+	"fmt"
+	"net/http"
 	"testing"
 
-	"go.chromium.org/luci/auth"
 	"go.chromium.org/luci/common/api/gerrit"
-	"go.chromium.org/luci/hardcoded/chromeinfra"
+	"golang.org/x/oauth2"
+	"golang.org/x/oauth2/google"
 )
 
 const cosInstance = "cos.googlesource.com"
 const defaultManifestRepo = "cos/manifest-snapshots"
 
-func getAuthenticator() *auth.Authenticator {
-	opts := chromeinfra.DefaultAuthOptions()
-	opts.Scopes = []string{gerrit.OAuthScope, auth.OAuthScopeEmail}
-	return auth.NewAuthenticator(context.Background(), auth.InteractiveLogin, opts)
+func getHTTPClient() (*http.Client, error) {
+	creds, err := google.FindDefaultCredentials(context.Background(), gerrit.OAuthScope)
+	if err != nil || len(creds.JSON) == 0 {
+		return nil, fmt.Errorf("no application default credentials found - run `gcloud auth application-default login` and try again")
+	}
+	return oauth2.NewClient(oauth2.NoContext, creds.TokenSource), nil
 }
 
 func commitsMatch(commits []*Commit, expectedCommits []string) bool {
@@ -57,10 +61,10 @@
 }
 
 func TestChangelog(t *testing.T) {
-	authenticator := getAuthenticator()
+	httpClient, err := getHTTPClient()
 
 	// Test invalid source
-	additions, misses, err := Changelog(authenticator, "15", "15043.0.0", cosInstance, defaultManifestRepo)
+	additions, misses, err := Changelog(httpClient, "15", "15043.0.0", cosInstance, defaultManifestRepo)
 	if additions != nil {
 		t.Errorf("Changelog failed, expected nil additions, got %v", additions)
 	} else if misses != nil {
@@ -70,7 +74,7 @@
 	}
 
 	// Test invalid target
-	additions, misses, err = Changelog(authenticator, "15043.0.0", "abx", cosInstance, defaultManifestRepo)
+	additions, misses, err = Changelog(httpClient, "15043.0.0", "abx", cosInstance, defaultManifestRepo)
 	if additions != nil {
 		t.Errorf("Changelog failed, expected nil additions, got %v", additions)
 	} else if misses != nil {
@@ -80,7 +84,7 @@
 	}
 
 	// Test invalid instance
-	additions, misses, err = Changelog(authenticator, "15036.0.0", "15041.0.0", "com", defaultManifestRepo)
+	additions, misses, err = Changelog(httpClient, "15036.0.0", "15041.0.0", "com", defaultManifestRepo)
 	if additions != nil {
 		t.Errorf("Changelog failed, expected nil additions, got %v", additions)
 	} else if misses != nil {
@@ -90,7 +94,7 @@
 	}
 
 	// Test invalid manifest repo
-	additions, misses, err = Changelog(authenticator, "15036.0.0", "15041.0.0", cosInstance, "cos/not-a-repo")
+	additions, misses, err = Changelog(httpClient, "15036.0.0", "15041.0.0", cosInstance, "cos/not-a-repo")
 	if additions != nil {
 		t.Errorf("Changelog failed, expected nil additions, got %v", additions)
 	} else if misses != nil {
@@ -100,7 +104,7 @@
 	}
 
 	// Test build number higher than latest release
-	additions, misses, err = Changelog(authenticator, "15036.0.0", "99999.0.0", cosInstance, defaultManifestRepo)
+	additions, misses, err = Changelog(httpClient, "15036.0.0", "99999.0.0", cosInstance, defaultManifestRepo)
 	if additions != nil {
 		t.Errorf("Changelog failed, expected nil additions, got %v", additions)
 	} else if misses != nil {
@@ -223,7 +227,7 @@
 		"9bc12bb411f357188d008864f80dfba43210b9d8",
 		"bf0dd3757826b9bc9d7082f5f749ff7615d4bcb3",
 	}
-	additions, misses, err = Changelog(authenticator, source, target, cosInstance, defaultManifestRepo)
+	additions, misses, err = Changelog(httpClient, source, target, cosInstance, defaultManifestRepo)
 	if err != nil {
 		t.Errorf("Changelog failed, expected no error, got %v", err)
 	} else if len(misses) != 0 {
@@ -262,7 +266,7 @@
 		"mirrors/cros/chromiumos/repohooks",
 		"mirrors/cros/chromiumos/overlays/portage-stable",
 	}
-	additions, misses, err = Changelog(authenticator, source, target, cosInstance, defaultManifestRepo)
+	additions, misses, err = Changelog(httpClient, source, target, cosInstance, defaultManifestRepo)
 	if err != nil {
 		t.Errorf("Changelog failed, expected no error, got %v", err)
 	} else if _, ok := misses["third_party/kernel"]; len(misses) != 1 && ok {