diff --git a/.github/actions/cleanup-stale/action.yaml b/.github/actions/cleanup-stale/action.yaml index 2bb016d1..c34cd84e 100644 --- a/.github/actions/cleanup-stale/action.yaml +++ b/.github/actions/cleanup-stale/action.yaml @@ -44,7 +44,7 @@ runs: password: ${{ inputs.token }} - name: Delete untagged images with no dependency - uses: Chizkiyahu/delete-untagged-ghcr-action@v3 + uses: Chizkiyahu/delete-untagged-ghcr-action@v4 with: repository: ${{ github.repository }} repository_owner: ${{ github.repository_owner }} diff --git a/.golangci.yml b/.golangci.yml index 52f8e208..99a413e4 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,6 +1,4 @@ linters-settings: - govet: - check-shadowing: true exhaustive: default-signifies-exhaustive: true gocyclo: @@ -8,6 +6,10 @@ linters-settings: gomoddirectives: replace-allow-list: - github.com/pion/dtls/v2 + govet: + enable: + - nilness + - shadow gomodguard: blocked: modules: @@ -15,31 +17,30 @@ linters-settings: recommendations: - errors stylecheck: - go: "1.18" checks: ["all", "-ST1000" , "-ST1003"] + linters: enable: + - asasalint # Check for pass []any as any in variadic func(...any) - asciicheck # Simple linter to check that your code does not contain non-ASCII identifiers - bidichk # Checks for dangerous unicode character sequences - # - bodyclose # checks whether HTTP response body is closed successfully - # - contextcheck # check the function whether use a non-inherited context - - decorder # check declaration order and count of types, constants, variables and functions - # - depguard # Go linter that checks if package imports are in a list of acceptable packages + - bodyclose # Checks whether HTTP response body is closed successfully + # - copyloopvar # Detects places where loop variables are copied + - decorder # Check declaration order and count of types, constants, variables and functions - dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f()) - dupl # Tool for code clone detection - - durationcheck # check for two durations multiplied together + - dupword # A linter that checks for duplicate words in the source code (usually miswritten) + - durationcheck # Check for two durations multiplied together - errcheck # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases - errchkjson # Checks types passed to the json encoding functions. Reports unsupported types and optionally reports occasions, where the check for the returned error can be omitted. - errname # Checks that sentinel errors are prefixed with the `Err` and error types are suffixed with the `Error`. - errorlint # errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13. - - exhaustive # check exhaustiveness of enum switch statements + - execinquery # Execinquery is a linter about query string checker in Query function which reads your Go src files and warning it finds. - exportloopref # checks for pointers to enclosing loop variables - # - forbidigo # Forbids identifiers - forcetypeassert # finds forced type assertions - gci # Gci control golang package import order and make it always deterministic. - # - gochecknoglobals # Checks that no globals are present in Go code - # - gochecknoinits # Checks that no init functions are present in Go code + - gocheckcompilerdirectives # Checks that go compiler directive comments (//go:) are valid. - gocognit # Computes and checks the cognitive complexity of functions - goconst # Finds repeated strings that could be replaced by a constant - gocritic # The most opinionated Go source code linter @@ -54,51 +55,75 @@ linters: - gomodguard # Allow and block list linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations. - goprintffuncname # Checks that printf-like functions are named with `f` at the end - gosec # Inspects source code for security problems + - gosmopolitan # Report certain i18n/l10n anti-patterns in your Go codebase - gosimple # Linter for Go source code that specializes in simplifying a code - govet # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string - - grouper # An analyzer to analyze expression groups. + - grouper # An analyzer to analyze expression groups - importas # Enforces consistent import aliases - ineffassign # Detects when assignments to existing variables are not used + # - intrange # Intrange is a linter to find places where for loops could make use of an integer range + - loggercheck # Checks key value pairs for common logger libraries (kitlog,klog,logr,zap). + - makezero # Finds slice declarations with non-zero initial length + - mirror # Reports wrong mirror patterns of bytes/strings usage - misspell # Finds commonly misspelled English words in comments - nakedret # Finds naked returns in functions greater than a specified function length + - nestif # Reports deeply nested if statements - nilerr # Finds the code that returns nil even if it checks that the error is not nil. - nilnil # Checks that there is no simultaneous return of `nil` error and an invalid value. - # - noctx # noctx finds sending http request without context.Context + - noctx # noctx finds sending http request without context.Context - nolintlint # Reports ill-formed or insufficient nolint directives - # - paralleltest # paralleltest detects missing usage of t.Parallel() method in your Go test + - nosprintfhostport # Checks for misuse of Sprintf to construct a host with port in a URL + - perfsprint # Checks that fmt.Sprintf can be replaced with a faster alternative. + - prealloc # Finds slice declarations that could potentially be preallocated - predeclared # find code that shadows one of Go's predeclared identifiers - # - revive # golint replacement, finds style mistakes + - protogetter # Reports direct reads from proto message fields when getters should be used. + - revive # golint replacement, finds style mistakes + - reassign # Checks that package variables are not reassigned + - sloglint # Ensure consistent code style when using log/slog + - spancheck # Checks for mistakes with OpenTelemetry/Census spans - staticcheck # Staticcheck is a go vet on steroids, applying a ton of static analysis checks - stylecheck # Stylecheck is a replacement for golint + - tagliatelle # Checks the struct tags. - tenv # tenv is analyzer that detects using os.Setenv instead of t.Setenv since Go1.17 - # - tparallel # tparallel detects inappropriate usage of t.Parallel() method in your Go test codes + - testableexamples # linter checks if examples are testable (have an expected output) + - testifylint # Checks usage of github.com/stretchr/testify. + - tparallel # tparallel detects inappropriate usage of t.Parallel() method in your Go test codes - typecheck # Like the front-end of a Go compiler, parses and type-checks Go code - unconvert # Remove unnecessary type conversions - unparam # Reports unused function parameters - unused # Checks Go code for unused constants, variables, functions and types - # - wastedassign # wastedassign finds wasted assignment statements + - usestdlibvars # A linter that detect the possibility to use variables/constants from the Go standard library. + - wastedassign # wastedassign finds wasted assignment statements - whitespace # Tool for detection of leading and trailing whitespace - - makezero # Finds slice declarations with non-zero initial length - - nestif # Reports deeply nested if statements - - prealloc # Finds slice declarations that could potentially be preallocated - - tagliatelle # Checks the struct tags. - - testpackage # linter that makes you use a separate _test package disable: - - structcheck # Finds unused struct fields - containedctx # containedctx is a linter that detects struct contained context.Context field + - contextcheck # check the function whether use a non-inherited context - cyclop # checks function and package cyclomatic complexity + - depguard # Go linter that checks if package imports are in a list of acceptable packages + - exhaustive # Check exhaustiveness of enum switch statements - exhaustivestruct # Checks if all struct's fields are initialized + - exhaustruct # Checks if all structure fields are initialized. + - forbidigo # Forbids identifiers - funlen # Tool for detection of long functions + - gochecknoglobals # Checks that no globals are present in Go code + - gochecknoinits # Checks that no init functions are present in Go code - godot # Check if comments end in a period - gomnd # An analyzer to detect magic numbers. + - ifshort # Checks that your code uses short syntax for if-statements whenever possible + - inamedparam # Reports interfaces with unnamed method parameters. + - interfacebloat # A linter that checks the number of methods inside an interface - ireturn # Accept Interfaces, Return Concrete Types - lll # Reports long lines - maintidx # maintidx measures the maintainability index of each function. - maligned # Tool to detect Go structs that would take less memory if their fields were sorted - nlreturn # nlreturn checks for a new line before return and branch statements to increase code clarity + - nonamedreturns # Reports all named returns + - paralleltest # paralleltest detects missing usage of t.Parallel() method in your Go test - promlinter # Check Prometheus metrics naming via promlint - rowserrcheck # checks whether Err of rows is checked successfully - sqlclosecheck # Checks that sql.Rows and sql.Stmt are closed. + - tagalign # Check that struct tags are well aligned. + - testpackage # linter that makes you use a separate _test package - thelper # thelper detects golang test helpers without t.Helper() call and checks the consistency of test helpers - varnamelen # checks that the length of a variable's name matches its scope - wrapcheck # Checks that errors returned from external packages are wrapped @@ -110,11 +135,16 @@ linters: issues: exclude-use-default: false + exclude-dirs: + - dependency exclude-rules: # Allow complex tests, better to be self contained - path: _test\.go linters: - goconst + - text: "var-naming:|exported:|package-comments:" + linters: + - revive run: - skip-dirs-use-default: false + go: "1.20" diff --git a/dependency/googleapis b/dependency/googleapis index 5ad98f72..d6e96e2b 160000 --- a/dependency/googleapis +++ b/dependency/googleapis @@ -1 +1 @@ -Subproject commit 5ad98f728d43bbf78a878cb3e9ff9e355138b956 +Subproject commit d6e96e2b2ec3f23fc9e3f84a194a56b5f5442274 diff --git a/go.mod b/go.mod index 7926cfa1..36af3fb1 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,6 @@ module github.com/plgd-dev/client-application go 1.20 require ( - cloud.google.com/go v0.112.1 github.com/apex/log v1.9.0 github.com/favadi/protoc-go-inject-tag v1.4.0 github.com/fullstorydev/grpchan v1.1.1 @@ -17,25 +16,26 @@ require ( github.com/hashicorp/go-multierror v1.1.1 github.com/jellydator/ttlcache/v3 v3.2.0 github.com/jessevdk/go-flags v1.5.0 - github.com/lestrrat-go/jwx v1.2.28 - github.com/pion/dtls/v2 v2.2.8-0.20240201071732-2597464081c8 - github.com/plgd-dev/device/v2 v2.3.2-0.20240305073234-ee311673e17c - github.com/plgd-dev/go-coap/v3 v3.3.4-0.20240303135359-ce5dcc5ef1ba - github.com/plgd-dev/hub/v2 v2.16.5-0.20240305104257-c66a897a69fa + github.com/lestrrat-go/jwx v1.2.29 + github.com/pion/dtls/v2 v2.2.8-0.20240327211025-8244c4570c01 + github.com/plgd-dev/device/v2 v2.4.5-0.20240403073803-48efa094e7b0 + github.com/plgd-dev/go-coap/v3 v3.3.4-0.20240403064319-6ed2ef2c4664 + github.com/plgd-dev/hub/v2 v2.17.4-0.20240403125943-fbad2f31e1ed github.com/plgd-dev/kit/v2 v2.0.0-20211006190727-057b33161b90 github.com/stretchr/testify v1.9.0 go.opentelemetry.io/otel/trace v1.24.0 go.uber.org/atomic v1.11.0 go.uber.org/zap v1.27.0 - google.golang.org/api v0.168.0 - google.golang.org/grpc v1.62.1 + google.golang.org/api v0.172.0 + google.golang.org/grpc v1.63.0 google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.3.0 google.golang.org/protobuf v1.33.0 gopkg.in/yaml.v3 v3.0.1 ) require ( - cloud.google.com/go/compute v1.25.0 // indirect + cloud.google.com/go v0.112.1 // indirect + cloud.google.com/go/compute v1.25.1 // indirect cloud.google.com/go/compute/metadata v0.2.3 // indirect cloud.google.com/go/iam v1.1.6 // indirect cloud.google.com/go/kms v1.15.7 // indirect @@ -96,7 +96,7 @@ require ( github.com/awslabs/amazon-ecr-credential-helper/ecr-login v0.0.0-20220517224237-e6f29200ae04 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/blakesmith/ar v0.0.0-20190502131153-809d4375e1fb // indirect - github.com/bufbuild/protocompile v0.8.0 // indirect + github.com/bufbuild/protocompile v0.9.0 // indirect github.com/caarlos0/ctrlc v1.2.0 // indirect github.com/caarlos0/env/v9 v9.0.0 // indirect github.com/caarlos0/go-reddit/v3 v3.0.1 // indirect @@ -104,14 +104,14 @@ require ( github.com/caarlos0/go-version v0.1.1 // indirect github.com/caarlos0/log v0.4.2 // indirect github.com/cavaliergopher/cpio v1.0.1 // indirect - github.com/cenkalti/backoff/v4 v4.2.1 // indirect + github.com/cenkalti/backoff/v4 v4.3.0 // indirect github.com/charmbracelet/lipgloss v0.7.1 // indirect github.com/chrismellard/docker-credential-acr-env v0.0.0-20220327082430-c57b701bfc08 // indirect github.com/cloudflare/circl v1.3.3 // indirect github.com/containerd/stargz-snapshotter/estargz v0.14.3 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect github.com/dghubble/go-twitter v0.0.0-20211115160449-93a8679adecb // indirect github.com/dghubble/oauth1 v0.7.2 // indirect github.com/dghubble/sling v1.4.0 // indirect @@ -133,7 +133,7 @@ require ( github.com/felixge/httpsnoop v1.0.4 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/fxamacker/cbor/v2 v2.6.0 // indirect - github.com/go-co-op/gocron/v2 v2.2.4 // indirect + github.com/go-co-op/gocron/v2 v2.2.9 // indirect github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect github.com/go-git/go-billy/v5 v5.4.1 // indirect github.com/go-git/go-git/v5 v5.7.0 // indirect @@ -167,13 +167,13 @@ require ( github.com/google/safetext v0.0.0-20220905092116-b49f7bc46da2 // indirect github.com/google/wire v0.5.0 // indirect github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect - github.com/googleapis/gax-go/v2 v2.12.2 // indirect + github.com/googleapis/gax-go/v2 v2.12.3 // indirect github.com/goreleaser/chglog v0.5.0 // indirect github.com/goreleaser/fileglob v1.3.0 // indirect github.com/goreleaser/nfpm/v2 v2.32.0 // indirect github.com/gorilla/websocket v1.5.1 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect - github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.0.1 // indirect + github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.1.0 // indirect github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect @@ -200,9 +200,9 @@ require ( github.com/lestrrat-go/backoff/v2 v2.0.8 // indirect github.com/lestrrat-go/blackmagic v1.0.2 // indirect github.com/lestrrat-go/httpcc v1.0.1 // indirect - github.com/lestrrat-go/httprc v1.0.4 // indirect + github.com/lestrrat-go/httprc v1.0.5 // indirect github.com/lestrrat-go/iter v1.0.2 // indirect - github.com/lestrrat-go/jwx/v2 v2.0.20 // indirect + github.com/lestrrat-go/jwx/v2 v2.0.21 // indirect github.com/lestrrat-go/option v1.0.1 // indirect github.com/letsencrypt/boulder v0.0.0-20221109233200-85aa52084eaf // indirect github.com/lucasb-eyer/go-colorful v1.2.0 // indirect @@ -224,17 +224,17 @@ require ( github.com/muesli/reflow v0.3.0 // indirect github.com/muesli/roff v0.1.0 // indirect github.com/muesli/termenv v0.15.2 // indirect - github.com/nats-io/nats.go v1.33.1 // indirect + github.com/nats-io/nats.go v1.34.1 // indirect github.com/nats-io/nkeys v0.4.7 // indirect github.com/nats-io/nuid v1.0.1 // indirect github.com/oklog/ulid v1.3.1 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.0-rc3 // indirect - github.com/panjf2000/ants/v2 v2.9.0 // indirect + github.com/panjf2000/ants/v2 v2.9.1 // indirect github.com/pelletier/go-toml v1.9.5 // indirect github.com/pelletier/go-toml/v2 v2.0.8 // indirect github.com/pion/logging v0.2.2 // indirect - github.com/pion/transport/v3 v3.0.1 // indirect + github.com/pion/transport/v3 v3.0.2 // indirect github.com/pjbgf/sha1cd v0.3.0 // indirect github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect github.com/pkg/errors v0.9.1 // indirect @@ -295,21 +295,21 @@ require ( go.uber.org/multierr v1.11.0 // indirect gocloud.dev v0.33.0 // indirect golang.org/x/crypto v0.21.0 // indirect - golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect - golang.org/x/mod v0.15.0 // indirect - golang.org/x/net v0.22.0 // indirect + golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 // indirect + golang.org/x/mod v0.16.0 // indirect + golang.org/x/net v0.23.0 // indirect golang.org/x/oauth2 v0.18.0 // indirect golang.org/x/sync v0.6.0 // indirect golang.org/x/sys v0.18.0 // indirect golang.org/x/term v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.5.0 // indirect - golang.org/x/tools v0.18.0 // indirect + golang.org/x/tools v0.19.0 // indirect golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect google.golang.org/appengine v1.6.8 // indirect - google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240304212257-790db918fca8 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240304212257-790db918fca8 // indirect + google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240401170217-c3f982113cda // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda // indirect gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect diff --git a/go.sum b/go.sum index b3df1325..1bfe71f0 100644 --- a/go.sum +++ b/go.sum @@ -25,8 +25,8 @@ cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvf cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= -cloud.google.com/go/compute v1.25.0 h1:H1/4SqSUhjPFE7L5ddzHOfY2bCAvjwNRZPNl6Ni5oYU= -cloud.google.com/go/compute v1.25.0/go.mod h1:GR7F0ZPZH8EhChlMo9FkLd7eUTwEymjqQagxzilIxIE= +cloud.google.com/go/compute v1.25.1 h1:ZRpHJedLtTpKgr3RV1Fx23NuaAEN1Zfx9hw1u4aJdjU= +cloud.google.com/go/compute v1.25.1/go.mod h1:oopOIR53ly6viBYxaDhBfJwzUAxf1zE//uf3IB011ls= cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= @@ -212,8 +212,8 @@ github.com/blakesmith/ar v0.0.0-20190502131153-809d4375e1fb h1:m935MPodAbYS46DG4 github.com/blakesmith/ar v0.0.0-20190502131153-809d4375e1fb/go.mod h1:PkYb9DJNAwrSvRx5DYA+gUcOIgTGVMNkfSCbZM8cWpI= github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4YnC6+E63dPcxHo2sUxDIu8g3QgEJdRY= github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4= -github.com/bufbuild/protocompile v0.8.0 h1:9Kp1q6OkS9L4nM3FYbr8vlJnEwtbpDPQlQOVXfR+78s= -github.com/bufbuild/protocompile v0.8.0/go.mod h1:+Etjg4guZoAqzVk2czwEQP12yaxLJ8DxuqCJ9qHdH94= +github.com/bufbuild/protocompile v0.9.0 h1:DI8qLG5PEO0Mu1Oj51YFPqtx6I3qYXUAhJVJ/IzAVl0= +github.com/bufbuild/protocompile v0.9.0/go.mod h1:s89m1O8CqSYpyE/YaSGtg1r1YFMF5nLTwh4vlj6O444= github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= github.com/caarlos0/ctrlc v1.2.0 h1:AtbThhmbeYx1WW3WXdWrd94EHKi+0NPRGS4/4pzrjwk= github.com/caarlos0/ctrlc v1.2.0/go.mod h1:n3gDlSjsXZ7rbD9/RprIR040b7oaLfNStikPd4gFago= @@ -235,8 +235,8 @@ github.com/cavaliergopher/cpio v1.0.1 h1:KQFSeKmZhv0cr+kawA3a0xTQCU4QxXF1vhU7P7a github.com/cavaliergopher/cpio v1.0.1/go.mod h1:pBdaqQjnvXxdS/6CvNDwIANIFSP0xRKI16PX4xejRQc= github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= github.com/cenkalti/backoff/v4 v4.1.2/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= -github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= -github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= +github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= +github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/charmbracelet/keygen v0.4.3 h1:ywOZRwkDlpmkawl0BgLTxaYWDSqp6Y4nfVVmgyyO1Mg= @@ -264,8 +264,9 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 h1:rpfIENRNNilwHwZeG5+P150SMrnNEcHYvcCuK6dPZSg= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= github.com/dghubble/go-twitter v0.0.0-20211115160449-93a8679adecb h1:7ENzkH+O3juL+yj2undESLTaAeRllHwCs/b8z6aWSfc= github.com/dghubble/go-twitter v0.0.0-20211115160449-93a8679adecb/go.mod h1:qhZBgV9e4WyB1JNjHpcXVkUe3knWUwYuAPB1hITdm50= github.com/dghubble/oauth1 v0.7.2 h1:pwcinOZy8z6XkNxvPmUDY52M7RDPxt0Xw1zgZ6Cl5JA= @@ -340,8 +341,8 @@ github.com/glendc/go-external-ip v0.1.0 h1:iX3xQ2Q26atAmLTbd++nUce2P5ht5P4uD4V7c github.com/glendc/go-external-ip v0.1.0/go.mod h1:CNx312s2FLAJoWNdJWZ2Fpf5O4oLsMFwuYviHjS4uJE= github.com/gliderlabs/ssh v0.3.5 h1:OcaySEmAQJgyYcArR+gGGTHCyE7nvhEMTlYY+Dp8CpY= github.com/go-acme/lego v2.7.2+incompatible/go.mod h1:yzMNe9CasVUhkquNvti5nAtPmG94USbYxYrZfTkIn0M= -github.com/go-co-op/gocron/v2 v2.2.4 h1:fL6a8/U+BJQ9UbaeqKxua8wY02w4ftKZsxPzLSNOCKk= -github.com/go-co-op/gocron/v2 v2.2.4/go.mod h1:igssOwzZkfcnu3m2kwnCf/mYj4SmhP9ecSgmYjCOHkk= +github.com/go-co-op/gocron/v2 v2.2.9 h1:aoKosYWSSdXFLecjFWX1i8+R6V7XdZb8sB2ZKAY5Yis= +github.com/go-co-op/gocron/v2 v2.2.9/go.mod h1:mZx3gMSlFnb97k3hRqX3+GdlG3+DUwTh6B8fnsTScXg= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= github.com/go-git/go-billy/v5 v5.4.1 h1:Uwp5tDRkPr+l/TnbHOQzp+tmJfLceOlbVucgpTz8ix4= @@ -543,8 +544,8 @@ github.com/googleapis/enterprise-certificate-proxy v0.3.2 h1:Vie5ybvEvT75RniqhfF github.com/googleapis/enterprise-certificate-proxy v0.3.2/go.mod h1:VLSiSSBs/ksPL8kq3OBOQ6WRI2QnaFynd1DCjZ62+V0= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -github.com/googleapis/gax-go/v2 v2.12.2 h1:mhN09QQW1jEWeMF74zGR81R30z4VJzjZsfkUhuHF+DA= -github.com/googleapis/gax-go/v2 v2.12.2/go.mod h1:61M8vcyyXR2kqKFxKrfA22jaA8JGF7Dc8App1U3H6jc= +github.com/googleapis/gax-go/v2 v2.12.3 h1:5/zPPDvw8Q1SuXjrqrZslrqT7dL/uJT2CQii/cLCKqA= +github.com/googleapis/gax-go/v2 v2.12.3/go.mod h1:AKloxT6GtNbaLm8QTNSidHUVsHYcBHwWRvkNFJUQcS4= github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= github.com/gopherjs/gopherjs v1.17.2 h1:fQnZVsXk8uxXIStYb0N4bGk7jeyTalG/wsZjQ25dO0g= github.com/goreleaser/chglog v0.5.0 h1:Sk6BMIpx8+vpAf8KyPit34OgWui8c7nKTMHhYx88jJ4= @@ -567,8 +568,8 @@ github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZH github.com/grpc-ecosystem/go-grpc-middleware v1.2.0/go.mod h1:mJzapYve32yjrKlk9GbyCZHuPgZsrbyIbyKhSzOpg6s= github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 h1:UH//fgunKIs4JdUbpDl1VZCDaL56wXCB/5+wF6uHfaI= github.com/grpc-ecosystem/go-grpc-middleware v1.4.0/go.mod h1:g5qyo/la0ALbONm6Vbp88Yd8NsDy6rZz+RcrMPxvld8= -github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.0.1 h1:HcUWd006luQPljE73d5sk+/VgYPGUReEVz2y1/qylwY= -github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.0.1/go.mod h1:w9Y7gY31krpLmrVU5ZPG9H7l9fZuRu5/3R3S3FMtVQ4= +github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.1.0 h1:pRhl55Yx1eC7BZ1N+BBWwnKaMyD8uC+34TLdndZMAKk= +github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.1.0/go.mod h1:XKMd7iuf/RGPSMJ/U4HP0zS2Z9Fh8Ps9a+6X26m/tmI= github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 h1:/c3QmbOGMGTOumP2iT/rCwB7b0QDGLKzqOmktBjT+Is= github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1/go.mod h1:5SN9VR2LTsRFsrEC6FHgRbTWrTHu6tqPeKxEQv15giM= github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed h1:5upAirOpQc1Q53c0bnx2ufif5kANL7bfZWcc6VJWJd8= @@ -679,16 +680,16 @@ github.com/lestrrat-go/blackmagic v1.0.2 h1:Cg2gVSc9h7sz9NOByczrbUvLopQmXrfFx//N github.com/lestrrat-go/blackmagic v1.0.2/go.mod h1:UrEqBzIR2U6CnzVyUtfM6oZNMt/7O7Vohk2J0OGSAtU= github.com/lestrrat-go/httpcc v1.0.1 h1:ydWCStUeJLkpYyjLDHihupbn2tYmZ7m22BGkcvZZrIE= github.com/lestrrat-go/httpcc v1.0.1/go.mod h1:qiltp3Mt56+55GPVCbTdM9MlqhvzyuL6W/NMDA8vA5E= -github.com/lestrrat-go/httprc v1.0.4 h1:bAZymwoZQb+Oq8MEbyipag7iSq6YIga8Wj6GOiJGdI8= -github.com/lestrrat-go/httprc v1.0.4/go.mod h1:mwwz3JMTPBjHUkkDv/IGJ39aALInZLrhBp0X7KGUZlo= +github.com/lestrrat-go/httprc v1.0.5 h1:bsTfiH8xaKOJPrg1R+E3iE/AWZr/x0Phj9PBTG/OLUk= +github.com/lestrrat-go/httprc v1.0.5/go.mod h1:mwwz3JMTPBjHUkkDv/IGJ39aALInZLrhBp0X7KGUZlo= github.com/lestrrat-go/iter v0.0.0-20200422075355-fc1769541911/go.mod h1:zIdgO1mRKhn8l9vrZJZz9TUMMFbQbLeTsbqPDrJ/OJc= github.com/lestrrat-go/iter v1.0.2 h1:gMXo1q4c2pHmC3dn8LzRhJfP1ceCbgSiT9lUydIzltI= github.com/lestrrat-go/iter v1.0.2/go.mod h1:Momfcq3AnRlRjI5b5O8/G5/BvpzrhoFTZcn06fEOPt4= github.com/lestrrat-go/jwx v1.0.2/go.mod h1:TPF17WiSFegZo+c20fdpw49QD+/7n4/IsGvEmCSWwT0= -github.com/lestrrat-go/jwx v1.2.28 h1:uadI6o0WpOVrBSf498tRXZIwPpEtLnR9CvqPFXeI5sA= -github.com/lestrrat-go/jwx v1.2.28/go.mod h1:nF+91HEMh/MYFVwKPl5HHsBGMPscqbQb+8IDQdIazP8= -github.com/lestrrat-go/jwx/v2 v2.0.20 h1:sAgXuWS/t8ykxS9Bi2Qtn5Qhpakw1wrcjxChudjolCc= -github.com/lestrrat-go/jwx/v2 v2.0.20/go.mod h1:UlCSmKqw+agm5BsOBfEAbTvKsEApaGNqHAEUTv5PJC4= +github.com/lestrrat-go/jwx v1.2.29 h1:QT0utmUJ4/12rmsVQrJ3u55bycPkKqGYuGT4tyRhxSQ= +github.com/lestrrat-go/jwx v1.2.29/go.mod h1:hU8k2l6WF0ncx20uQdOmik/Gjg6E3/wIRtXSNFeZuB8= +github.com/lestrrat-go/jwx/v2 v2.0.21 h1:jAPKupy4uHgrHFEdjVjNkUgoBKtVDgrQPB/h55FHrR0= +github.com/lestrrat-go/jwx/v2 v2.0.21/go.mod h1:09mLW8zto6bWL9GbwnqAli+ArLf+5M33QLQPDggkUWM= github.com/lestrrat-go/option v1.0.0/go.mod h1:5ZHFbivi4xwXxhxY9XHDe2FHo6/Z7WWmtT7T5nBBp3I= github.com/lestrrat-go/option v1.0.1 h1:oAzP2fvZGQKWkvHa1/SAcFolBEca1oN+mQ7eooNBEYU= github.com/lestrrat-go/option v1.0.1/go.mod h1:5ZHFbivi4xwXxhxY9XHDe2FHo6/Z7WWmtT7T5nBBp3I= @@ -759,8 +760,8 @@ github.com/muesli/roff v0.1.0 h1:YD0lalCotmYuF5HhZliKWlIx7IEhiXeSfq7hNjFqGF8= github.com/muesli/roff v0.1.0/go.mod h1:pjAHQM9hdUUwm/krAfrLGgJkXJ+YuhtsfZ42kieB2Ig= github.com/muesli/termenv v0.15.2 h1:GohcuySI0QmI3wN8Ok9PtKGkgkFIk7y6Vpb5PvrY+Wo= github.com/muesli/termenv v0.15.2/go.mod h1:Epx+iuz8sNs7mNKhxzH4fWXGNpZwUaJKRS1noLXviQ8= -github.com/nats-io/nats.go v1.33.1 h1:8TxLZZ/seeEfR97qV0/Bl939tpDnt2Z2fK3HkPypj70= -github.com/nats-io/nats.go v1.33.1/go.mod h1:Ubdu4Nh9exXdSz0RVWRFBbRfrbSxOYd26oF0wkWclB8= +github.com/nats-io/nats.go v1.34.1 h1:syWey5xaNHZgicYBemv0nohUPPmaLteiBEUT6Q5+F/4= +github.com/nats-io/nats.go v1.34.1/go.mod h1:Ubdu4Nh9exXdSz0RVWRFBbRfrbSxOYd26oF0wkWclB8= github.com/nats-io/nkeys v0.4.7 h1:RwNJbbIdYCoClSDNY7QVKZlyb/wfT6ugvFCiKy6vDvI= github.com/nats-io/nkeys v0.4.7/go.mod h1:kqXRgRDPlGy7nGaEDMuYzmiJCIAAWDK0IMBtDmGD0nc= github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw= @@ -778,8 +779,8 @@ github.com/opencontainers/runc v1.1.5 h1:L44KXEpKmfWDcS02aeGm8QNTFXTo2D+8MYGDIJ/ github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/ory/dockertest/v3 v3.10.0 h1:4K3z2VMe8Woe++invjaTB7VRyQXQy5UY+loujO4aNE4= github.com/panjf2000/ants/v2 v2.4.3/go.mod h1:f6F0NZVFsGCp5A7QW/Zj/m92atWwOkY0OIhFxRNFr4A= -github.com/panjf2000/ants/v2 v2.9.0 h1:SztCLkVxBRigbg+vt0S5QvF5vxAbxbKt09/YfAJ0tEo= -github.com/panjf2000/ants/v2 v2.9.0/go.mod h1:7ZxyxsqE4vvW0M7LSD8aI3cKwgFhBHbxnlN8mDqHa1I= +github.com/panjf2000/ants/v2 v2.9.1 h1:Q5vh5xohbsZXGcD6hhszzGqB7jSSc2/CRr3QKIga8Kw= +github.com/panjf2000/ants/v2 v2.9.1/go.mod h1:7ZxyxsqE4vvW0M7LSD8aI3cKwgFhBHbxnlN8mDqHa1I= github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= github.com/pelletier/go-toml v1.9.4/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= @@ -791,8 +792,9 @@ github.com/pion/dtls/v2 v2.2.8-0.20240201071732-2597464081c8 h1:r7K+oQUYubeA0am0 github.com/pion/dtls/v2 v2.2.8-0.20240201071732-2597464081c8/go.mod h1:/gft3czh67pwl4nM1BBUvF7eTy72uGkObJXOYfxRDbA= github.com/pion/logging v0.2.2 h1:M9+AIj/+pxNsDfAT64+MAVgJO0rsyLnoJKCqf//DoeY= github.com/pion/logging v0.2.2/go.mod h1:k0/tDVsRCX2Mb2ZEmTqNa7CWsQPc+YYCB7Q+5pahoms= -github.com/pion/transport/v3 v3.0.1 h1:gDTlPJwROfSfz6QfSi0ZmeCSkFcnWWiiR9ES0ouANiM= github.com/pion/transport/v3 v3.0.1/go.mod h1:UY7kiITrlMv7/IKgd5eTUcaahZx5oUN3l9SzK5f5xE0= +github.com/pion/transport/v3 v3.0.2 h1:r+40RJR25S9w3jbA6/5uEPTzcdn7ncyU44RWCbHkLg4= +github.com/pion/transport/v3 v3.0.2/go.mod h1:nIToODoOlb5If2jF9y2Igfx3PFYWfuXi37m0IlWa/D0= github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= @@ -802,14 +804,14 @@ github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg= -github.com/plgd-dev/device/v2 v2.3.2-0.20240305073234-ee311673e17c h1:d6CMhw6Lx/fJpeZrbnbeHULtbfRfPLDprMWmKP/YxnA= -github.com/plgd-dev/device/v2 v2.3.2-0.20240305073234-ee311673e17c/go.mod h1:4hzgXvOY/u2+EvQDehDCe77UKuhD+9SouLiPKEFexes= +github.com/plgd-dev/device/v2 v2.4.5-0.20240403073803-48efa094e7b0 h1:EEDaxD3RCCD5uAtmJxE+S7DncGh00/8NvIwTmu1AEKE= +github.com/plgd-dev/device/v2 v2.4.5-0.20240403073803-48efa094e7b0/go.mod h1:T0ePJIrEkK8uvHkq43qA8J/eHGsV3w7zriDh5S7xJgE= github.com/plgd-dev/go-coap/v2 v2.0.4-0.20200819112225-8eb712b901bc/go.mod h1:+tCi9Q78H/orWRtpVWyBgrr4vKFo2zYtbbxUllerBp4= github.com/plgd-dev/go-coap/v2 v2.4.1-0.20210517130748-95c37ac8e1fa/go.mod h1:rA7fc7ar+B/qa+Q0hRqv7yj/EMtIlmo1l7vkQGSrHPU= -github.com/plgd-dev/go-coap/v3 v3.3.4-0.20240303135359-ce5dcc5ef1ba h1:bDpB1PPdUzgaTdcPr4jMdbb78ODxvG9CE7lSOQngL9Y= -github.com/plgd-dev/go-coap/v3 v3.3.4-0.20240303135359-ce5dcc5ef1ba/go.mod h1:rUgy/k2SX0esIM7JT01euQALT5YrYkROwxMSwfiIzhw= -github.com/plgd-dev/hub/v2 v2.16.5-0.20240305104257-c66a897a69fa h1:82CiXBTpk7UMaoo/cFEA7GWBKcUMprvzdUSXkRva1YM= -github.com/plgd-dev/hub/v2 v2.16.5-0.20240305104257-c66a897a69fa/go.mod h1:2O5C46UNG4rt0xlbZtbBrinMICVoyyDESqOqYpxIcG0= +github.com/plgd-dev/go-coap/v3 v3.3.4-0.20240403064319-6ed2ef2c4664 h1:iMMYyd666v1oHmR642hYFoRgRyrN/qMoCoY0X/Cj6RE= +github.com/plgd-dev/go-coap/v3 v3.3.4-0.20240403064319-6ed2ef2c4664/go.mod h1:flkLrn0JqGJyW25Uybwg0g0PZUt+pZ1O7aaPeIhEEbs= +github.com/plgd-dev/hub/v2 v2.17.4-0.20240403125943-fbad2f31e1ed h1:wdAE2Bxsf3GdgVnl7dCueioerPU4QkSMzCGS/oT2IrM= +github.com/plgd-dev/hub/v2 v2.17.4-0.20240403125943-fbad2f31e1ed/go.mod h1:yXrJ3bFNgCJORjclAXYxrvibqXWv1NikoEEZohawhyM= github.com/plgd-dev/kit v0.0.0-20200819113605-d5fcf3e94f63/go.mod h1:Yl9zisyXfPdtP9hTWlJqjJYXmgU/jtSDKttz9/CeD90= github.com/plgd-dev/kit/v2 v2.0.0-20211006190727-057b33161b90 h1:TC1HJ/UbyflJFPvaOdGmNZ5TeFGex1/dyr9urNGLy7M= github.com/plgd-dev/kit/v2 v2.0.0-20211006190727-057b33161b90/go.mod h1:Z7oKFLSGQjdi8eInxwFCs0tSApuEM1o0qNck+sJYp4M= @@ -885,6 +887,7 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.3.1-0.20190311161405-34c6fa2dc709/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= @@ -1051,8 +1054,8 @@ golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2Uz golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= -golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= +golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -1065,8 +1068,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUFH7PGP+OQ6mgDYo3yuQ= -golang.org/x/exp v0.0.0-20240222234643-814bf88cf225/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= +golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 h1:aAcj0Da7eBAtrTp03QXWvm88pSyOt+UgdZw2BFZ+lEw= +golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8/go.mod h1:CQ1k9gNrJ50XIzaKCRR2hssIjF07kZFEiieALBM/ARQ= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -1092,8 +1095,8 @@ golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8= -golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic= +golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1139,8 +1142,10 @@ golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= -golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= +golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= +golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= +golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1231,8 +1236,8 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -1243,8 +1248,8 @@ golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= -golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY= +golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1333,8 +1338,8 @@ golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.18.0 h1:k8NLag8AGHnn+PHbl7g43CtqZAwG60vZkLqgyZgIHgQ= -golang.org/x/tools v0.18.0/go.mod h1:GL7B4CwcLLeo59yx/9UWWuNOW1n3VZ4f5axWfML7Lcg= +golang.org/x/tools v0.19.0 h1:tfGCXNR1OsFG+sVdLAitlpjAvD/I6dHDKnYrpEZUHkw= +golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1360,8 +1365,8 @@ google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz513 google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE= google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= -google.golang.org/api v0.168.0 h1:MBRe+Ki4mMN93jhDDbpuRLjRddooArz4FeSObvUMmjY= -google.golang.org/api v0.168.0/go.mod h1:gpNOiMA2tZ4mf5R9Iwf4rK/Dcz0fbdIgWYWVoxmsyLg= +google.golang.org/api v0.172.0 h1:/1OcMZGPmW1rX2LCu2CmGUD1KXK1+pfzxotxyRUCCdk= +google.golang.org/api v0.172.0/go.mod h1:+fJZq6QXWfa9pXhnIzsjx4yI22d4aI9ZpLb58gvXjis= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -1408,12 +1413,12 @@ google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 h1:9+tzLLstTlPTRyJTh+ah5wIMsBW5c4tQwGTN3thOW9Y= -google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9/go.mod h1:mqHbVIp48Muh7Ywss/AD6I5kNVKZMmAa/QEW58Gxp2s= -google.golang.org/genproto/googleapis/api v0.0.0-20240304212257-790db918fca8 h1:8eadJkXbwDEMNwcB5O0s5Y5eCfyuCLdvaiOIaGTrWmQ= -google.golang.org/genproto/googleapis/api v0.0.0-20240304212257-790db918fca8/go.mod h1:O1cOfN1Cy6QEYr7VxtjOyP5AdAuR0aJ/MYZaaof623Y= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240304212257-790db918fca8 h1:IR+hp6ypxjH24bkMfEJ0yHR21+gwPWdV+/IBrPQyn3k= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240304212257-790db918fca8/go.mod h1:UCOku4NytXMJuLQE5VuqA5lX3PcHCBo8pxNyvkf4xBs= +google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de h1:F6qOa9AZTYJXOUEr4jDysRDLrm4PHePlge4v4TGAlxY= +google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:VUhTRKeHn9wwcdrk73nvdC9gF178Tzhmt/qyaFcPLSo= +google.golang.org/genproto/googleapis/api v0.0.0-20240401170217-c3f982113cda h1:b6F6WIV4xHHD0FA4oIyzU6mHWg2WI2X1RBehwa5QN38= +google.golang.org/genproto/googleapis/api v0.0.0-20240401170217-c3f982113cda/go.mod h1:AHcE/gZH76Bk/ROZhQphlRoWo5xKDEtz3eVEO1LfA8c= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda h1:LI5DOvAxUPMv/50agcLLoo+AdWc1irS9Rzz4vPuD1V4= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= @@ -1431,8 +1436,8 @@ google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.62.1 h1:B4n+nfKzOICUXMgyrNd19h/I9oH0L1pizfk1d4zSgTk= -google.golang.org/grpc v1.62.1/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE= +google.golang.org/grpc v1.63.0 h1:WjKe+dnvABXyPJMD7KDNLxtoGk5tgk+YFWN6cBWjZE8= +google.golang.org/grpc v1.63.0/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.3.0 h1:rNBFJjBCOgVr9pWD7rs/knKL4FRTKgpZmsRfV214zcA= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.3.0/go.mod h1:Dk1tviKTvMCz5tvh7t+fh94dhmQVHuCt2OzJB3CTW9Y= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= diff --git a/pb/get_configuration.go b/pb/get_configuration.go index 578f8bfd..ac5c86c8 100644 --- a/pb/get_configuration.go +++ b/pb/get_configuration.go @@ -35,7 +35,7 @@ func (c *UserAgent) Clone() *UserAgent { return nil } return &UserAgent{ - CsrChallengeStateExpiration: c.CsrChallengeStateExpiration, + CsrChallengeStateExpiration: c.GetCsrChallengeStateExpiration(), } } @@ -102,7 +102,7 @@ func (r *GetConfigurationResponse) Clone() *GetConfigurationResponse { CommitHash: r.GetBuildInfo().GetCommitHash(), CommitDate: r.GetBuildInfo().GetCommitDate(), ReleaseUrl: r.GetBuildInfo().GetReleaseUrl(), - RemoteProvisioning: r.RemoteProvisioning.Clone(), + RemoteProvisioning: r.GetRemoteProvisioning().Clone(), BuildInfo: r.GetBuildInfo().Clone(), Ui: r.GetUi().Clone(), } diff --git a/service/config/config.go b/service/config/config.go index 75fbc290..fdcffb96 100644 --- a/service/config/config.go +++ b/service/config/config.go @@ -17,6 +17,7 @@ package config import ( + "errors" "fmt" "github.com/plgd-dev/client-application/service/config/device" @@ -38,7 +39,7 @@ type Config struct { func New(configPath string) (Config, error) { if configPath == "" { - return Config{}, fmt.Errorf("path to config is empty") + return Config{}, errors.New("path to config is empty") } var cfg Config if err := config.LoadAndValidateConfig(&cfg); err != nil { @@ -85,7 +86,7 @@ type APIsConfig struct { func (c *APIsConfig) Validate() error { if !c.HTTP.Enabled && !c.GRPC.Enabled { - return fmt.Errorf("http or grpc must be enabled") + return errors.New("http or grpc must be enabled") } if c.HTTP.Enabled { if err := c.HTTP.Validate(); err != nil { diff --git a/service/device/authenticationPreSharedKey.go b/service/device/authenticationPreSharedKey.go index b8482207..5d66e23e 100644 --- a/service/device/authenticationPreSharedKey.go +++ b/service/device/authenticationPreSharedKey.go @@ -68,7 +68,7 @@ func (s *authenticationPreSharedKey) DialDTLS(ctx context.Context, addr string, idBin, _ := subjectUUID.MarshalBinary() dtlsCfg := &dtls.Config{ PSKIdentityHint: idBin, - PSK: func(b []byte) ([]byte, error) { + PSK: func([]byte) ([]byte, error) { // iotivity-lite supports only 16-byte PSK return toKeyBin(key), nil }, @@ -77,7 +77,7 @@ func (s *authenticationPreSharedKey) DialDTLS(ctx context.Context, addr string, return coap.DialUDPSecure(ctx, addr, dtlsCfg, opts...) } -func (s *authenticationPreSharedKey) DialTLS(ctx context.Context, addr string, tlsCfg *tls.Config, opts ...tcp.Option) (*coap.ClientCloseHandler, error) { +func (s *authenticationPreSharedKey) DialTLS(_ context.Context, _ string, _ *tls.Config, _ ...tcp.Option) (*coap.ClientCloseHandler, error) { return nil, errPreSharedKeyAuthentication } @@ -94,11 +94,11 @@ func (s *authenticationPreSharedKey) GetOwnOptions() ([]core.OwnOption, error) { return []core.OwnOption{core.WithPresharedKey(toKeyBin(key))}, nil } -func (s *authenticationPreSharedKey) GetIdentityCSR(id string) ([]byte, error) { +func (s *authenticationPreSharedKey) GetIdentityCSR(_ string) ([]byte, error) { return nil, errPreSharedKeyAuthentication } -func (s *authenticationPreSharedKey) SetIdentityCertificate(owner string, chainPem []byte) error { +func (s *authenticationPreSharedKey) SetIdentityCertificate(_ string, _ []byte) error { return errPreSharedKeyAuthentication } diff --git a/service/device/authenticationX509.go b/service/device/authenticationX509.go index f1f0983c..facf2cfa 100644 --- a/service/device/authenticationX509.go +++ b/service/device/authenticationX509.go @@ -24,6 +24,7 @@ import ( "crypto/tls" "crypto/x509" "encoding/pem" + "errors" "fmt" "time" @@ -53,7 +54,7 @@ func newAuthenticationX509(config configDevice.Config) *authenticationX509 { func (s *authenticationX509) getTLSCertificate() (*tls.Certificate, error) { crt := s.certificate.Load() if crt == nil || crt.Leaf == nil { - return nil, fmt.Errorf("certificate hasn't been set") + return nil, errors.New("certificate hasn't been set") } if crt.Leaf.NotAfter.Before(time.Now()) { return nil, fmt.Errorf("certificate is not valid after %v", crt.Leaf.NotAfter) @@ -70,7 +71,7 @@ func getRootCAFromChain(chain [][]byte) (*x509.Certificate, error) { return nil, err } if !rootCA.IsCA || rootCA.Issuer.CommonName != rootCA.Subject.CommonName { - return nil, fmt.Errorf("invalid root certificate") + return nil, errors.New("invalid root certificate") } return rootCA, nil } @@ -187,7 +188,7 @@ func (s *authenticationX509) updateCertificate(crt tls.Certificate) error { func (s *authenticationX509) SetIdentityCertificate(owner string, chainPem []byte) error { privateKey := s.privateKey.Load() if privateKey == nil { - return fmt.Errorf("private key is not set") + return errors.New("private key is not set") } keyPem, err := encodePrivateKeyToPem(privateKey) if err != nil { diff --git a/service/device/service.go b/service/device/service.go index e4986036..3bfe8461 100644 --- a/service/device/service.go +++ b/service/device/service.go @@ -20,6 +20,7 @@ import ( "context" "crypto/tls" "crypto/x509" + "errors" "fmt" "net" "sync" @@ -86,7 +87,7 @@ func New(ctx context.Context, getConfig func() configDevice.Config, logger log.L case configDevice.AuthenticationX509: authenticationClient = newAuthenticationX509(config) case configDevice.AuthenticationUninitialized: - return nil, fmt.Errorf("device is not initialized") + return nil, errors.New("device is not initialized") } opts := []udpServer.Option{ @@ -182,7 +183,7 @@ func (c *UDPClientConn) Context() context.Context { return cc.Context() } -func (s *Service) DialUDP(ctx context.Context, addr string, opts ...udp.Option) (*coap.ClientCloseHandler, error) { +func (s *Service) DialUDP(_ context.Context, addr string, _ ...udp.Option) (*coap.ClientCloseHandler, error) { udpAddr, err := net.ResolveUDPAddr("udp", addr) if err != nil { return nil, err @@ -199,12 +200,12 @@ func (s *Service) DialUDP(ctx context.Context, addr string, opts ...udp.Option) closeHandler := cc.Context().Value(&closeHandlerKey) if closeHandler == nil { _ = cc.Close() - return nil, fmt.Errorf("failed to create client connection: close handler is nil") + return nil, errors.New("failed to create client connection: close handler is nil") } h, ok := closeHandler.(*coap.OnCloseHandler) if !ok { _ = cc.Close() - return nil, fmt.Errorf("failed to create client connection: close handler is not *coap.OnCloseHandler") + return nil, errors.New("failed to create client connection: close handler is not *coap.OnCloseHandler") } return coap.NewClientCloseHandler(&UDPClientConn{Conn: cc}, h), nil } diff --git a/service/grpc/clearCache.go b/service/grpc/clearCache.go index 8da4fa53..199bb0ea 100644 --- a/service/grpc/clearCache.go +++ b/service/grpc/clearCache.go @@ -53,7 +53,7 @@ func closeDevices(devices map[uuid.UUID]*device) error { } } -func (s *ClientApplicationServer) ClearCache(ctx context.Context, _ *pb.ClearCacheRequest) (*pb.ClearCacheResponse, error) { +func (s *ClientApplicationServer) ClearCache(_ context.Context, _ *pb.ClearCacheRequest) (*pb.ClearCacheResponse, error) { devices := s.devices.LoadAndDeleteAll() go func(devices map[uuid.UUID]*device) { err := closeDevices(devices) diff --git a/service/grpc/clearCache_test.go b/service/grpc/clearCache_test.go index 4a2e3764..924b0cfc 100644 --- a/service/grpc/clearCache_test.go +++ b/service/grpc/clearCache_test.go @@ -49,21 +49,21 @@ func TestClientApplicationServerClearCache(t *testing.T) { // get device d1, err := s.GetDevice(ctx, &pb.GetDeviceRequest{ - DeviceId: dev.Id, + DeviceId: dev.GetId(), }) require.NoError(t, err) require.Equal(t, dev, d1) // own device _, err = s.OwnDevice(ctx, &pb.OwnDeviceRequest{ - DeviceId: dev.Id, + DeviceId: dev.GetId(), }) require.NoError(t, err) // update resource - dtls connection will be created newName := test.DevsimName + "_new" _, err = s.UpdateResource(ctx, &pb.UpdateResourceRequest{ - ResourceId: commands.NewResourceID(dev.Id, configuration.ResourceURI), + ResourceId: commands.NewResourceID(dev.GetId(), configuration.ResourceURI), Content: &grpcgwPb.Content{ ContentType: serviceHttp.ApplicationJsonContentType, Data: []byte(`{"n":"` + newName + `"}`), @@ -73,7 +73,7 @@ func TestClientApplicationServerClearCache(t *testing.T) { // get device - udp connection will be created d1, err = s.GetDevice(ctx, &pb.GetDeviceRequest{ - DeviceId: dev.Id, + DeviceId: dev.GetId(), }) require.NoError(t, err) var v plgdDevice.Device @@ -87,7 +87,7 @@ func TestClientApplicationServerClearCache(t *testing.T) { // get device - cache is empty so expected error _, err = s.GetDevice(ctx, &pb.GetDeviceRequest{ - DeviceId: dev.Id, + DeviceId: dev.GetId(), }) require.Error(t, err) @@ -99,7 +99,7 @@ func TestClientApplicationServerClearCache(t *testing.T) { // revert resource update _, err = s.UpdateResource(ctx, &pb.UpdateResourceRequest{ - ResourceId: commands.NewResourceID(dev.Id, configuration.ResourceURI), + ResourceId: commands.NewResourceID(dev.GetId(), configuration.ResourceURI), Content: &grpcgwPb.Content{ ContentType: serviceHttp.ApplicationJsonContentType, Data: []byte(`{"n":"` + test.DevsimName + `"}`), @@ -109,7 +109,7 @@ func TestClientApplicationServerClearCache(t *testing.T) { // disown device _, err = s.DisownDevice(ctx, &pb.DisownDeviceRequest{ - DeviceId: dev.Id, + DeviceId: dev.GetId(), }) require.NoError(t, err) } diff --git a/service/grpc/createDeleteResource_test.go b/service/grpc/createDeleteResource_test.go index 6a7cd9e2..e9ab7060 100644 --- a/service/grpc/createDeleteResource_test.go +++ b/service/grpc/createDeleteResource_test.go @@ -44,18 +44,18 @@ func TestClientApplicationServerCreateDeleteResource(t *testing.T) { require.NoError(t, err) d1, err := s.GetDevice(ctx, &pb.GetDeviceRequest{ - DeviceId: dev.Id, + DeviceId: dev.GetId(), }) require.NoError(t, err) require.Equal(t, dev, d1) _, err = s.OwnDevice(ctx, &pb.OwnDeviceRequest{ - DeviceId: dev.Id, + DeviceId: dev.GetId(), }) require.NoError(t, err) _, err = s.CreateResource(ctx, &pb.CreateResourceRequest{ - ResourceId: commands.NewResourceID(dev.Id, hubTest.TestResourceSwitchesHref), + ResourceId: commands.NewResourceID(dev.GetId(), hubTest.TestResourceSwitchesHref), Content: &grpcgwPb.Content{ ContentType: message.AppOcfCbor.String(), Data: hubTest.EncodeToCbor(t, hubTest.MakeSwitchResourceDefaultData()), @@ -64,18 +64,18 @@ func TestClientApplicationServerCreateDeleteResource(t *testing.T) { require.NoError(t, err) _, err = s.DeleteResource(ctx, &pb.DeleteResourceRequest{ - ResourceId: commands.NewResourceID(dev.Id, hubTest.TestResourceSwitchesInstanceHref("1")), + ResourceId: commands.NewResourceID(dev.GetId(), hubTest.TestResourceSwitchesInstanceHref("1")), }) require.NoError(t, err) // duplicity delete _, err = s.DeleteResource(ctx, &pb.DeleteResourceRequest{ - ResourceId: commands.NewResourceID(dev.Id, hubTest.TestResourceSwitchesInstanceHref("1")), + ResourceId: commands.NewResourceID(dev.GetId(), hubTest.TestResourceSwitchesInstanceHref("1")), }) require.Error(t, err) _, err = s.DisownDevice(ctx, &pb.DisownDeviceRequest{ - DeviceId: dev.Id, + DeviceId: dev.GetId(), }) require.NoError(t, err) } diff --git a/service/grpc/disownDevice.go b/service/grpc/disownDevice.go index c3b44dde..c721e283 100644 --- a/service/grpc/disownDevice.go +++ b/service/grpc/disownDevice.go @@ -40,7 +40,7 @@ func (s *ClientApplicationServer) DisownDevice(ctx context.Context, req *pb.Diso if err != nil { return nil, err } - if dev.ToProto().OwnershipStatus != grpcgwPb.Device_OWNED { + if dev.ToProto().GetOwnershipStatus() != grpcgwPb.Device_OWNED { return nil, status.Error(codes.PermissionDenied, "device is not owned") } diff --git a/service/grpc/getConfiguration.go b/service/grpc/getConfiguration.go index 3ffbdb11..4f3e0a16 100644 --- a/service/grpc/getConfiguration.go +++ b/service/grpc/getConfiguration.go @@ -23,7 +23,7 @@ import ( "github.com/plgd-dev/client-application/pb" ) -func (s *ClientApplicationServer) GetConfiguration(ctx context.Context, _ *pb.GetConfigurationRequest) (*pb.GetConfigurationResponse, error) { +func (s *ClientApplicationServer) GetConfiguration(_ context.Context, _ *pb.GetConfigurationRequest) (*pb.GetConfigurationResponse, error) { info := s.info.Clone() devService := s.serviceDevice.Load() info.DeviceAuthenticationMode = pb.GetConfigurationResponse_UNINITIALIZED @@ -31,7 +31,7 @@ func (s *ClientApplicationServer) GetConfiguration(ctx context.Context, _ *pb.Ge info.Owner = "" remoteProvisioning := s.GetConfig().RemoteProvisioning info.RemoteProvisioning = remoteProvisioning.Clone() - if info.RemoteProvisioning == nil { + if info.GetRemoteProvisioning() == nil { info.RemoteProvisioning = &pb.RemoteProvisioning{} } info.RemoteProvisioning.CurrentTime = time.Now().UnixNano() @@ -39,7 +39,7 @@ func (s *ClientApplicationServer) GetConfiguration(ctx context.Context, _ *pb.Ge info.DeviceAuthenticationMode = devService.GetDeviceAuthenticationMode() info.IsInitialized = devService.IsInitialized() info.Owner = devService.GetOwner() - if info.DeviceAuthenticationMode == pb.GetConfigurationResponse_X509 { + if info.GetDeviceAuthenticationMode() == pb.GetConfigurationResponse_X509 { info.RemoteProvisioning.Mode = pb.RemoteProvisioning_USER_AGENT } else { info.RemoteProvisioning.Mode = pb.RemoteProvisioning_MODE_NONE diff --git a/service/grpc/getDeviceResourceLinks_test.go b/service/grpc/getDeviceResourceLinks_test.go index f7595e2f..e1c158dc 100644 --- a/service/grpc/getDeviceResourceLinks_test.go +++ b/service/grpc/getDeviceResourceLinks_test.go @@ -52,11 +52,11 @@ func TestClientApplicationServerGetDeviceResourceLinks(t *testing.T) { name: "device links", args: args{ req: &pb.GetDeviceResourceLinksRequest{ - DeviceId: dev.Id, + DeviceId: dev.GetId(), }, }, want: hubTestPb.CleanUpResourceLinksPublished(&events.ResourceLinksPublished{ - DeviceId: dev.Id, + DeviceId: dev.GetId(), Resources: commands.SchemaResourceLinksToResources(test.GetDeviceResourceLinks(), time.Time{}), }, true), }, diff --git a/service/grpc/getDevice_test.go b/service/grpc/getDevice_test.go index d224eb26..77c31895 100644 --- a/service/grpc/getDevice_test.go +++ b/service/grpc/getDevice_test.go @@ -48,19 +48,19 @@ func TestClientApplicationServerGetDevice(t *testing.T) { time.Sleep(time.Second) d1, err := s.GetDevice(ctx, &pb.GetDeviceRequest{ - DeviceId: dev.Id, + DeviceId: dev.GetId(), }) require.NoError(t, err) require.Equal(t, dev.GetData(), d1.GetData()) _, err = s.OwnDevice(ctx, &pb.OwnDeviceRequest{ - DeviceId: dev.Id, + DeviceId: dev.GetId(), }) require.NoError(t, err) newName := test.DevsimName + "_new" _, err = s.UpdateResource(ctx, &pb.UpdateResourceRequest{ - ResourceId: commands.NewResourceID(dev.Id, configuration.ResourceURI), + ResourceId: commands.NewResourceID(dev.GetId(), configuration.ResourceURI), Content: &grpcgwPb.Content{ ContentType: serviceHttp.ApplicationJsonContentType, Data: []byte(`{"n":"` + newName + `"}`), @@ -69,7 +69,7 @@ func TestClientApplicationServerGetDevice(t *testing.T) { require.NoError(t, err) d1, err = s.GetDevice(ctx, &pb.GetDeviceRequest{ - DeviceId: dev.Id, + DeviceId: dev.GetId(), }) require.NoError(t, err) var v plgdDevice.Device @@ -78,7 +78,7 @@ func TestClientApplicationServerGetDevice(t *testing.T) { require.Equal(t, newName, v.Name) _, err = s.UpdateResource(ctx, &pb.UpdateResourceRequest{ - ResourceId: commands.NewResourceID(dev.Id, configuration.ResourceURI), + ResourceId: commands.NewResourceID(dev.GetId(), configuration.ResourceURI), Content: &grpcgwPb.Content{ ContentType: serviceHttp.ApplicationJsonContentType, Data: []byte(`{"n":"` + test.DevsimName + `"}`), @@ -87,7 +87,7 @@ func TestClientApplicationServerGetDevice(t *testing.T) { require.NoError(t, err) _, err = s.DisownDevice(ctx, &pb.DisownDeviceRequest{ - DeviceId: dev.Id, + DeviceId: dev.GetId(), }) require.NoError(t, err) } diff --git a/service/grpc/getDevices.go b/service/grpc/getDevices.go index dbc55d42..91c940d6 100644 --- a/service/grpc/getDevices.go +++ b/service/grpc/getDevices.go @@ -18,6 +18,7 @@ package grpc import ( "context" + "errors" "fmt" "io" "net" @@ -171,7 +172,7 @@ func processDiscoveryResourceResponse(serviceDevice *serviceDevice.Service, logg return nil, err } if len(links) == 0 { - return nil, fmt.Errorf("no links in response") + return nil, errors.New("no links in response") } addr, err := pkgNet.ParseString(string(schema.UDPScheme), remoteAddr.String()) @@ -256,7 +257,7 @@ func processDeviceResourceResponse(serviceDevice *serviceDevice.Service, logger return nil, err } if d.ID == "" { - return nil, fmt.Errorf("device ID is empty") + return nil, errors.New("device ID is empty") } devID, err := uuid.Parse(d.ID) if err != nil { @@ -559,7 +560,7 @@ func (s *ClientApplicationServer) GetDevices(req *pb.GetDevicesRequest, srv pb.C } discoveryCtx, cancel := context.WithTimeout(ctx, timeout) defer cancel() - if req.UseCache { + if req.GetUseCache() { s.devices.Range(func(key uuid.UUID, value *device) bool { cachedDevices.Store(key, value) return true @@ -569,7 +570,7 @@ func (s *ClientApplicationServer) GetDevices(req *pb.GetDevicesRequest, srv pb.C if len(req.GetUseMulticast()) > 0 { devService := s.serviceDevice.Load() if devService == nil { - return fmt.Errorf("cannot get devices: device service is not initialized") + return errors.New("cannot get devices: device service is not initialized") } toCall = append(toCall, func() { getDevicesByMulticast(discoveryCtx, toDiscoveryConfiguration(toUseMulticastFilter(req.GetUseMulticast())), func(conn *client.Conn, resp *pool.Message) { @@ -584,7 +585,7 @@ func (s *ClientApplicationServer) GetDevices(req *pb.GetDevicesRequest, srv pb.C if len(req.GetUseEndpoints()) > 0 { devService := s.serviceDevice.Load() if devService == nil { - return fmt.Errorf("cannot get devices: device service is not initialized") + return errors.New("cannot get devices: device service is not initialized") } toCall = append(toCall, func() { getDevicesByEndpoints(discoveryCtx, devService, s.logger, req.GetUseEndpoints(), discoveredDevices) @@ -602,7 +603,7 @@ func (s *ClientApplicationServer) GetDevices(req *pb.GetDevicesRequest, srv pb.C wg.Wait() devs := s.processDiscoverdDevices(discoveredDevices, cachedDevices) - cachedDevices.Range(func(key uuid.UUID, d *device) bool { + cachedDevices.Range(func(_ uuid.UUID, d *device) bool { devs = append(devs, d) return true }) diff --git a/service/grpc/getDevices_test.go b/service/grpc/getDevices_test.go index 4c63d2c4..f5edcf30 100644 --- a/service/grpc/getDevices_test.go +++ b/service/grpc/getDevices_test.go @@ -43,7 +43,7 @@ func TestClientApplicationServerCheckForClosingInactivityConnection(t *testing.T srv := test.NewClientApplicationGetDevicesServer(ctx) err = s.GetDevices(&pb.GetDevicesRequest{}, srv) require.NoError(t, err) - require.Greater(t, len(srv.Devices), 0) + require.NotEmpty(t, srv.Devices) time.Sleep(time.Second) numParallel := 10 var wg sync.WaitGroup @@ -54,7 +54,7 @@ func TestClientApplicationServerCheckForClosingInactivityConnection(t *testing.T go func(i int) { defer wg.Done() fmt.Printf("%v GetDevice %v start\n", time.Now(), i) - _, err := s.GetDevice(ctx, &pb.GetDeviceRequest{DeviceId: device.Id}) + _, err := s.GetDevice(ctx, &pb.GetDeviceRequest{DeviceId: device.GetId()}) fmt.Printf("%v GetDevice %v end %v\n", time.Now(), i, err) errCh <- err }(i) @@ -73,7 +73,7 @@ func TestClientApplicationServerCheckForClosingInactivityConnection(t *testing.T func TestClientApplicationServerGetDevices(t *testing.T) { device := test.MustFindDeviceByName(test.DevsimName, []pb.GetDevicesRequest_UseMulticast{pb.GetDevicesRequest_IPV4}) - u, err := url.Parse(device.Endpoints[0]) + u, err := url.Parse(device.GetEndpoints()[0]) require.NoError(t, err) ctx, cancel := context.WithTimeout(context.Background(), time.Second*8) defer cancel() @@ -141,11 +141,11 @@ func TestClientApplicationServerGetDevices(t *testing.T) { require.True(t, ok) got := server.Devices require.NotEmpty(t, got) - require.Len(t, got[0].Endpoints, 4) - require.True(t, strings.Contains(got[0].Endpoints[0], "coap://")) - require.True(t, strings.Contains(got[0].Endpoints[1], "coap+tcp://")) - require.True(t, strings.Contains(got[0].Endpoints[2], "coaps://")) - require.True(t, strings.Contains(got[0].Endpoints[3], "coaps+tcp://")) + require.Len(t, got[0].GetEndpoints(), 4) + require.True(t, strings.Contains(got[0].GetEndpoints()[0], "coap://")) + require.True(t, strings.Contains(got[0].GetEndpoints()[1], "coap+tcp://")) + require.True(t, strings.Contains(got[0].GetEndpoints()[2], "coaps://")) + require.True(t, strings.Contains(got[0].GetEndpoints()[3], "coaps+tcp://")) assert.Equal(t, tt.want, got) }) } diff --git a/service/grpc/getIdentityCertificate.go b/service/grpc/getIdentityCertificate.go index 22e50961..b2125cd8 100644 --- a/service/grpc/getIdentityCertificate.go +++ b/service/grpc/getIdentityCertificate.go @@ -25,7 +25,7 @@ import ( "google.golang.org/grpc/codes" ) -func (s *ClientApplicationServer) GetIdentityCertificate(ctx context.Context, req *pb.GetIdentityCertificateRequest) (*pb.GetIdentityCertificateResponse, error) { +func (s *ClientApplicationServer) GetIdentityCertificate(_ context.Context, _ *pb.GetIdentityCertificateRequest) (*pb.GetIdentityCertificateResponse, error) { devService := s.serviceDevice.Load() if devService == nil { return nil, grpc.ForwardErrorf(codes.Unavailable, "service is not initialized") diff --git a/service/grpc/getJSONWebKeys.go b/service/grpc/getJSONWebKeys.go index 359c1984..c624a729 100644 --- a/service/grpc/getJSONWebKeys.go +++ b/service/grpc/getJSONWebKeys.go @@ -27,7 +27,7 @@ import ( "google.golang.org/protobuf/types/known/structpb" ) -func (s *ClientApplicationServer) GetJSONWebKeys(ctx context.Context, req *pb.GetJSONWebKeysRequest) (*structpb.Struct, error) { +func (s *ClientApplicationServer) GetJSONWebKeys(_ context.Context, _ *pb.GetJSONWebKeysRequest) (*structpb.Struct, error) { jwksCache := s.jwksCache.Load() if jwksCache == nil { return nil, status.Errorf(codes.Unavailable, "not available") @@ -42,7 +42,7 @@ func (s *ClientApplicationServer) GetJSONWebKeys(ctx context.Context, req *pb.Ge marshaledJwk, err := json.Marshal(map[string]interface{}{ "keys": keys, }) - if jwksCache == nil { + if err != nil { return nil, status.Errorf(codes.Internal, "cannot marshal keys to json: %v", err) } var jwkMap map[string]interface{} diff --git a/service/grpc/getResource_test.go b/service/grpc/getResource_test.go index 5dbb9542..0a46b17b 100644 --- a/service/grpc/getResource_test.go +++ b/service/grpc/getResource_test.go @@ -53,7 +53,7 @@ func TestClientApplicationServerGetResource(t *testing.T) { args: args{ req: &pb.GetResourceRequest{ ResourceId: &commands.ResourceId{ - DeviceId: dev.Id, + DeviceId: dev.GetId(), Href: device.ResourceURI, }, }, @@ -81,7 +81,7 @@ func TestClientApplicationServerGetResource(t *testing.T) { args: args{ req: &pb.GetResourceRequest{ ResourceId: &commands.ResourceId{ - DeviceId: dev.Id, + DeviceId: dev.GetId(), Href: "/unknown", }, }, @@ -94,7 +94,7 @@ func TestClientApplicationServerGetResource(t *testing.T) { args: args{ req: &pb.GetResourceRequest{ ResourceId: &commands.ResourceId{ - DeviceId: dev.Id, + DeviceId: dev.GetId(), Href: configuration.ResourceURI, }, }, diff --git a/service/grpc/jsonWebKeyCache.go b/service/grpc/jsonWebKeyCache.go index b309cff7..59f292a7 100644 --- a/service/grpc/jsonWebKeyCache.go +++ b/service/grpc/jsonWebKeyCache.go @@ -1,7 +1,7 @@ package grpc import ( - "fmt" + "errors" "github.com/golang-jwt/jwt/v5" "github.com/google/uuid" @@ -37,18 +37,18 @@ func (c *JSONWebKeyCache) GetKey(token *jwt.Token) (interface{}, error) { func (c *JSONWebKeyCache) LookupKey(token *jwt.Token) (jwk.Key, error) { id, ok := token.Header["kid"].(string) if !ok { - return nil, fmt.Errorf("missing key id in token") + return nil, errors.New("missing key id in token") } if c.keys == nil { - return nil, fmt.Errorf("empty JWK cache") + return nil, errors.New("empty JWK cache") } if key, ok := c.keys.LookupKeyID(id); ok { if key.Algorithm() == token.Method.Alg() { return key, nil } } - return nil, fmt.Errorf("could not find JWK") + return nil, errors.New("could not find JWK") } func (s *ClientApplicationServer) ParseWithClaims(token string, claims jwt.Claims) error { diff --git a/service/grpc/onboardDevice.go b/service/grpc/onboardDevice.go index e35c48bd..23335076 100644 --- a/service/grpc/onboardDevice.go +++ b/service/grpc/onboardDevice.go @@ -19,6 +19,7 @@ package grpc import ( "context" "crypto/x509" + "errors" "fmt" "github.com/google/uuid" @@ -186,11 +187,11 @@ func insecureAddCredentials(ctx context.Context, cloudID string, dev *device, li func onboardInsecureDevice(ctx context.Context, dev *device, links schema.ResourceLinks, req *pb.OnboardDeviceRequest) error { switch { case req.GetAuthorizationProviderName() == "": - return fmt.Errorf("invalid AuthorizationProvider") + return errors.New("invalid AuthorizationProvider") case req.GetAuthorizationCode() == "": - return fmt.Errorf("invalid AuthorizationCode") + return errors.New("invalid AuthorizationCode") case req.GetCoapGatewayAddress() == "": - return fmt.Errorf("invalid URL") + return errors.New("invalid URL") } cloudLinks := links.GetResourceLinks(cloud.ResourceType) if len(cloudLinks) == 0 { diff --git a/service/grpc/ownDevice.go b/service/grpc/ownDevice.go index 4706368b..29aac15b 100644 --- a/service/grpc/ownDevice.go +++ b/service/grpc/ownDevice.go @@ -18,6 +18,7 @@ package grpc import ( "context" + "errors" "fmt" "time" @@ -55,7 +56,7 @@ func (s *remoteSign) Close(err error) { close(s.certificateSignChan) } -func (s *remoteSign) Sign(ctx context.Context, csr []byte) ([]byte, error) { +func (s *remoteSign) Sign(_ context.Context, csr []byte) ([]byte, error) { select { case <-s.ctx.Done(): return nil, fmt.Errorf("cannot send request with CSR: %w", s.ctx.Err()) @@ -143,7 +144,7 @@ func (s *ClientApplicationServer) ownDeviceGetCSR(ctx context.Context, timeoutVa go func() { devService := s.serviceDevice.Load() if devService == nil { - remoteSign.Close(fmt.Errorf("device service is not initialized")) + remoteSign.Close(errors.New("device service is not initialized")) return } defer s.remoteOwnSignCache.Delete(deviceStateID(dev.ID, remoteSign.state)) diff --git a/service/grpc/ownDevice_test.go b/service/grpc/ownDevice_test.go index 63f26325..d4c39107 100644 --- a/service/grpc/ownDevice_test.go +++ b/service/grpc/ownDevice_test.go @@ -41,17 +41,17 @@ func TestClientApplicationServerOwnDevice(t *testing.T) { require.NoError(t, err) _, err = s.OwnDevice(ctx, &pb.OwnDeviceRequest{ - DeviceId: dev.Id, + DeviceId: dev.GetId(), }) require.NoError(t, err) _, err = s.GetResource(ctx, &pb.GetResourceRequest{ - ResourceId: commands.NewResourceID(dev.Id, "/light/1"), + ResourceId: commands.NewResourceID(dev.GetId(), "/light/1"), }) require.NoError(t, err) _, err = s.DisownDevice(ctx, &pb.DisownDeviceRequest{ - DeviceId: dev.Id, + DeviceId: dev.GetId(), }) require.NoError(t, err) } @@ -73,17 +73,17 @@ func TestClientApplicationServerOwnDeviceViaManufacturerCertificate(t *testing.T require.NoError(t, err) _, err = s.OwnDevice(ctx, &pb.OwnDeviceRequest{ - DeviceId: dev.Id, + DeviceId: dev.GetId(), }) require.NoError(t, err) _, err = s.GetResource(ctx, &pb.GetResourceRequest{ - ResourceId: commands.NewResourceID(dev.Id, "/light/1"), + ResourceId: commands.NewResourceID(dev.GetId(), "/light/1"), }) require.NoError(t, err) _, err = s.DisownDevice(ctx, &pb.DisownDeviceRequest{ - DeviceId: dev.Id, + DeviceId: dev.GetId(), }) require.NoError(t, err) } diff --git a/service/grpc/reset.go b/service/grpc/reset.go index 257cbfbc..133e2fc5 100644 --- a/service/grpc/reset.go +++ b/service/grpc/reset.go @@ -51,7 +51,7 @@ func (s *ClientApplicationServer) reset(ctx context.Context, forceReset bool) er return nil } -func (s *ClientApplicationServer) Reset(ctx context.Context, req *pb.ResetRequest) (*pb.ResetResponse, error) { +func (s *ClientApplicationServer) Reset(ctx context.Context, _ *pb.ResetRequest) (*pb.ResetResponse, error) { s.initializationMutex.Lock() defer s.initializationMutex.Unlock() err := s.reset(ctx, true) diff --git a/service/grpc/server.go b/service/grpc/server.go index 96cfb7b6..2d0a39a7 100644 --- a/service/grpc/server.go +++ b/service/grpc/server.go @@ -73,7 +73,7 @@ func NewClientApplicationServer(cfg *atomic.Pointer[config.Config], devService * } func (s *ClientApplicationServer) Version() string { - return s.info.Version + return s.info.GetVersion() } func (s *ClientApplicationServer) GetConfig() config.Config { diff --git a/service/grpc/service.go b/service/grpc/service.go index 0e20cbbb..d5202552 100644 --- a/service/grpc/service.go +++ b/service/grpc/service.go @@ -17,7 +17,6 @@ package grpc import ( - "context" "fmt" "github.com/plgd-dev/client-application/pb" @@ -34,7 +33,7 @@ type Service struct { } // New creates new GRPC service -func New(ctx context.Context, serviceName string, config configGrpc.Config, clientApplicationServer *ClientApplicationServer, fileWatcher *fsnotify.Watcher, logger log.Logger, tracerProvider trace.TracerProvider) (*Service, error) { +func New(config configGrpc.Config, clientApplicationServer *ClientApplicationServer, fileWatcher *fsnotify.Watcher, logger log.Logger, tracerProvider trace.TracerProvider) (*Service, error) { methods := []string{ "/" + pb.ClientApplication_ServiceDesc.ServiceName + "/UpdateJSONWebKeys", "/" + pb.ClientApplication_ServiceDesc.ServiceName + "/GetJSONWebKeys", diff --git a/service/grpc/updateJSONWebKeys.go b/service/grpc/updateJSONWebKeys.go index 26859f6d..2fb694b0 100644 --- a/service/grpc/updateJSONWebKeys.go +++ b/service/grpc/updateJSONWebKeys.go @@ -46,12 +46,11 @@ func (s *ClientApplicationServer) getOwnerForUpdateJSONWebKeys(ctx context.Conte if err != nil { return "", status.Errorf(codes.Unauthenticated, "cannot get token: %v", err) } - owner := "" cfg := s.GetConfig() if s.jwksCache.Load() == nil { - owner, err = grpc.OwnerFromTokenMD(ctx, cfg.RemoteProvisioning.GetJwtOwnerClaim()) - if err != nil { - return "", status.Errorf(codes.Unauthenticated, "cannot get owner from token: %v", err) + owner, err2 := grpc.OwnerFromTokenMD(ctx, cfg.RemoteProvisioning.GetJwtOwnerClaim()) + if err2 != nil { + return "", status.Errorf(codes.Unauthenticated, "cannot get owner from token: %v", err2) } return owner, nil } @@ -61,7 +60,7 @@ func (s *ClientApplicationServer) getOwnerForUpdateJSONWebKeys(ctx context.Conte return "", status.Errorf(codes.Unauthenticated, "cannot parse token: %v", err) } claims := plgdJwt.Claims(*scopedClaims) - owner, err = claims.GetOwner(cfg.RemoteProvisioning.GetJwtOwnerClaim()) + owner, err := claims.GetOwner(cfg.RemoteProvisioning.GetJwtOwnerClaim()) if err != nil { return "", status.Errorf(codes.Unauthenticated, "cannot get owner from token: %v", err) } diff --git a/service/grpc/updateResource_test.go b/service/grpc/updateResource_test.go index 4247b8bc..eb85da0b 100644 --- a/service/grpc/updateResource_test.go +++ b/service/grpc/updateResource_test.go @@ -56,7 +56,7 @@ func TestClientApplicationServerUpdateResource(t *testing.T) { args: args{ req: &pb.UpdateResourceRequest{ ResourceId: &commands.ResourceId{ - DeviceId: dev.Id, + DeviceId: dev.GetId(), Href: doxm.ResourceURI, }, Content: &grpcgwPb.Content{ @@ -77,7 +77,7 @@ func TestClientApplicationServerUpdateResource(t *testing.T) { args: args{ req: &pb.UpdateResourceRequest{ ResourceId: &commands.ResourceId{ - DeviceId: dev.Id, + DeviceId: dev.GetId(), Href: device.ResourceURI, }, Content: &grpcgwPb.Content{ @@ -111,7 +111,7 @@ func TestClientApplicationServerUpdateResource(t *testing.T) { args: args{ req: &pb.UpdateResourceRequest{ ResourceId: &commands.ResourceId{ - DeviceId: dev.Id, + DeviceId: dev.GetId(), Href: "/unknown", }, Content: &grpcgwPb.Content{ @@ -128,7 +128,7 @@ func TestClientApplicationServerUpdateResource(t *testing.T) { args: args{ req: &pb.UpdateResourceRequest{ ResourceId: &commands.ResourceId{ - DeviceId: dev.Id, + DeviceId: dev.GetId(), Href: configuration.ResourceURI, }, Content: &grpcgwPb.Content{ diff --git a/service/http/clearCache_test.go b/service/http/clearCache_test.go index 71b61a4b..d4bef185 100644 --- a/service/http/clearCache_test.go +++ b/service/http/clearCache_test.go @@ -44,7 +44,7 @@ func TestClientApplicationServerClearCache(t *testing.T) { // own device request := httpgwTest.NewRequest(http.MethodPost, serviceHttp.OwnDevice, nil). - Host(test.CLIENT_APPLICATION_HTTP_HOST).DeviceId(dev.Id).Build() + Host(test.CLIENT_APPLICATION_HTTP_HOST).DeviceId(dev.GetId()).Build() resp := httpgwTest.HTTPDo(t, request) _ = resp.Body.Close() require.Equal(t, http.StatusOK, resp.StatusCode) @@ -52,7 +52,7 @@ func TestClientApplicationServerClearCache(t *testing.T) { // update device newName := test.DevsimName + "_new" request = httpgwTest.NewRequest(http.MethodPut, serviceHttp.DeviceResource, bytes.NewBufferString(`{"n":"`+newName+`"}`)). - Host(test.CLIENT_APPLICATION_HTTP_HOST).DeviceId(dev.Id).ResourceHref(configuration.ResourceURI).ContentType(serviceHttp.ApplicationJsonContentType).Build() + Host(test.CLIENT_APPLICATION_HTTP_HOST).DeviceId(dev.GetId()).ResourceHref(configuration.ResourceURI).ContentType(serviceHttp.ApplicationJsonContentType).Build() resp = httpgwTest.HTTPDo(t, request) defer func() { _ = resp.Body.Close() @@ -61,7 +61,7 @@ func TestClientApplicationServerClearCache(t *testing.T) { // check device name request = httpgwTest.NewRequest(http.MethodGet, serviceHttp.Device, nil). - Host(test.CLIENT_APPLICATION_HTTP_HOST).Accept(serviceHttp.ApplicationProtoJsonContentType).DeviceId(dev.Id).Build() + Host(test.CLIENT_APPLICATION_HTTP_HOST).Accept(serviceHttp.ApplicationProtoJsonContentType).DeviceId(dev.GetId()).Build() resp = httpgwTest.HTTPDo(t, request) defer func() { _ = resp.Body.Close() @@ -88,7 +88,7 @@ func TestClientApplicationServerClearCache(t *testing.T) { // check that device is not in cache request = httpgwTest.NewRequest(http.MethodGet, serviceHttp.Device, nil). - Host(test.CLIENT_APPLICATION_HTTP_HOST).Accept(serviceHttp.ApplicationProtoJsonContentType).DeviceId(dev.Id).Build() + Host(test.CLIENT_APPLICATION_HTTP_HOST).Accept(serviceHttp.ApplicationProtoJsonContentType).DeviceId(dev.GetId()).Build() resp = httpgwTest.HTTPDo(t, request) defer func() { _ = resp.Body.Close() @@ -100,7 +100,7 @@ func TestClientApplicationServerClearCache(t *testing.T) { // revert update device name request = httpgwTest.NewRequest(http.MethodPut, serviceHttp.DeviceResource, bytes.NewBufferString(`{"n":"`+test.DevsimName+`"}`)). - Host(test.CLIENT_APPLICATION_HTTP_HOST).DeviceId(dev.Id).ResourceHref(configuration.ResourceURI).ContentType(serviceHttp.ApplicationJsonContentType).Build() + Host(test.CLIENT_APPLICATION_HTTP_HOST).DeviceId(dev.GetId()).ResourceHref(configuration.ResourceURI).ContentType(serviceHttp.ApplicationJsonContentType).Build() resp = httpgwTest.HTTPDo(t, request) defer func() { _ = resp.Body.Close() @@ -109,7 +109,7 @@ func TestClientApplicationServerClearCache(t *testing.T) { // disown device request = httpgwTest.NewRequest(http.MethodPost, serviceHttp.DisownDevice, nil). - Host(test.CLIENT_APPLICATION_HTTP_HOST).DeviceId(dev.Id).Build() + Host(test.CLIENT_APPLICATION_HTTP_HOST).DeviceId(dev.GetId()).Build() resp = httpgwTest.HTTPDo(t, request) _ = resp.Body.Close() require.Equal(t, http.StatusOK, resp.StatusCode) diff --git a/service/http/createDeleteResource_test.go b/service/http/createDeleteResource_test.go index e70198cc..0ae14b8a 100644 --- a/service/http/createDeleteResource_test.go +++ b/service/http/createDeleteResource_test.go @@ -40,7 +40,7 @@ func TestClientApplicationServerCreateDeleteResource(t *testing.T) { getDevices(t, "") request := httpgwTest.NewRequest(http.MethodPost, serviceHttp.OwnDevice, nil). - Host(test.CLIENT_APPLICATION_HTTP_HOST).DeviceId(dev.Id).Build() + Host(test.CLIENT_APPLICATION_HTTP_HOST).DeviceId(dev.GetId()).Build() resp := httpgwTest.HTTPDo(t, request) _ = resp.Body.Close() require.Equal(t, http.StatusOK, resp.StatusCode) @@ -50,27 +50,27 @@ func TestClientApplicationServerCreateDeleteResource(t *testing.T) { v, err := json.Encode(hubTest.MakeSwitchResourceDefaultData()) require.NoError(t, err) return v - }())).Host(test.CLIENT_APPLICATION_HTTP_HOST).DeviceId(dev.Id).ResourceHref(hubTest.TestResourceSwitchesHref).Build() + }())).Host(test.CLIENT_APPLICATION_HTTP_HOST).DeviceId(dev.GetId()).ResourceHref(hubTest.TestResourceSwitchesHref).Build() resp = httpgwTest.HTTPDo(t, request) _ = resp.Body.Close() require.Equal(t, http.StatusOK, resp.StatusCode) // delete resource request = httpgwTest.NewRequest(http.MethodDelete, serviceHttp.DeviceResourceLink, nil). - Host(test.CLIENT_APPLICATION_HTTP_HOST).DeviceId(dev.Id).ResourceHref(hubTest.TestResourceSwitchesInstanceHref("1")).Build() + Host(test.CLIENT_APPLICATION_HTTP_HOST).DeviceId(dev.GetId()).ResourceHref(hubTest.TestResourceSwitchesInstanceHref("1")).Build() resp = httpgwTest.HTTPDo(t, request) _ = resp.Body.Close() require.Equal(t, http.StatusOK, resp.StatusCode) // duplicity delete request = httpgwTest.NewRequest(http.MethodDelete, serviceHttp.DeviceResourceLink, nil). - Host(test.CLIENT_APPLICATION_HTTP_HOST).DeviceId(dev.Id).ResourceHref(hubTest.TestResourceSwitchesInstanceHref("1")).Build() + Host(test.CLIENT_APPLICATION_HTTP_HOST).DeviceId(dev.GetId()).ResourceHref(hubTest.TestResourceSwitchesInstanceHref("1")).Build() resp = httpgwTest.HTTPDo(t, request) _ = resp.Body.Close() require.Equal(t, http.StatusNotFound, resp.StatusCode) request = httpgwTest.NewRequest(http.MethodPost, serviceHttp.DisownDevice, nil). - Host(test.CLIENT_APPLICATION_HTTP_HOST).DeviceId(dev.Id).Build() + Host(test.CLIENT_APPLICATION_HTTP_HOST).DeviceId(dev.GetId()).Build() resp = httpgwTest.HTTPDo(t, request) _ = resp.Body.Close() require.Equal(t, http.StatusOK, resp.StatusCode) diff --git a/service/http/getDeviceResourceLinks_test.go b/service/http/getDeviceResourceLinks_test.go index 929ebaab..b3d84797 100644 --- a/service/http/getDeviceResourceLinks_test.go +++ b/service/http/getDeviceResourceLinks_test.go @@ -51,10 +51,10 @@ func TestClientApplicationServerGetDeviceResourceLinks(t *testing.T) { { name: "device links", args: args{ - deviceID: dev.Id, + deviceID: dev.GetId(), }, want: hubTestPb.CleanUpResourceLinksPublished(&events.ResourceLinksPublished{ - DeviceId: dev.Id, + DeviceId: dev.GetId(), Resources: commands.SchemaResourceLinksToResources(test.GetDeviceResourceLinks(), time.Time{}), }, true), wantCode: http.StatusOK, diff --git a/service/http/getDevice_test.go b/service/http/getDevice_test.go index 21b2ba02..415739d2 100644 --- a/service/http/getDevice_test.go +++ b/service/http/getDevice_test.go @@ -43,7 +43,7 @@ func TestClientApplicationServerGetDevice(t *testing.T) { getDevices(t, "") request := httpgwTest.NewRequest(http.MethodPost, serviceHttp.OwnDevice, nil). - Host(test.CLIENT_APPLICATION_HTTP_HOST).DeviceId(dev.Id).Build() + Host(test.CLIENT_APPLICATION_HTTP_HOST).DeviceId(dev.GetId()).Build() resp := httpgwTest.HTTPDo(t, request) _ = resp.Body.Close() require.Equal(t, http.StatusOK, resp.StatusCode) @@ -51,7 +51,7 @@ func TestClientApplicationServerGetDevice(t *testing.T) { newName := test.DevsimName + "_new" request = httpgwTest.NewRequest(http.MethodPut, serviceHttp.DeviceResource, bytes.NewBufferString(`{"n":"`+newName+`"}`)). - Host(test.CLIENT_APPLICATION_HTTP_HOST).DeviceId(dev.Id).ResourceHref(configuration.ResourceURI).ContentType(serviceHttp.ApplicationJsonContentType).Build() + Host(test.CLIENT_APPLICATION_HTTP_HOST).DeviceId(dev.GetId()).ResourceHref(configuration.ResourceURI).ContentType(serviceHttp.ApplicationJsonContentType).Build() resp = httpgwTest.HTTPDo(t, request) defer func() { _ = resp.Body.Close() @@ -59,7 +59,7 @@ func TestClientApplicationServerGetDevice(t *testing.T) { assert.Equal(t, http.StatusOK, resp.StatusCode) request = httpgwTest.NewRequest(http.MethodGet, serviceHttp.Device, nil). - Host(test.CLIENT_APPLICATION_HTTP_HOST).Accept(serviceHttp.ApplicationProtoJsonContentType).DeviceId(dev.Id).Build() + Host(test.CLIENT_APPLICATION_HTTP_HOST).Accept(serviceHttp.ApplicationProtoJsonContentType).DeviceId(dev.GetId()).Build() resp = httpgwTest.HTTPDo(t, request) defer func() { _ = resp.Body.Close() @@ -76,7 +76,7 @@ func TestClientApplicationServerGetDevice(t *testing.T) { require.Equal(t, newName, v.Name) request = httpgwTest.NewRequest(http.MethodPut, serviceHttp.DeviceResource, bytes.NewBufferString(`{"n":"`+test.DevsimName+`"}`)). - Host(test.CLIENT_APPLICATION_HTTP_HOST).DeviceId(dev.Id).ResourceHref(configuration.ResourceURI).ContentType(serviceHttp.ApplicationJsonContentType).Build() + Host(test.CLIENT_APPLICATION_HTTP_HOST).DeviceId(dev.GetId()).ResourceHref(configuration.ResourceURI).ContentType(serviceHttp.ApplicationJsonContentType).Build() resp = httpgwTest.HTTPDo(t, request) defer func() { _ = resp.Body.Close() @@ -84,7 +84,7 @@ func TestClientApplicationServerGetDevice(t *testing.T) { assert.Equal(t, http.StatusOK, resp.StatusCode) request = httpgwTest.NewRequest(http.MethodPost, serviceHttp.DisownDevice, nil). - Host(test.CLIENT_APPLICATION_HTTP_HOST).DeviceId(dev.Id).Build() + Host(test.CLIENT_APPLICATION_HTTP_HOST).DeviceId(dev.GetId()).Build() resp = httpgwTest.HTTPDo(t, request) _ = resp.Body.Close() require.Equal(t, http.StatusOK, resp.StatusCode) diff --git a/service/http/getDevices_test.go b/service/http/getDevices_test.go index dea5fa72..73132755 100644 --- a/service/http/getDevices_test.go +++ b/service/http/getDevices_test.go @@ -54,7 +54,7 @@ func getDevices(t *testing.T, token string) { func TestClientApplicationServerGetDevices(t *testing.T) { device := test.MustFindDeviceByName(test.DevsimName, []pb.GetDevicesRequest_UseMulticast{pb.GetDevicesRequest_IPV4}) - u, err := url.Parse(device.Endpoints[0]) + u, err := url.Parse(device.GetEndpoints()[0]) require.NoError(t, err) type args struct { diff --git a/service/http/getJSONWebKeys_test.go b/service/http/getJSONWebKeys_test.go index 98d221e4..6c75bb07 100644 --- a/service/http/getJSONWebKeys_test.go +++ b/service/http/getJSONWebKeys_test.go @@ -38,12 +38,18 @@ func TestClientApplicationServerGetJSONWebKeys(t *testing.T) { request := httpgwTest.NewRequest(http.MethodGet, serviceHttp.WellKnownJWKs, nil). Host(test.CLIENT_APPLICATION_HTTP_HOST).Build() resp := httpgwTest.HTTPDo(t, request) + defer func(r *http.Response) { + _ = r.Body.Close() + }(resp) require.Equal(t, http.StatusServiceUnavailable, resp.StatusCode) initializeRemoteProvisioning(ctx, t) request = httpgwTest.NewRequest(http.MethodGet, serviceHttp.WellKnownJWKs, nil).Host(test.CLIENT_APPLICATION_HTTP_HOST).Build() resp = httpgwTest.HTTPDo(t, request) + defer func(r *http.Response) { + _ = r.Body.Close() + }(resp) require.Equal(t, http.StatusOK, resp.StatusCode) var jwksClientApp map[string]interface{} err := json.ReadFrom(resp.Body, &jwksClientApp) diff --git a/service/http/getResource_test.go b/service/http/getResource_test.go index 572f8e17..82f17ba8 100644 --- a/service/http/getResource_test.go +++ b/service/http/getResource_test.go @@ -53,11 +53,11 @@ func TestClientApplicationServerGetResource(t *testing.T) { name: "device resource", args: args{ accept: serviceHttp.ApplicationProtoJsonContentType, - deviceID: dev.Id, + deviceID: dev.GetId(), href: device.ResourceURI, }, want: &grpcgwPb.Resource{ - Data: dev.Data, + Data: dev.GetData(), Types: []string{"oic.d.cloudDevice", "oic.wk.d"}, }, wantCode: http.StatusOK, @@ -74,7 +74,7 @@ func TestClientApplicationServerGetResource(t *testing.T) { { name: "unknown href", args: args{ - deviceID: dev.Id, + deviceID: dev.GetId(), href: "/unknown", }, wantErr: true, @@ -83,7 +83,7 @@ func TestClientApplicationServerGetResource(t *testing.T) { { name: "forbidden - cannot establish TLS connection", args: args{ - deviceID: dev.Id, + deviceID: dev.GetId(), href: configuration.ResourceURI, }, wantErr: true, diff --git a/service/http/onboardDevice_test.go b/service/http/onboardDevice_test.go index 4f5feca2..746c4700 100644 --- a/service/http/onboardDevice_test.go +++ b/service/http/onboardDevice_test.go @@ -62,7 +62,7 @@ func TestClientApplicationServerOnboardDeviceRemoteProvisioning(t *testing.T) { request := httpgwTest.NewRequest(http.MethodPost, serviceHttp.OwnDevice, encodeToBody(t, &pb.OwnDeviceRequest{ Timeout: (time.Second * 8).Nanoseconds(), - })).Host(test.CLIENT_APPLICATION_HTTP_HOST).AuthToken(token).DeviceId(dev.Id).Build() + })).Host(test.CLIENT_APPLICATION_HTTP_HOST).AuthToken(token).DeviceId(dev.GetId()).Build() resp := httpgwTest.HTTPDo(t, request) require.Equal(t, http.StatusOK, resp.StatusCode) var ownCSRResp pb.OwnDeviceResponse @@ -74,13 +74,13 @@ func TestClientApplicationServerOnboardDeviceRemoteProvisioning(t *testing.T) { certificate := signCSR(ctx, t, ownCSRResp.GetIdentityCertificateChallenge().GetCertificateSigningRequest()) request = httpgwTest.NewRequest(http.MethodPost, serviceHttp.OwnDevice+"/"+ownCSRResp.GetIdentityCertificateChallenge().GetState(), encodeToBody(t, &pb.FinishOwnDeviceRequest{ Certificate: certificate, - })).Host(test.CLIENT_APPLICATION_HTTP_HOST).AuthToken(token).DeviceId(dev.Id).Build() + })).Host(test.CLIENT_APPLICATION_HTTP_HOST).AuthToken(token).DeviceId(dev.GetId()).Build() resp = httpgwTest.HTTPDo(t, request) require.Equal(t, http.StatusOK, resp.StatusCode) var ownCertificateResp pb.FinishOwnDeviceResponse decodeBody(t, resp.Body, &ownCertificateResp) - cloudConn, err := grpc.Dial(config.GRPC_GW_HOST, grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{ + cloudConn, err := grpc.NewClient(config.GRPC_GW_HOST, grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{ RootCAs: hubTest.GetRootCertificatePool(t), MinVersion: tls.VersionTLS12, }))) @@ -106,7 +106,7 @@ func TestClientApplicationServerOnboardDeviceRemoteProvisioning(t *testing.T) { ev, err := subClient.Recv() require.NoError(t, err) expectedEvent := &hubGrpcGwPb.Event{ - SubscriptionId: ev.SubscriptionId, + SubscriptionId: ev.GetSubscriptionId(), CorrelationId: "allEvents", Type: &hubGrpcGwPb.Event_OperationProcessed_{ OperationProcessed: &hubGrpcGwPb.Event_OperationProcessed{ @@ -140,26 +140,26 @@ func TestClientApplicationServerOnboardDeviceRemoteProvisioning(t *testing.T) { // onboard request = httpgwTest.NewRequest(http.MethodPost, serviceHttp.OnboardDevice, encodeToBody(t, &pb.OnboardDeviceRequest{ CoapGatewayAddress: httpClientCfg.GetRemoteProvisioning().GetCoapGateway(), - AuthorizationCode: hubTestOAuthServerTest.GetAuthorizationCode(t, oauthServer.Host, httpClientCfg.GetRemoteProvisioning().GetDeviceOauthClient().GetClientId(), dev.Id, ""), + AuthorizationCode: hubTestOAuthServerTest.GetAuthorizationCode(t, oauthServer.Host, httpClientCfg.GetRemoteProvisioning().GetDeviceOauthClient().GetClientId(), dev.GetId(), ""), HubId: httpClientCfg.GetRemoteProvisioning().GetId(), AuthorizationProviderName: httpClientCfg.GetRemoteProvisioning().GetDeviceOauthClient().GetProviderName(), CertificateAuthorities: httpClientCfg.GetRemoteProvisioning().GetCertificateAuthorities(), - })).Host(test.CLIENT_APPLICATION_HTTP_HOST).AuthToken(token).DeviceId(dev.Id).Build() + })).Host(test.CLIENT_APPLICATION_HTTP_HOST).AuthToken(token).DeviceId(dev.GetId()).Build() resp = httpgwTest.HTTPDo(t, request) _ = resp.Body.Close() require.Equal(t, http.StatusOK, resp.StatusCode) - hubTest.WaitForDevice(t, subClient, dev.Id, expectedEvent.GetSubscriptionId(), expectedEvent.GetCorrelationId(), hubTest.GetAllBackendResourceLinks()) + hubTest.WaitForDevice(t, subClient, dev.GetId(), expectedEvent.GetSubscriptionId(), expectedEvent.GetCorrelationId(), hubTest.GetAllBackendResourceLinks()) // offboard - request = httpgwTest.NewRequest(http.MethodPost, serviceHttp.OffboardDevice, nil).Host(test.CLIENT_APPLICATION_HTTP_HOST).AuthToken(token).DeviceId(dev.Id).Build() + request = httpgwTest.NewRequest(http.MethodPost, serviceHttp.OffboardDevice, nil).Host(test.CLIENT_APPLICATION_HTTP_HOST).AuthToken(token).DeviceId(dev.GetId()).Build() resp = httpgwTest.HTTPDo(t, request) _ = resp.Body.Close() require.Equal(t, http.StatusOK, resp.StatusCode) // disown request = httpgwTest.NewRequest(http.MethodPost, serviceHttp.DisownDevice, nil). - Host(test.CLIENT_APPLICATION_HTTP_HOST).AuthToken(token).DeviceId(dev.Id).Build() + Host(test.CLIENT_APPLICATION_HTTP_HOST).AuthToken(token).DeviceId(dev.GetId()).Build() resp = httpgwTest.HTTPDo(t, request) _ = resp.Body.Close() require.Equal(t, http.StatusOK, resp.StatusCode) diff --git a/service/http/ownDevice_test.go b/service/http/ownDevice_test.go index 0f05657d..813b054c 100644 --- a/service/http/ownDevice_test.go +++ b/service/http/ownDevice_test.go @@ -54,15 +54,15 @@ func TestClientApplicationServerOwnDevice(t *testing.T) { getDevices(t, "") - doSimpleOwn(t, dev.Id, http.StatusOK) + doSimpleOwn(t, dev.GetId(), http.StatusOK) request := httpgwTest.NewRequest(http.MethodGet, serviceHttp.DeviceResource, nil). - Host(test.CLIENT_APPLICATION_HTTP_HOST).DeviceId(dev.Id).ResourceHref("/light/1").Build() + Host(test.CLIENT_APPLICATION_HTTP_HOST).DeviceId(dev.GetId()).ResourceHref("/light/1").Build() resp := httpgwTest.HTTPDo(t, request) _ = resp.Body.Close() require.Equal(t, http.StatusOK, resp.StatusCode) - doDisown(t, dev.Id, http.StatusOK) + doDisown(t, dev.GetId(), http.StatusOK) } func createJwkKey(privateKey interface{}) (jwk.Key, error) { @@ -166,8 +166,11 @@ func TestClientApplicationServerOwnDeviceRemoteProvisioning(t *testing.T) { request := httpgwTest.NewRequest(http.MethodPost, serviceHttp.OwnDevice, encodeToBody(t, &pb.OwnDeviceRequest{ Timeout: (time.Second * 8).Nanoseconds(), - })).Host(test.CLIENT_APPLICATION_HTTP_HOST).AuthToken(token).DeviceId(dev.Id).Build() + })).Host(test.CLIENT_APPLICATION_HTTP_HOST).AuthToken(token).DeviceId(dev.GetId()).Build() resp := httpgwTest.HTTPDo(t, request) + defer func(r *http.Response) { + _ = r.Body.Close() + }(resp) require.Equal(t, http.StatusOK, resp.StatusCode) var ownCSRResp pb.OwnDeviceResponse decodeBody(t, resp.Body, &ownCSRResp) @@ -177,27 +180,36 @@ func TestClientApplicationServerOwnDeviceRemoteProvisioning(t *testing.T) { certificate := signCSR(ctx, t, ownCSRResp.GetIdentityCertificateChallenge().GetCertificateSigningRequest()) request = httpgwTest.NewRequest(http.MethodPost, serviceHttp.OwnDevice+"/"+ownCSRResp.GetIdentityCertificateChallenge().GetState(), encodeToBody(t, &pb.FinishOwnDeviceRequest{ Certificate: certificate, - })).Host(test.CLIENT_APPLICATION_HTTP_HOST).AuthToken(token).DeviceId(dev.Id).Build() + })).Host(test.CLIENT_APPLICATION_HTTP_HOST).AuthToken(token).DeviceId(dev.GetId()).Build() resp = httpgwTest.HTTPDo(t, request) + defer func(r *http.Response) { + _ = r.Body.Close() + }(resp) require.Equal(t, http.StatusOK, resp.StatusCode) var ownCertificateResp pb.FinishOwnDeviceResponse decodeBody(t, resp.Body, &ownCertificateResp) // get resource with valid token request = httpgwTest.NewRequest(http.MethodGet, serviceHttp.DeviceResource, nil). - Host(test.CLIENT_APPLICATION_HTTP_HOST).AuthToken(token).DeviceId(dev.Id).ResourceHref("/light/1").Build() + Host(test.CLIENT_APPLICATION_HTTP_HOST).AuthToken(token).DeviceId(dev.GetId()).ResourceHref("/light/1").Build() resp = httpgwTest.HTTPDo(t, request) + defer func(r *http.Response) { + _ = r.Body.Close() + }(resp) assert.Equal(t, http.StatusOK, resp.StatusCode) // get resource with token by another user user2token := GetAccessTokenForUser(t, "user2") request = httpgwTest.NewRequest(http.MethodGet, serviceHttp.DeviceResource, nil). - Host(test.CLIENT_APPLICATION_HTTP_HOST).AuthToken(user2token).DeviceId(dev.Id).ResourceHref("/light/1").Build() + Host(test.CLIENT_APPLICATION_HTTP_HOST).AuthToken(user2token).DeviceId(dev.GetId()).ResourceHref("/light/1").Build() resp = httpgwTest.HTTPDo(t, request) + defer func(r *http.Response) { + _ = r.Body.Close() + }(resp) assert.Equal(t, http.StatusUnauthorized, resp.StatusCode) request = httpgwTest.NewRequest(http.MethodPost, serviceHttp.DisownDevice, nil). - Host(test.CLIENT_APPLICATION_HTTP_HOST).AuthToken(token).DeviceId(dev.Id).Build() + Host(test.CLIENT_APPLICATION_HTTP_HOST).AuthToken(token).DeviceId(dev.GetId()).Build() resp = httpgwTest.HTTPDo(t, request) _ = resp.Body.Close() require.Equal(t, http.StatusOK, resp.StatusCode) @@ -219,8 +231,11 @@ func TestClientApplicationServerOwnDeviceRemoteProvisioningFails(t *testing.T) { request := httpgwTest.NewRequest(http.MethodPost, serviceHttp.OwnDevice, encodeToBody(t, &pb.OwnDeviceRequest{ Timeout: (time.Millisecond * 100).Nanoseconds(), - })).Host(test.CLIENT_APPLICATION_HTTP_HOST).AuthToken(token).DeviceId(dev.Id).Build() + })).Host(test.CLIENT_APPLICATION_HTTP_HOST).AuthToken(token).DeviceId(dev.GetId()).Build() resp := httpgwTest.HTTPDo(t, request) + defer func(r *http.Response) { + _ = r.Body.Close() + }(resp) require.Equal(t, http.StatusOK, resp.StatusCode) var ownCSRResp pb.OwnDeviceResponse decodeBody(t, resp.Body, &ownCSRResp) @@ -233,7 +248,10 @@ func TestClientApplicationServerOwnDeviceRemoteProvisioningFails(t *testing.T) { certificate := signCSR(ctx, t, ownCSRResp.GetIdentityCertificateChallenge().GetCertificateSigningRequest()) request = httpgwTest.NewRequest(http.MethodPost, serviceHttp.OwnDevice+"/"+ownCSRResp.GetIdentityCertificateChallenge().GetState(), encodeToBody(t, &pb.FinishOwnDeviceRequest{ Certificate: certificate, - })).Host(test.CLIENT_APPLICATION_HTTP_HOST).AuthToken(token).DeviceId(dev.Id).Build() + })).Host(test.CLIENT_APPLICATION_HTTP_HOST).AuthToken(token).DeviceId(dev.GetId()).Build() resp = httpgwTest.HTTPDo(t, request) + defer func(r *http.Response) { + _ = r.Body.Close() + }(resp) require.Equal(t, http.StatusNotFound, resp.StatusCode) } diff --git a/service/http/pskInitialize_test.go b/service/http/pskInitialize_test.go index c3795961..49427feb 100644 --- a/service/http/pskInitialize_test.go +++ b/service/http/pskInitialize_test.go @@ -40,11 +40,15 @@ func doInitializePSK(t *testing.T, subjectID string, key string, expCode int) { })).Host(test.CLIENT_APPLICATION_HTTP_HOST).Build() resp := httpgwTest.HTTPDo(t, request) require.Equal(t, expCode, resp.StatusCode) + _ = resp.Body.Close() } func initializePSK(t *testing.T, subjectID string, key string) { request := httpgwTest.NewRequest(http.MethodGet, serviceHttp.WellKnownConfiguration, nil).Host(test.CLIENT_APPLICATION_HTTP_HOST).Build() resp := httpgwTest.HTTPDo(t, request) + defer func(r *http.Response) { + _ = r.Body.Close() + }(resp) require.Equal(t, http.StatusOK, resp.StatusCode) configRespBody, err := io.ReadAll(resp.Body) require.NoError(t, err) @@ -52,13 +56,16 @@ func initializePSK(t *testing.T, subjectID string, key string) { err = protojson.Unmarshal(configRespBody, &configResp) require.NoError(t, err) require.False(t, configResp.GetIsInitialized()) - require.Equal(t, configResp.GetOwner(), "") - require.Equal(t, configResp.GetDeviceAuthenticationMode(), pb.GetConfigurationResponse_UNINITIALIZED) + require.Equal(t, "", configResp.GetOwner()) + require.Equal(t, pb.GetConfigurationResponse_UNINITIALIZED, configResp.GetDeviceAuthenticationMode()) doInitializePSK(t, subjectID, key, http.StatusOK) request = httpgwTest.NewRequest(http.MethodGet, serviceHttp.WellKnownConfiguration, nil).Host(test.CLIENT_APPLICATION_HTTP_HOST).Build() resp = httpgwTest.HTTPDo(t, request) + defer func(r *http.Response) { + _ = r.Body.Close() + }(resp) require.Equal(t, http.StatusOK, resp.StatusCode) configRespBody, err = io.ReadAll(resp.Body) require.NoError(t, err) @@ -67,7 +74,7 @@ func initializePSK(t *testing.T, subjectID string, key string) { require.NoError(t, err) require.True(t, configResp1.GetIsInitialized()) require.Equal(t, configResp1.GetOwner(), subjectID) - require.Equal(t, configResp1.GetDeviceAuthenticationMode(), pb.GetConfigurationResponse_PRE_SHARED_KEY) + require.Equal(t, pb.GetConfigurationResponse_PRE_SHARED_KEY, configResp1.GetDeviceAuthenticationMode()) } func setupClientApplicationForPSKInitialization(t *testing.T) func() { @@ -85,12 +92,14 @@ func setupClientApplicationForPSKInitialization(t *testing.T) func() { func doSimpleOwn(t *testing.T, deviceID string, expCode int) { request := httpgwTest.NewRequest(http.MethodPost, serviceHttp.OwnDevice, nil).Host(test.CLIENT_APPLICATION_HTTP_HOST).DeviceId(deviceID).Build() resp := httpgwTest.HTTPDo(t, request) + _ = resp.Body.Close() require.Equal(t, expCode, resp.StatusCode) } func doDisown(t *testing.T, deviceID string, expCode int) { request := httpgwTest.NewRequest(http.MethodPost, serviceHttp.DisownDevice, nil).Host(test.CLIENT_APPLICATION_HTTP_HOST).DeviceId(deviceID).Build() resp := httpgwTest.HTTPDo(t, request) + _ = resp.Body.Close() require.Equal(t, expCode, resp.StatusCode) } diff --git a/service/http/remoteInitialize_test.go b/service/http/remoteInitialize_test.go index cde1930e..5ff33417 100644 --- a/service/http/remoteInitialize_test.go +++ b/service/http/remoteInitialize_test.go @@ -62,6 +62,9 @@ func encodeToBody(t *testing.T, v protoreflect.ProtoMessage) io.Reader { func initializeRemoteProvisioning(ctx context.Context, t *testing.T) { request := httpgwTest.NewRequest(http.MethodGet, serviceHttp.WellKnownConfiguration, nil).Host(test.CLIENT_APPLICATION_HTTP_HOST).Build() resp := httpgwTest.HTTPDo(t, request) + defer func(r *http.Response) { + _ = r.Body.Close() + }(resp) require.Equal(t, http.StatusOK, resp.StatusCode) configRespBody, err := io.ReadAll(resp.Body) require.NoError(t, err) @@ -69,12 +72,15 @@ func initializeRemoteProvisioning(ctx context.Context, t *testing.T) { err = protojson.Unmarshal(configRespBody, &configResp) require.NoError(t, err) require.False(t, configResp.GetIsInitialized()) - require.Equal(t, configResp.GetOwner(), "") - require.Equal(t, configResp.GetDeviceAuthenticationMode(), pb.GetConfigurationResponse_UNINITIALIZED) - require.Equal(t, configResp.GetRemoteProvisioning().GetMode(), pb.RemoteProvisioning_MODE_NONE) + require.Equal(t, "", configResp.GetOwner()) + require.Equal(t, pb.GetConfigurationResponse_UNINITIALIZED, configResp.GetDeviceAuthenticationMode()) + require.Equal(t, pb.RemoteProvisioning_MODE_NONE, configResp.GetRemoteProvisioning().GetMode()) request = httpgwTest.NewRequest(http.MethodGet, serviceHttp.WellKnownJWKs, nil).Host(config.OAUTH_SERVER_HOST).Build() resp = httpgwTest.HTTPDo(t, request) + defer func(r *http.Response) { + _ = r.Body.Close() + }(resp) require.Equal(t, http.StatusOK, resp.StatusCode) var jwks map[string]interface{} @@ -89,6 +95,9 @@ func initializeRemoteProvisioning(ctx context.Context, t *testing.T) { Jwks: pbJwks, })).Host(test.CLIENT_APPLICATION_HTTP_HOST).AuthToken(token).Build() resp = httpgwTest.HTTPDo(t, request) + defer func(r *http.Response) { + _ = r.Body.Close() + }(resp) require.Equal(t, http.StatusOK, resp.StatusCode) var challengeResp pb.InitializeResponse @@ -102,10 +111,16 @@ func initializeRemoteProvisioning(ctx context.Context, t *testing.T) { Certificate: certificate, })).Host(test.CLIENT_APPLICATION_HTTP_HOST).AuthToken(token).Build() resp = httpgwTest.HTTPDo(t, request) + defer func(r *http.Response) { + _ = r.Body.Close() + }(resp) require.Equal(t, http.StatusOK, resp.StatusCode) request = httpgwTest.NewRequest(http.MethodGet, serviceHttp.WellKnownConfiguration, nil).Host(test.CLIENT_APPLICATION_HTTP_HOST).Build() resp = httpgwTest.HTTPDo(t, request) + defer func(r *http.Response) { + _ = r.Body.Close() + }(resp) require.Equal(t, http.StatusOK, resp.StatusCode) configRespBody, err = io.ReadAll(resp.Body) require.NoError(t, err) @@ -113,12 +128,15 @@ func initializeRemoteProvisioning(ctx context.Context, t *testing.T) { err = protojson.Unmarshal(configRespBody, &configResp) require.NoError(t, err) require.True(t, configResp.GetIsInitialized()) - require.Equal(t, configResp.GetOwner(), "1") - require.Equal(t, configResp.GetDeviceAuthenticationMode(), pb.GetConfigurationResponse_X509) - require.Equal(t, configResp.GetRemoteProvisioning().GetMode(), pb.RemoteProvisioning_USER_AGENT) + require.Equal(t, "1", configResp.GetOwner()) + require.Equal(t, pb.GetConfigurationResponse_X509, configResp.GetDeviceAuthenticationMode()) + require.Equal(t, pb.RemoteProvisioning_USER_AGENT, configResp.GetRemoteProvisioning().GetMode()) request = httpgwTest.NewRequest(http.MethodGet, serviceHttp.IdentityCertificate, nil).Host(test.CLIENT_APPLICATION_HTTP_HOST).AuthToken(token).Build() resp = httpgwTest.HTTPDo(t, request) + defer func(r *http.Response) { + _ = r.Body.Close() + }(resp) require.Equal(t, http.StatusOK, resp.StatusCode) } @@ -146,7 +164,7 @@ func setupRemoteProvisioning(t *testing.T, services ...hubTestService.SetUpServi } func signCSR(ctx context.Context, t *testing.T, csr []byte) []byte { - conn, err := grpc.Dial(config.CERTIFICATE_AUTHORITY_HOST, grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{ + conn, err := grpc.NewClient(config.CERTIFICATE_AUTHORITY_HOST, grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{ RootCAs: hubTest.GetRootCertificatePool(t), MinVersion: tls.VersionTLS12, }))) @@ -160,7 +178,7 @@ func signCSR(ctx context.Context, t *testing.T, csr []byte) []byte { CertificateSigningRequest: csr, }) require.NoError(t, err) - return signResp.Certificate + return signResp.GetCertificate() } func TestClientApplicationServerUpdateIdentityCertificate(t *testing.T) { @@ -178,6 +196,9 @@ func TestClientApplicationServerUpdateIdentityCertificate(t *testing.T) { request := httpgwTest.NewRequest(http.MethodGet, serviceHttp.WellKnownConfiguration, nil).Host(test.CLIENT_APPLICATION_HTTP_HOST).Build() resp := httpgwTest.HTTPDo(t, request) + defer func(r *http.Response) { + _ = r.Body.Close() + }(resp) require.Equal(t, http.StatusOK, resp.StatusCode) configRespBody, err := io.ReadAll(resp.Body) require.NoError(t, err) @@ -185,12 +206,15 @@ func TestClientApplicationServerUpdateIdentityCertificate(t *testing.T) { err = protojson.Unmarshal(configRespBody, &configResp) require.NoError(t, err) require.False(t, configResp.GetIsInitialized()) - require.Equal(t, configResp.GetOwner(), "") - require.Equal(t, configResp.GetDeviceAuthenticationMode(), pb.GetConfigurationResponse_X509) - require.Equal(t, configResp.GetRemoteProvisioning().GetMode(), pb.RemoteProvisioning_USER_AGENT) + require.Equal(t, "", configResp.GetOwner()) + require.Equal(t, pb.GetConfigurationResponse_X509, configResp.GetDeviceAuthenticationMode()) + require.Equal(t, pb.RemoteProvisioning_USER_AGENT, configResp.GetRemoteProvisioning().GetMode()) request = httpgwTest.NewRequest(http.MethodGet, serviceHttp.WellKnownJWKs, nil).Host(config.OAUTH_SERVER_HOST).Build() resp = httpgwTest.HTTPDo(t, request) + defer func(r *http.Response) { + _ = r.Body.Close() + }(resp) require.Equal(t, http.StatusOK, resp.StatusCode) var jwks map[string]interface{} @@ -205,6 +229,9 @@ func TestClientApplicationServerUpdateIdentityCertificate(t *testing.T) { Jwks: pbJwks, })).Host(test.CLIENT_APPLICATION_HTTP_HOST).AuthToken(token).Build() resp = httpgwTest.HTTPDo(t, request) + defer func(r *http.Response) { + _ = r.Body.Close() + }(resp) require.Equal(t, http.StatusOK, resp.StatusCode) var challengeResp pb.InitializeResponse decodeBody(t, resp.Body, &challengeResp) @@ -213,6 +240,9 @@ func TestClientApplicationServerUpdateIdentityCertificate(t *testing.T) { request = httpgwTest.NewRequest(http.MethodGet, serviceHttp.IdentityCertificate, nil).Host(test.CLIENT_APPLICATION_HTTP_HOST).AuthToken(token).Build() resp = httpgwTest.HTTPDo(t, request) + defer func(r *http.Response) { + _ = r.Body.Close() + }(resp) require.Equal(t, http.StatusServiceUnavailable, resp.StatusCode) ctx = kitNetGrpc.CtxWithToken(ctx, token) @@ -221,23 +251,32 @@ func TestClientApplicationServerUpdateIdentityCertificate(t *testing.T) { Certificate: certificate, })).Host(test.CLIENT_APPLICATION_HTTP_HOST).AuthToken(token).Build() resp = httpgwTest.HTTPDo(t, request) + defer func(r *http.Response) { + _ = r.Body.Close() + }(resp) require.Equal(t, http.StatusOK, resp.StatusCode) request = httpgwTest.NewRequest(http.MethodGet, serviceHttp.IdentityCertificate, nil).Host(test.CLIENT_APPLICATION_HTTP_HOST).AuthToken(token).Build() resp = httpgwTest.HTTPDo(t, request) + defer func(r *http.Response) { + _ = r.Body.Close() + }(resp) require.Equal(t, http.StatusOK, resp.StatusCode) var clientCertificate pb.GetIdentityCertificateResponse decodeBody(t, resp.Body, &clientCertificate) - require.Equal(t, certificate, clientCertificate.Certificate) + require.Equal(t, certificate, clientCertificate.GetCertificate()) request = httpgwTest.NewRequest(http.MethodGet, serviceHttp.WellKnownConfiguration, nil).Host(test.CLIENT_APPLICATION_HTTP_HOST).Build() resp = httpgwTest.HTTPDo(t, request) + defer func(r *http.Response) { + _ = r.Body.Close() + }(resp) require.Equal(t, http.StatusOK, resp.StatusCode) configRespBody, err = io.ReadAll(resp.Body) require.NoError(t, err) err = protojson.Unmarshal(configRespBody, &configResp) require.NoError(t, err) require.True(t, configResp.GetIsInitialized()) - require.Equal(t, configResp.GetOwner(), "1") + require.Equal(t, "1", configResp.GetOwner()) } diff --git a/service/http/reset_test.go b/service/http/reset_test.go index fe4eeb0a..de6e9bfb 100644 --- a/service/http/reset_test.go +++ b/service/http/reset_test.go @@ -37,10 +37,16 @@ func doReset(t *testing.T, token string, expCode int) { request := httpgwTest.NewRequest(http.MethodPost, serviceHttp.Reset, nil). Host(test.CLIENT_APPLICATION_HTTP_HOST).AuthToken(token).Build() resp := httpgwTest.HTTPDo(t, request) + defer func(r *http.Response) { + _ = r.Body.Close() + }(resp) require.Equal(t, expCode, resp.StatusCode) if resp.StatusCode == http.StatusOK { request = httpgwTest.NewRequest(http.MethodGet, serviceHttp.WellKnownConfiguration, nil).Host(test.CLIENT_APPLICATION_HTTP_HOST).Build() resp = httpgwTest.HTTPDo(t, request) + defer func(r *http.Response) { + _ = r.Body.Close() + }(resp) require.Equal(t, http.StatusOK, resp.StatusCode) configRespBody, err := io.ReadAll(resp.Body) require.NoError(t, err) @@ -48,9 +54,9 @@ func doReset(t *testing.T, token string, expCode int) { err = protojson.Unmarshal(configRespBody, &configResp) require.NoError(t, err) require.False(t, configResp.GetIsInitialized()) - require.Equal(t, configResp.GetOwner(), "") - require.Equal(t, configResp.GetDeviceAuthenticationMode(), pb.GetConfigurationResponse_UNINITIALIZED) - require.Equal(t, configResp.GetRemoteProvisioning().GetMode(), pb.RemoteProvisioning_MODE_NONE) + require.Equal(t, "", configResp.GetOwner()) + require.Equal(t, pb.GetConfigurationResponse_UNINITIALIZED, configResp.GetDeviceAuthenticationMode()) + require.Equal(t, pb.RemoteProvisioning_MODE_NONE, configResp.GetRemoteProvisioning().GetMode()) } } diff --git a/service/http/service.go b/service/http/service.go index 9ed891e0..106ad645 100644 --- a/service/http/service.go +++ b/service/http/service.go @@ -129,9 +129,8 @@ func newListener(config configHttp.Config, fileWatcher *fsnotify.Watcher, logger Addr: config.Config.Addr, TLS: config.Config.TLS.Config, }, fileWatcher, logger) - } else { - return listener.New(config.Config, fileWatcher, logger) } + return listener.New(config.Config, fileWatcher, logger) } func wrapHandler(handler http.Handler, serviceName string, tracerProvider trace.TracerProvider) http.Handler { @@ -213,7 +212,7 @@ func New(ctx context.Context, serviceName string, config configHttp.Config, clie handler := newCORSHandler(config, r) // register grpc-proxy handler - if err := pb.RegisterClientApplicationHandlerClient(context.Background(), mux, grpcClient); err != nil { + if err := pb.RegisterClientApplicationHandlerClient(ctx, mux, grpcClient); err != nil { _ = lis.Close() return nil, fmt.Errorf("failed to register grpc-gateway handler: %w", err) } diff --git a/service/http/updateResource_test.go b/service/http/updateResource_test.go index 0e679e4b..1277a07c 100644 --- a/service/http/updateResource_test.go +++ b/service/http/updateResource_test.go @@ -60,7 +60,7 @@ func TestClientApplicationServerUpdateResource(t *testing.T) { name: "doxm update", args: args{ accept: serviceHttp.ApplicationProtoJsonContentType, - deviceID: dev.Id, + deviceID: dev.GetId(), href: doxm.ResourceURI, contentType: serviceHttp.ApplicationJsonContentType, body: bytes.NewReader([]byte(`{"oxmsel":0}`)), @@ -78,7 +78,7 @@ func TestClientApplicationServerUpdateResource(t *testing.T) { name: "device resource", args: args{ accept: serviceHttp.ApplicationProtoJsonContentType, - deviceID: dev.Id, + deviceID: dev.GetId(), href: device.ResourceURI, contentType: serviceHttp.ApplicationJsonContentType, body: bytes.NewReader([]byte(`{"oxmsel":0}`)), @@ -100,7 +100,7 @@ func TestClientApplicationServerUpdateResource(t *testing.T) { { name: "unknown href", args: args{ - deviceID: dev.Id, + deviceID: dev.GetId(), href: "/unknown", contentType: serviceHttp.ApplicationJsonContentType, body: bytes.NewReader([]byte(`{"oxmsel":0}`)), @@ -111,7 +111,7 @@ func TestClientApplicationServerUpdateResource(t *testing.T) { { name: "forbidden - cannot establish TLS connection", args: args{ - deviceID: dev.Id, + deviceID: dev.GetId(), href: configuration.ResourceURI, contentType: serviceHttp.ApplicationJsonContentType, body: bytes.NewReader([]byte(`{"oxmsel":0}`)), diff --git a/service/service.go b/service/service.go index 20895c88..9bec008a 100644 --- a/service/service.go +++ b/service/service.go @@ -52,8 +52,8 @@ func newHttpService(ctx context.Context, config config.Config, clientApplication return httpService, err } -func newGrpcService(ctx context.Context, config config.Config, clientApplicationServer *grpc.ClientApplicationServer, fileWatcher *fsnotify.Watcher, logger log.Logger, tracerProvider trace.TracerProvider) (*grpc.Service, error) { - grpcService, err := grpc.New(ctx, serviceName, config.APIs.GRPC.Config, clientApplicationServer, fileWatcher, logger, tracerProvider) +func newGrpcService(config config.Config, clientApplicationServer *grpc.ClientApplicationServer, fileWatcher *fsnotify.Watcher, logger log.Logger, tracerProvider trace.TracerProvider) (*grpc.Service, error) { + grpcService, err := grpc.New(config.APIs.GRPC.Config, clientApplicationServer, fileWatcher, logger, tracerProvider) if err != nil { return nil, err } @@ -115,7 +115,7 @@ func New(ctx context.Context, cfg config.Config, info *configGrpc.ServiceInforma services = append(services, httpService) } if cfg.APIs.GRPC.Enabled { - grpcService, err := newGrpcService(ctx, cfg, clientApplicationServer, fileWatcher, logger, tracerProvider) + grpcService, err := newGrpcService(cfg, clientApplicationServer, fileWatcher, logger, tracerProvider) if err != nil { closerFunc.Execute() return nil, closeServicesOnError(fmt.Errorf("cannot create grpc service: %w", err), services) diff --git a/test/test.go b/test/test.go index 7d33f8cc..ea6fc22c 100644 --- a/test/test.go +++ b/test/test.go @@ -25,7 +25,6 @@ import ( "testing" "time" - _ "cloud.google.com/go" "github.com/plgd-dev/client-application/pb" "github.com/plgd-dev/client-application/pkg/net/grpc/server" "github.com/plgd-dev/client-application/pkg/net/listener"