diff --git a/.travis.yml b/.travis.yml index 2a7d54336..399a56030 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,7 +39,9 @@ script: - misspell -error -locale US $GOFILES - gocyclo -over 20 $GOFILES - golint -set_exit_status $GOFILES -- staticcheck ./cmd/*/*.go *.go # TODO(adam): later add ./pkg/*/*.go +- staticcheck ./cmd/server/*.go +- staticcheck ./internal/database/*.go +- staticcheck *.go - if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then choco install -y mingw; export PATH=/c/tools/mingw64/bin:"$PATH";fi after_success: - bash <(curl -s https://codecov.io/bash) -X fix diff --git a/cmd/server/approval.go b/cmd/server/approval.go index e72205436..9c0541ad5 100644 --- a/cmd/server/approval.go +++ b/cmd/server/approval.go @@ -39,8 +39,8 @@ var ( // TODO(adam): We need to hide these behind an admin level auth, but we'll write them for now. // What about a header like x-admin-id ?? func addApprovalRoutes(logger log.Logger, svc *admin.Server, repo customerRepository, ofac *ofacSearcher) { - svc.AddHandler("/customers/{customerId}/status", updateCustomerStatus(logger, repo, ofac)) - svc.AddHandler("/customers/{customerId}/addresses/{addressId}", updateCustomerAddress(logger, repo)) + svc.AddHandler("/customers/{customerID}/status", updateCustomerStatus(logger, repo, ofac)) + svc.AddHandler("/customers/{customerID}/addresses/{addressId}", updateCustomerAddress(logger, repo)) } type updateCustomerStatusRequest struct { @@ -54,7 +54,7 @@ type updateCustomerStatusRequest struct { // - KYC is only valid if the Customer has first, last, address, and date of birth // - OFAC can only be after an OFAC search has been performed (and search info recorded) // - CIP can only be if the SSN has been set -func validCustomerStatusTransition(existing *client.Customer, futureStatus CustomerStatus, repo customerRepository, ofac *ofacSearcher, requestId string) error { +func validCustomerStatusTransition(existing *client.Customer, futureStatus CustomerStatus, repo customerRepository, ofac *ofacSearcher, requestID string) error { eql := func(s string, status CustomerStatus) bool { return strings.EqualFold(s, string(status)) } @@ -117,8 +117,8 @@ func updateCustomerStatus(logger log.Logger, repo customerRepository, ofac *ofac return } - customerId, requestId := getCustomerID(w, r), moovhttp.GetRequestId(r) - if customerId == "" { + customerID, requestID := getCustomerID(w, r), moovhttp.GetRequestID(r) + if customerID == "" { return } @@ -128,23 +128,23 @@ func updateCustomerStatus(logger log.Logger, repo customerRepository, ofac *ofac return } - cust, err := repo.getCustomer(customerId) + cust, err := repo.getCustomer(customerID) if err != nil { moovhttp.Problem(w, err) return } - if err := validCustomerStatusTransition(cust, req.Status, repo, ofac, requestId); err != nil { + if err := validCustomerStatusTransition(cust, req.Status, repo, ofac, requestID); err != nil { moovhttp.Problem(w, err) return } // Update Customer's status in the database - if err := repo.updateCustomerStatus(customerId, req.Status, req.Comment); err != nil { + if err := repo.updateCustomerStatus(customerID, req.Status, req.Comment); err != nil { moovhttp.Problem(w, err) return } - respondWithCustomer(logger, w, customerId, requestId, repo) + respondWithCustomer(logger, w, customerID, requestID, repo) } } @@ -159,7 +159,7 @@ func getAddressId(w http.ResponseWriter, r *http.Request) string { // TODO(adam): Should Addresses have a 'Type: Previous'? I don't think we ever want to delete an address, but it can be marked as old. // If we keep address info around does it have GDPR implications? -// PUT /customers/{customerId}/addresses/{addressId} only accept {"type": "Primary/Secondary", "validated": true/false} +// PUT /customers/{customerID}/addresses/{addressId} only accept {"type": "Primary/Secondary", "validated": true/false} type updateCustomerAddressRequest struct { Type string `json:"type"` @@ -184,8 +184,8 @@ func updateCustomerAddress(logger log.Logger, repo customerRepository) http.Hand return } - customerId, addressId := getCustomerID(w, r), getAddressId(w, r) - if customerId == "" || addressId == "" { + customerID, addressId := getCustomerID(w, r), getAddressId(w, r) + if customerID == "" || addressId == "" { return } @@ -199,14 +199,14 @@ func updateCustomerAddress(logger log.Logger, repo customerRepository) http.Hand return } - requestId := moovhttp.GetRequestId(r) - logger.Log("approval", fmt.Sprintf("updating address=%s for customer=%s", addressId, customerId), "requestId", requestId) + requestID := moovhttp.GetRequestID(r) + logger.Log("approval", fmt.Sprintf("updating address=%s for customer=%s", addressId, customerID), "requestID", requestID) - if err := repo.updateCustomerAddress(customerId, addressId, req.Type, req.Validated); err != nil { - logger.Log("approval", fmt.Sprintf("error updating customer=%s address=%s: %v", customerId, addressId, err), "requestId", requestId) + if err := repo.updateCustomerAddress(customerID, addressId, req.Type, req.Validated); err != nil { + logger.Log("approval", fmt.Sprintf("error updating customer=%s address=%s: %v", customerID, addressId, err), "requestID", requestID) moovhttp.Problem(w, err) return } - respondWithCustomer(logger, w, customerId, requestId, repo) + respondWithCustomer(logger, w, customerID, requestID, repo) } } diff --git a/cmd/server/approval_ofac.go b/cmd/server/approval_ofac.go index 758737549..3e34b8d6c 100644 --- a/cmd/server/approval_ofac.go +++ b/cmd/server/approval_ofac.go @@ -27,17 +27,17 @@ type ofacSearcher struct { // storeCustomerOFACSearch performs OFAC searches against the Customer's name and nickname if populated. // The higher matching search result is stored in s.customerRepository for use later (in approvals) -func (s *ofacSearcher) storeCustomerOFACSearch(cust *client.Customer, requestId string) error { +func (s *ofacSearcher) storeCustomerOFACSearch(cust *client.Customer, requestID string) error { ctx, cancelFn := context.WithTimeout(context.TODO(), 10*time.Second) defer cancelFn() - sdn, err := s.ofacClient.Search(ctx, formatCustomerName(cust), requestId) + sdn, err := s.ofacClient.Search(ctx, formatCustomerName(cust), requestID) if err != nil { return fmt.Errorf("ofacSearcher.storeCustomerOFACSearch: name search for customer=%s: %v", cust.ID, err) } var nickSDN *ofac.Sdn if cust.NickName != "" { - nickSDN, err = s.ofacClient.Search(ctx, cust.NickName, requestId) + nickSDN, err = s.ofacClient.Search(ctx, cust.NickName, requestID) if err != nil { return fmt.Errorf("ofacSearcher.storeCustomerOFACSearch: nickname search for customer=%s: %v", cust.ID, err) } diff --git a/cmd/server/bucket_test.go b/cmd/server/bucket_test.go index 74f4b90b2..0963abcb6 100644 --- a/cmd/server/bucket_test.go +++ b/cmd/server/bucket_test.go @@ -31,11 +31,11 @@ var ( func TestBucket__openBucket(t *testing.T) { // test the invalid cases - bucket, err := openBucket(nil, "", "", nil) + bucket, err := openBucket(context.TODO(), "", "", nil) if bucket != nil || err == nil { t.Errorf("expected error: bucket=%v error=%v", bucket, err) } - bucket, err = openBucket(nil, "", "other", nil) + bucket, err = openBucket(context.TODO(), "", "other", nil) if bucket != nil || err == nil { t.Errorf("expected error: bucket=%v error=%v", bucket, err) } @@ -64,14 +64,14 @@ func TestBucket__getBucket(t *testing.T) { } func TestBucketAWS(t *testing.T) { - bucket, err := openBucket(nil, "", "aws", nil) + bucket, err := openBucket(context.TODO(), "", "aws", nil) if err == nil || bucket != nil { t.Errorf("expected error bucket=%v", bucket) } } func TestBucketGCP(t *testing.T) { - bucket, err := openBucket(nil, "", "gcp", nil) + bucket, err := openBucket(context.TODO(), "", "gcp", nil) if err == nil || bucket != nil { t.Errorf("expected error bucket=%v", bucket) } diff --git a/cmd/server/customer_ssn.go b/cmd/server/customer_ssn.go index dea85458c..ad42a0dbb 100644 --- a/cmd/server/customer_ssn.go +++ b/cmd/server/customer_ssn.go @@ -16,14 +16,14 @@ import ( ) type SSN struct { - customerId string + customerID string encrypted []byte masked string } func (s *SSN) String() string { - return fmt.Sprintf("SSN: customerId=%s masked=%s", s.customerId, s.masked) + return fmt.Sprintf("SSN: customerID=%s masked=%s", s.customerID, s.masked) } type ssnStorage struct { @@ -31,23 +31,23 @@ type ssnStorage struct { repo customerSSNRepository } -func (s *ssnStorage) encryptRaw(customerId, raw string) (*SSN, error) { +func (s *ssnStorage) encryptRaw(customerID, raw string) (*SSN, error) { defer func() { raw = "" }() - if customerId == "" || raw == "" { - return nil, fmt.Errorf("missing customer=%s and/or SSN", customerId) + if customerID == "" || raw == "" { + return nil, fmt.Errorf("missing customer=%s and/or SSN", customerID) } - keeper, err := s.keeperFactory(fmt.Sprintf("customer-%s-ssn", customerId)) + keeper, err := s.keeperFactory(fmt.Sprintf("customer-%s-ssn", customerID)) if err != nil { - return nil, fmt.Errorf("ssnStorage: keeper init customer=%s: %v", customerId, err) + return nil, fmt.Errorf("ssnStorage: keeper init customer=%s: %v", customerID, err) } encrypted, err := keeper.Encrypt(context.Background(), []byte(raw)) if err != nil { - return nil, fmt.Errorf("ssnStorage: encrypt customer=%s: %v", customerId, err) + return nil, fmt.Errorf("ssnStorage: encrypt customer=%s: %v", customerID, err) } return &SSN{ - customerId: customerId, + customerID: customerID, encrypted: encrypted, masked: maskSSN(raw), }, nil @@ -66,7 +66,7 @@ func maskSSN(s string) string { type customerSSNRepository interface { saveCustomerSSN(*SSN) error - getCustomerSSN(customerId string) (*SSN, error) + getCustomerSSN(customerID string) (*SSN, error) } type sqlCustomerSSNRepository struct { @@ -89,13 +89,13 @@ func (r *sqlCustomerSSNRepository) saveCustomerSSN(ssn *SSN) error { defer stmt.Close() encoded := base64.StdEncoding.EncodeToString(ssn.encrypted) - if _, err := stmt.Exec(ssn.customerId, encoded, ssn.masked, time.Now()); err != nil { + if _, err := stmt.Exec(ssn.customerID, encoded, ssn.masked, time.Now()); err != nil { return fmt.Errorf("sqlCustomerSSNRepository: saveCustomerSSN: exec: %v", err) } return nil } -func (r *sqlCustomerSSNRepository) getCustomerSSN(customerId string) (*SSN, error) { +func (r *sqlCustomerSSNRepository) getCustomerSSN(customerID string) (*SSN, error) { query := `select ssn, ssn_masked from customer_ssn where customer_id = ? limit 1;` stmt, err := r.db.Prepare(query) if err != nil { @@ -103,11 +103,11 @@ func (r *sqlCustomerSSNRepository) getCustomerSSN(customerId string) (*SSN, erro } defer stmt.Close() - row := stmt.QueryRow(customerId) + row := stmt.QueryRow(customerID) var encoded string ssn := SSN{ - customerId: customerId, + customerID: customerID, } if err := row.Scan(&encoded, &ssn.masked); err != nil { if err == sql.ErrNoRows { diff --git a/cmd/server/customer_ssn_test.go b/cmd/server/customer_ssn_test.go index 1d58c8c78..294516052 100644 --- a/cmd/server/customer_ssn_test.go +++ b/cmd/server/customer_ssn_test.go @@ -35,7 +35,7 @@ func (r *testCustomerSSNRepository) saveCustomerSSN(*SSN) error { return r.err } -func (r *testCustomerSSNRepository) getCustomerSSN(customerId string) (*SSN, error) { +func (r *testCustomerSSNRepository) getCustomerSSN(customerID string) (*SSN, error) { if r.ssn != nil { return r.ssn, nil } @@ -43,9 +43,9 @@ func (r *testCustomerSSNRepository) getCustomerSSN(customerId string) (*SSN, err } func TestSSN(t *testing.T) { - customerId := base.ID() - ssn := &SSN{customerId: customerId, masked: "1###5"} - if v := ssn.String(); v != fmt.Sprintf("SSN: customerId=%s masked=1###5", customerId) { + customerID := base.ID() + ssn := &SSN{customerID: customerID, masked: "1###5"} + if v := ssn.String(); v != fmt.Sprintf("SSN: customerID=%s masked=1###5", customerID) { t.Errorf("got %s", v) } @@ -55,7 +55,7 @@ func TestSSN(t *testing.T) { return nil, errors.New("bad error") }, } - if _, err := storage.encryptRaw(customerId, "1###5"); err == nil { + if _, err := storage.encryptRaw(customerID, "1###5"); err == nil { t.Error("expected error") } else { if !strings.Contains(err.Error(), "ssnStorage: keeper init") { @@ -77,19 +77,19 @@ func TestCustomerSSNStorage(t *testing.T) { } // encrypt SSN - customerId := base.ID() - ssn, err := storage.encryptRaw(customerId, "123456789") + customerID := base.ID() + ssn, err := storage.encryptRaw(customerID, "123456789") if err != nil { t.Error(err) } - if ssn.customerId != customerId { - t.Errorf("ssn.customerId=%s", ssn.customerId) + if ssn.customerID != customerID { + t.Errorf("ssn.customerID=%s", ssn.customerID) } if ssn.masked != "1#######9" { t.Errorf("ssn.masked=%s", ssn.masked) } - keeper, err := storage.keeperFactory(fmt.Sprintf("customer-%s-ssn", customerId)) + keeper, err := storage.keeperFactory(fmt.Sprintf("customer-%s-ssn", customerID)) if err != nil { t.Fatal(err) } @@ -103,22 +103,22 @@ func TestCustomerSSNStorage(t *testing.T) { } func TestCustomerSSNRepository(t *testing.T) { - customerId := base.ID() + customerID := base.ID() check := func(t *testing.T, customerSSNRepo *sqlCustomerSSNRepository) { - if ssn, err := customerSSNRepo.getCustomerSSN(customerId); ssn != nil || err != nil { + if ssn, err := customerSSNRepo.getCustomerSSN(customerID); ssn != nil || err != nil { t.Fatalf("ssn=%v error=%v", ssn, err) } // write bs := base64.StdEncoding.EncodeToString([]byte("123456789")) - ssn := &SSN{customerId: customerId, encrypted: []byte(bs), masked: "1#######9"} + ssn := &SSN{customerID: customerID, encrypted: []byte(bs), masked: "1#######9"} if err := customerSSNRepo.saveCustomerSSN(ssn); err != nil { t.Fatal(err) } // read again - ssn, err := customerSSNRepo.getCustomerSSN(customerId) + ssn, err := customerSSNRepo.getCustomerSSN(customerID) if ssn == nil || err != nil { t.Fatalf("ssn=%v error=%v", ssn, err) } diff --git a/cmd/server/customers.go b/cmd/server/customers.go index 13f328c24..0101b130f 100644 --- a/cmd/server/customers.go +++ b/cmd/server/customers.go @@ -64,14 +64,14 @@ func (cs *CustomerStatus) UnmarshalJSON(b []byte) error { } func addCustomerRoutes(logger log.Logger, r *mux.Router, repo customerRepository, customerSSNStorage *ssnStorage, ofac *ofacSearcher) { - r.Methods("GET").Path("/customers/{customerId}").HandlerFunc(getCustomer(logger, repo)) + r.Methods("GET").Path("/customers/{customerID}").HandlerFunc(getCustomer(logger, repo)) r.Methods("POST").Path("/customers").HandlerFunc(createCustomer(logger, repo, customerSSNStorage, ofac)) - r.Methods("PUT").Path("/customers/{customerId}/metadata").HandlerFunc(replaceCustomerMetadata(logger, repo)) - r.Methods("POST").Path("/customers/{customerId}/address").HandlerFunc(addCustomerAddress(logger, repo)) + r.Methods("PUT").Path("/customers/{customerID}/metadata").HandlerFunc(replaceCustomerMetadata(logger, repo)) + r.Methods("POST").Path("/customers/{customerID}/address").HandlerFunc(addCustomerAddress(logger, repo)) } func getCustomerID(w http.ResponseWriter, r *http.Request) string { - v, ok := mux.Vars(r)["customerId"] + v, ok := mux.Vars(r)["customerID"] if !ok || v == "" { moovhttp.Problem(w, errNoCustomerID) return "" @@ -100,7 +100,7 @@ func getCustomer(logger log.Logger, repo customerRepository) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { w = wrapResponseWriter(logger, w, r) - customerID, requestID := getCustomerID(w, r), moovhttp.GetRequestId(r) + customerID, requestID := getCustomerID(w, r), moovhttp.GetRequestID(r) if customerID == "" { return } @@ -233,7 +233,7 @@ func createCustomer(logger log.Logger, repo customerRepository, customerSSNStora moovhttp.Problem(w, err) return } - requestID := moovhttp.GetRequestId(r) + requestID := moovhttp.GetRequestID(r) cust, ssn, err := req.asCustomer(customerSSNStorage) if err != nil { @@ -289,7 +289,7 @@ func replaceCustomerMetadata(logger log.Logger, repo customerRepository) http.Ha moovhttp.Problem(w, err) return } - customerID, requestID := getCustomerID(w, r), moovhttp.GetRequestId(r) + customerID, requestID := getCustomerID(w, r), moovhttp.GetRequestID(r) if customerID == "" { return } @@ -304,7 +304,7 @@ func replaceCustomerMetadata(logger log.Logger, repo customerRepository) http.Ha func addCustomerAddress(logger log.Logger, repo customerRepository) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - customerID, requestID := getCustomerID(w, r), moovhttp.GetRequestId(r) + customerID, requestID := getCustomerID(w, r), moovhttp.GetRequestID(r) if customerID == "" { return } diff --git a/cmd/server/customers_test.go b/cmd/server/customers_test.go index 7b17c4892..0d11099b5 100644 --- a/cmd/server/customers_test.go +++ b/cmd/server/customers_test.go @@ -714,28 +714,6 @@ func mockCustomerRequest() customerRequest { return c } -func mockClientRequest() client.Customer { - cli := client.Customer{} - cli.FirstName = "John" - cli.LastName = "Doe" - cli.Email = "johndoe@example.net" - - p := client.Phone{} - p.Number = "123-456-7892" - p.Type = "cell" - cli.Phones = append(cli.Phones, p) - - a := client.Address{} - a.Address1 = "Any Street" - a.Address2 = "" - a.City = "Any City" - a.Country = "USA" - a.PostalCode = "19456" - a.State = "MA" - cli.Addresses = append(cli.Addresses, a) - return cli -} - // TestCustomers__MetaDataValidate validates customer meta data func TestCustomers__MetaDataValidate(t *testing.T) { c := mockCustomerRequest() diff --git a/cmd/server/documents.go b/cmd/server/documents.go index 8173525ce..9f64bf678 100644 --- a/cmd/server/documents.go +++ b/cmd/server/documents.go @@ -32,9 +32,9 @@ var ( ) func addDocumentRoutes(logger log.Logger, r *mux.Router, repo documentRepository, bucketFactory bucketFunc) { - r.Methods("GET").Path("/customers/{customerId}/documents").HandlerFunc(getCustomerDocuments(logger, repo)) - r.Methods("POST").Path("/customers/{customerId}/documents").HandlerFunc(uploadCustomerDocument(logger, repo, bucketFactory)) - r.Methods("GET").Path("/customers/{customerId}/documents/{documentId}").HandlerFunc(retrieveRawDocument(logger, repo, bucketFactory)) + r.Methods("GET").Path("/customers/{customerID}/documents").HandlerFunc(getCustomerDocuments(logger, repo)) + r.Methods("POST").Path("/customers/{customerID}/documents").HandlerFunc(uploadCustomerDocument(logger, repo, bucketFactory)) + r.Methods("GET").Path("/customers/{customerID}/documents/{documentId}").HandlerFunc(retrieveRawDocument(logger, repo, bucketFactory)) } func getDocumentID(w http.ResponseWriter, r *http.Request) string { @@ -118,7 +118,7 @@ func uploadCustomerDocument(logger log.Logger, repo documentRepository, bucketFa } defer bucket.Close() - customerID, requestID := getCustomerID(w, r), moovhttp.GetRequestId(r) + customerID, requestID := getCustomerID(w, r), moovhttp.GetRequestID(r) if customerID == "" { return } @@ -166,7 +166,7 @@ func retrieveRawDocument(logger log.Logger, repo documentRepository, bucketFacto if customerID == "" || documentId == "" { return } - requestID := moovhttp.GetRequestId(r) + requestID := moovhttp.GetRequestID(r) bucket, err := bucketFactory() if err != nil { diff --git a/cmd/server/files.go b/cmd/server/files.go index 824a10d2b..5c92d55db 100644 --- a/cmd/server/files.go +++ b/cmd/server/files.go @@ -59,7 +59,7 @@ func proxyLocalFile(logger log.Logger, signer *fileblob.URLSignerHMAC, bucketFac } defer rdr.Close() - logger.Log("files", fmt.Sprintf("proxying document=%s contentType=%s", key, rdr.ContentType()), "requestId", moovhttp.GetRequestId(r)) + logger.Log("files", fmt.Sprintf("proxying document=%s contentType=%s", key, rdr.ContentType()), "requestID", moovhttp.GetRequestID(r)) w.Header().Set("Content-Disposition", "inline") w.Header().Set("Content-Length", fmt.Sprintf("%d", rdr.Size())) diff --git a/cmd/server/files_test.go b/cmd/server/files_test.go index 1356e28e1..2008ed227 100644 --- a/cmd/server/files_test.go +++ b/cmd/server/files_test.go @@ -29,8 +29,8 @@ func TestFiles__proxyLocalFile(t *testing.T) { t.Fatal(err) } - customerId, documentId := base.ID(), base.ID() - documentKey := makeDocumentKey(customerId, documentId) + customerID, documentID := base.ID(), base.ID() + documentKey := makeDocumentKey(customerID, documentID) ctx, cancelFn := context.WithTimeout(context.TODO(), 10*time.Second) defer cancelFn() diff --git a/cmd/server/http.go b/cmd/server/http.go index b9b86c416..73e8a06ae 100644 --- a/cmd/server/http.go +++ b/cmd/server/http.go @@ -12,7 +12,7 @@ import ( "strings" moovhttp "github.com/moov-io/base/http" - "github.com/moov-io/base/idempotent/lru" + // "github.com/moov-io/base/idempotent/lru" // TODO(adam): use with LRU below "github.com/go-kit/kit/log" "github.com/go-kit/kit/metrics/prometheus" @@ -25,7 +25,7 @@ var ( Help: "Histogram representing the http response durations", }, []string{"route"}) - inmemIdempotentRecorder = lru.New() + // inmemIdempotentRecorder = lru.New() // TODO(adam): integrate this with wrapResponseWriter (call moovhttp.EnsureHeaders) ) func wrapResponseWriter(logger log.Logger, w http.ResponseWriter, r *http.Request) http.ResponseWriter { diff --git a/cmd/server/ofac.go b/cmd/server/ofac.go index 66f03db77..341ed88ae 100644 --- a/cmd/server/ofac.go +++ b/cmd/server/ofac.go @@ -20,7 +20,7 @@ import ( type OFACClient interface { Ping() error - Search(ctx context.Context, name string, requestId string) (*ofac.Sdn, error) + Search(ctx context.Context, name string, requestID string) (*ofac.Sdn, error) } type moovOFACClient struct { @@ -47,11 +47,11 @@ func (c *moovOFACClient) Ping() error { } // Search returns the top OFAC match given the provided options across SDN names and AltNames -func (c *moovOFACClient) Search(ctx context.Context, name string, requestId string) (*ofac.Sdn, error) { +func (c *moovOFACClient) Search(ctx context.Context, name string, requestID string) (*ofac.Sdn, error) { search, resp, err := c.underlying.OFACApi.Search(ctx, &ofac.SearchOpts{ Q: optional.NewString(name), Limit: optional.NewInt32(1), - XRequestId: optional.NewString(requestId), + XRequestId: optional.NewString(requestID), }) if err != nil { return nil, fmt.Errorf("ofac.Search: %v", err) @@ -66,14 +66,14 @@ func (c *moovOFACClient) Search(ctx context.Context, name string, requestId stri // AltName matched higher than SDN names, so return the SDN of the matched AltName sdn, resp, err := c.underlying.OFACApi.GetSDN(ctx, alt.EntityID, &ofac.GetSDNOpts{ - XRequestId: optional.NewString(requestId), + XRequestId: optional.NewString(requestID), }) resp.Body.Close() if err != nil { return nil, fmt.Errorf("ofac.Search: found alt name: %v", err) } sdn.Match = alt.Match // copy match from original search (GetSDN doesn't do string matching) - c.logger.Log("ofac", fmt.Sprintf("AltName=%s,SDN=%s had higher match than SDN=%s", alt.AlternateID, alt.EntityID, search.SDNs[0].EntityID), "requestId", requestId) + c.logger.Log("ofac", fmt.Sprintf("AltName=%s,SDN=%s had higher match than SDN=%s", alt.AlternateID, alt.EntityID, search.SDNs[0].EntityID), "requestID", requestID) return &sdn, nil } else { if len(search.SDNs) > 0 { diff --git a/go.mod b/go.mod index 73f2af2b0..ddca99d9f 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/hashicorp/vault/api v1.0.1 github.com/lopezator/migrator v0.1.0 github.com/mattn/go-sqlite3 v1.10.0 - github.com/moov-io/base v0.9.1-0.20190509232802-5e13ea2b1490 + github.com/moov-io/base v0.10.0 github.com/moov-io/ofac v0.7.1-0.20190611152258-a1fb72e71c46 github.com/opencontainers/go-digest v1.0.0-rc1 // indirect github.com/opencontainers/image-spec v1.0.1 // indirect diff --git a/go.sum b/go.sum index 4a35b99f3..16bba8755 100644 --- a/go.sum +++ b/go.sum @@ -222,8 +222,8 @@ github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/moov-io/base v0.9.1-0.20190430163914-76a8e2cca72d/go.mod h1:pPu/TAc9PkaaegbREVEeDHsGqyAlvji9vqTuARuAnd0= -github.com/moov-io/base v0.9.1-0.20190509232802-5e13ea2b1490 h1:ukVnfYLs1XIyk8QKevYT43LQaVqKU9GPLOVvcSXnH1o= -github.com/moov-io/base v0.9.1-0.20190509232802-5e13ea2b1490/go.mod h1:pPu/TAc9PkaaegbREVEeDHsGqyAlvji9vqTuARuAnd0= +github.com/moov-io/base v0.10.0 h1:9A/N0E+oB5nqxTMWszN06Az1PRAkW9EgQ4UQ/94S1IU= +github.com/moov-io/base v0.10.0/go.mod h1:pPu/TAc9PkaaegbREVEeDHsGqyAlvji9vqTuARuAnd0= github.com/moov-io/ofac v0.7.1-0.20190611152258-a1fb72e71c46 h1:UyImg75iJuNjXiLHDzcIbsMhni2Y0z7jz7jma7FzP3s= github.com/moov-io/ofac v0.7.1-0.20190611152258-a1fb72e71c46/go.mod h1:y2reNnW6KxYT1UylJ3bcwQ097ulJh7iow8VoeXzpmYw= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= diff --git a/internal/database/sqlite_test.go b/internal/database/sqlite_test.go index 3825fc5c7..2e83bc76c 100644 --- a/internal/database/sqlite_test.go +++ b/internal/database/sqlite_test.go @@ -25,7 +25,11 @@ func TestSQLite__basic(t *testing.T) { conn, err := s.Connect() - defer conn.Close() + defer func(t *testing.T) { + if err := conn.Close(); err != nil { + t.Errorf("close: %v", err) + } + }(t) if err := conn.Ping(); err == nil { t.Fatal("expected error")