Skip to content

Commit

Permalink
Merge pull request #98 from nats-io/nas-jwt
Browse files Browse the repository at this point in the history
jwt update and deprecation fixes
  • Loading branch information
aricart committed Apr 18, 2023
2 parents e7fbf2b + eee41bc commit 69cb476
Show file tree
Hide file tree
Showing 18 changed files with 120 additions and 441 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/go-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ jobs:
test:
strategy:
matrix:
go: [1.17]
go: [1.19.x]

runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Setup Go
uses: actions/setup-go@v3
Expand Down
21 changes: 10 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
module github.com/nats-io/nats-account-server

go 1.17
go 1.19

require (
github.com/julienschmidt/httprouter v1.3.0
github.com/mitchellh/go-homedir v1.1.0
github.com/nats-io/jwt v1.2.2
github.com/nats-io/jwt/v2 v2.2.1-0.20220113022732-58e87895b296
github.com/nats-io/nats-server/v2 v2.7.4
github.com/nats-io/nats.go v1.13.1-0.20220308171302-2f2f6968e98d
github.com/nats-io/nkeys v0.3.0
github.com/rs/cors v1.8.2
github.com/nats-io/jwt/v2 v2.4.0
github.com/nats-io/nats-server/v2 v2.9.15
github.com/nats-io/nats.go v1.24.0
github.com/nats-io/nkeys v0.4.4
github.com/rs/cors v1.8.3
github.com/stretchr/testify v1.7.0
golang.org/x/sys v0.0.0-20220318055525-2edf467146b5
golang.org/x/sys v0.6.0
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/klauspost/compress v1.15.1 // indirect
github.com/klauspost/compress v1.16.3 // indirect
github.com/minio/highwayhash v1.0.2 // indirect
github.com/nats-io/nuid v1.0.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd // indirect
golang.org/x/time v0.0.0-20220224211638-0e9765cccd65 // indirect
golang.org/x/crypto v0.7.0 // indirect
golang.org/x/time v0.3.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
)
75 changes: 18 additions & 57 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,79 +1,40 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
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/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0=
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U=
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
github.com/klauspost/compress v1.14.4/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/klauspost/compress v1.15.1 h1:y9FcTHGyrebwfP0ZZqFiaxTaiDnUrGkJkI+f583BL1A=
github.com/klauspost/compress v1.15.1/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/klauspost/compress v1.16.3 h1:XuJt9zzcnaz6a16/OU53ZjWp/v7/42WcR5t2a0PcNQY=
github.com/klauspost/compress v1.16.3/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
github.com/minio/highwayhash v1.0.2 h1:Aak5U0nElisjDCfPSG79Tgzkn2gl66NxOMspRrKnA/g=
github.com/minio/highwayhash v1.0.2/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/nats-io/jwt v1.2.2 h1:w3GMTO969dFg+UOKTmmyuu7IGdusK+7Ytlt//OYH/uU=
github.com/nats-io/jwt v1.2.2/go.mod h1:/xX356yQA6LuXI9xWW7mZNpxgF2mBmGecH+Fj34sP5Q=
github.com/nats-io/jwt/v2 v2.2.1-0.20220113022732-58e87895b296 h1:vU9tpM3apjYlLLeY23zRWJ9Zktr5jp+mloR942LEOpY=
github.com/nats-io/jwt/v2 v2.2.1-0.20220113022732-58e87895b296/go.mod h1:0tqz9Hlu6bCBFLWAASKhE5vUA4c24L9KPUUgvwumE/k=
github.com/nats-io/nats-server/v2 v2.7.4 h1:c+BZJ3rGzUKCBIM4IXO8uNT2u1vajGbD1kPA6wqCEaM=
github.com/nats-io/nats-server/v2 v2.7.4/go.mod h1:1vZ2Nijh8tcyNe8BDVyTviCd9NYzRbubQYiEHsvOQWc=
github.com/nats-io/nats.go v1.13.1-0.20220308171302-2f2f6968e98d h1:zJf4l8Kp67RIZhoVeniSLZs69SHNgjLHz0aNsqPPlx8=
github.com/nats-io/nats.go v1.13.1-0.20220308171302-2f2f6968e98d/go.mod h1:BPko4oXsySz4aSWeFgOHLZs3G4Jq4ZAyE6/zMCxRT6w=
github.com/nats-io/nkeys v0.2.0/go.mod h1:XdZpAbhgyyODYqjTawOnIOI7VlbKSarI9Gfy1tqEu/s=
github.com/nats-io/nkeys v0.3.0 h1:cgM5tL53EvYRU+2YLXIK0G2mJtK12Ft9oeooSZMA2G8=
github.com/nats-io/nkeys v0.3.0/go.mod h1:gvUNGjVcM2IPr5rCsRsC6Wb3Hr2CQAm08dsxtV6A5y4=
github.com/nats-io/jwt/v2 v2.4.0 h1:1woVcq37qhNwJOeZ4ZoRy5NJU5bvbtGsIammf2GpuJQ=
github.com/nats-io/jwt/v2 v2.4.0/go.mod h1:24BeQtRwxRV8ruvC4CojXlx/WQ/VjuwlYiH+vu/+ibI=
github.com/nats-io/nats-server/v2 v2.9.15 h1:MuwEJheIwpvFgqvbs20W8Ish2azcygjf4Z0liVu2I4c=
github.com/nats-io/nats-server/v2 v2.9.15/go.mod h1:QlCTy115fqpx4KSOPFIxSV7DdI6OxtZsGOL1JLdeRlE=
github.com/nats-io/nats.go v1.24.0 h1:CRiD8L5GOQu/DcfkmgBcTTIQORMwizF+rPk6T0RaHVQ=
github.com/nats-io/nats.go v1.24.0/go.mod h1:dVQF+BK3SzUZpwyzHedXsvH3EO38aVKuOPkkHlv5hXA=
github.com/nats-io/nkeys v0.4.4 h1:xvBJ8d69TznjcQl9t6//Q5xXuVhyYiSos6RPtvQNTwA=
github.com/nats-io/nkeys v0.4.4/go.mod h1:XUkxdLPTufzlihbamfzQ7mw/VGx6ObUs+0bN5sNvt64=
github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw=
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rs/cors v1.8.2 h1:KCooALfAYGs415Cwu5ABvv9n9509fSiG5SQJn/AQo4U=
github.com/rs/cors v1.8.2/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU=
github.com/rs/cors v1.8.3 h1:O+qNyWn7Z+F9M0ILBHgMVPuB1xTOucVd5gtaYyXBpRo=
github.com/rs/cors v1.8.3/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210314154223-e6e6c4f2bb5b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd h1:XcWmESyNjXJMLahc3mqVQJcgSTDxFxhETVlfk9uGc38=
golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A=
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
golang.org/x/sys v0.0.0-20190130150945-aca44879d564/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220111092808-5a964db01320/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220318055525-2edf467146b5 h1:saXMvIOKvRFwbOMicHXr0B1uwoxq9dGmLe5ExMES6c4=
golang.org/x/sys v0.0.0-20220318055525-2edf467146b5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/time v0.0.0-20211116232009-f0f3c7e86c11/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20220224211638-0e9765cccd65 h1:M73Iuj3xbbb9Uk1DYhzydthsj6oOd6l9bpuFcNoUvTs=
golang.org/x/time v0.0.0-20220224211638-0e9765cccd65/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4=
golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM=
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
Expand Down
4 changes: 2 additions & 2 deletions server/conf/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package conf

import (
"fmt"
"io/ioutil"
"os"

"github.com/nats-io/nats-server/v2/conf"
)
Expand All @@ -28,7 +28,7 @@ import (
// otherwise, the fields in the config struct will act as defaults if the file doesn't contain them
// Strict will also force an error if the struct contains any fields which are not settable with reflection
func LoadConfigFromFile(configFile string, configStruct interface{}, strict bool) error {
configString, err := ioutil.ReadFile(configFile)
configString, err := os.ReadFile(configFile)
if err != nil {
return fmt.Errorf("error reading configuration file: %s", err.Error())
}
Expand Down
5 changes: 2 additions & 3 deletions server/conf/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package conf

import (
"io/ioutil"
"os"
"testing"

Expand Down Expand Up @@ -62,7 +61,7 @@ func TestLoadFromBadString(t *testing.T) {
}

func TestLoadFromFile(t *testing.T) {
file, err := ioutil.TempFile(os.TempDir(), "prefix")
file, err := os.CreateTemp(os.TempDir(), "prefix")
require.NoError(t, err)

configString := `
Expand All @@ -75,7 +74,7 @@ func TestLoadFromFile(t *testing.T) {
fullPath, err := ValidateFilePath(file.Name())
require.NoError(t, err)

err = ioutil.WriteFile(fullPath, []byte(configString), 0644)
err = os.WriteFile(fullPath, []byte(configString), 0644)
require.NoError(t, err)

config := SimpleConf{}
Expand Down
7 changes: 3 additions & 4 deletions server/conf/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package conf

import (
"io/ioutil"
"os"
"path/filepath"
"testing"
Expand All @@ -26,7 +25,7 @@ import (
)

func TestFilePath(t *testing.T) {
file, err := ioutil.TempFile(os.TempDir(), "prefix")
file, err := os.CreateTemp(os.TempDir(), "prefix")
require.NoError(t, err)

path, err := ValidateFilePath(file.Name())
Expand All @@ -38,7 +37,7 @@ func TestFilePath(t *testing.T) {
}

func TestDirPath(t *testing.T) {
path, err := ioutil.TempDir(os.TempDir(), "prefix")
path, err := os.MkdirTemp(os.TempDir(), "prefix")
require.NoError(t, err)

abspath, err := ValidateDirPath(path)
Expand All @@ -50,7 +49,7 @@ func TestDirPath(t *testing.T) {
}

func TestPathDoesntExist(t *testing.T) {
path, err := ioutil.TempDir(os.TempDir(), "prefix")
path, err := os.MkdirTemp(os.TempDir(), "prefix")
require.NoError(t, err)

path = filepath.Join(path, "foo")
Expand Down
4 changes: 2 additions & 2 deletions server/core/handlers_accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package core

import (
"fmt"
"io/ioutil"
"io"
"net/http"
"strings"
"time"
Expand Down Expand Up @@ -47,7 +47,7 @@ func (h *JwtHandler) loadAccountJWT(publicKey string) (bool, *jwt.AccountClaims)
// Sends a nats notification
func (h *JwtHandler) UpdateAccountJWT(w http.ResponseWriter, r *http.Request, params httprouter.Params) {
h.logger.Tracef("%s: %s", r.RemoteAddr, r.URL.String())
theJWT, err := ioutil.ReadAll(r.Body)
theJWT, err := io.ReadAll(r.Body)
defer r.Body.Close()
if err != nil {
h.sendErrorResponse(http.StatusBadRequest, "bad JWT in request", "", err, w)
Expand Down
24 changes: 12 additions & 12 deletions server/core/handlers_accounts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ package core
import (
"bytes"
"fmt"
"io/ioutil"
"io"
"net/http"
"strings"
"sync"
"testing"
"time"

jwtv1 "github.com/nats-io/jwt"
"github.com/nats-io/jwt/v2"
jwtv1 "github.com/nats-io/jwt/v2/v1compat"
"github.com/nats-io/nats-account-server/server/conf"
nats "github.com/nats-io/nats.go"
"github.com/nats-io/nkeys"
Expand Down Expand Up @@ -143,7 +143,7 @@ func TestUploadGetAccountJWT(t *testing.T) {
resp, err = testEnv.HTTP.Get(url)
require.NoError(t, err)
require.True(t, resp.StatusCode == http.StatusOK)
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
require.NoError(t, err)

savedJWT := string(body)
Expand Down Expand Up @@ -172,7 +172,7 @@ func TestUploadGetAccountJWT(t *testing.T) {
resp, err = testEnv.HTTP.Get(url)
require.NoError(t, err)
require.True(t, resp.StatusCode == http.StatusOK)
body, err = ioutil.ReadAll(resp.Body)
body, err = io.ReadAll(resp.Body)
require.NoError(t, err)
require.True(t, strings.HasPrefix(string(body), "eyJ0eXAiOiJKV1QiLCJhbGciOiJlZDI1NTE5LW5rZXkifQ.")) // header prefix doesn't change

Expand All @@ -181,7 +181,7 @@ func TestUploadGetAccountJWT(t *testing.T) {
resp, err = testEnv.HTTP.Get(url)
require.NoError(t, err)
require.True(t, resp.StatusCode == http.StatusOK)
body, err = ioutil.ReadAll(resp.Body)
body, err = io.ReadAll(resp.Body)
require.NoError(t, err)

decoded := string(body)
Expand Down Expand Up @@ -275,7 +275,7 @@ func TestUploadGetAccountJWTV1(t *testing.T) {
resp, err = testEnv.HTTP.Get(url)
require.NoError(t, err)
require.True(t, resp.StatusCode == http.StatusOK)
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
require.NoError(t, err)

savedJWT := string(body)
Expand Down Expand Up @@ -304,7 +304,7 @@ func TestUploadGetAccountJWTV1(t *testing.T) {
resp, err = testEnv.HTTP.Get(url)
require.NoError(t, err)
require.True(t, resp.StatusCode == http.StatusOK)
body, err = ioutil.ReadAll(resp.Body)
body, err = io.ReadAll(resp.Body)
require.NoError(t, err)
require.True(t, strings.HasPrefix(string(body), "eyJ0eXAiOiJqd3QiLCJhbGciOiJlZDI1NTE5In0")) // header prefix doesn't change

Expand All @@ -313,7 +313,7 @@ func TestUploadGetAccountJWTV1(t *testing.T) {
resp, err = testEnv.HTTP.Get(url)
require.NoError(t, err)
require.True(t, resp.StatusCode == http.StatusOK)
body, err = ioutil.ReadAll(resp.Body)
body, err = io.ReadAll(resp.Body)
require.NoError(t, err)

decoded := string(body)
Expand Down Expand Up @@ -382,7 +382,7 @@ func TestExpiredJWT(t *testing.T) {
resp, err = testEnv.HTTP.Post(url, "application/json", bytes.NewBuffer([]byte(acctJWT)))
require.NoError(t, err)
require.True(t, resp.StatusCode == http.StatusBadRequest) // Already expired
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
require.NoError(t, err)
message := string(body)

Expand Down Expand Up @@ -532,7 +532,7 @@ func TestSignAccount(t *testing.T) {
require.True(t, resp.StatusCode == http.StatusOK)

// check if retrieved jwt is what was signed
msg, err := ioutil.ReadAll(resp.Body)
msg, err := io.ReadAll(resp.Body)
require.NoError(t, err)
defer resp.Body.Close()
t.Log(string(msg))
Expand Down Expand Up @@ -577,7 +577,7 @@ func TestSignAccountMultiple(t *testing.T) {
require.True(t, resp.StatusCode == http.StatusOK)

// check if retrieved jwt is what was signed
msg, err := ioutil.ReadAll(resp.Body)
msg, err := io.ReadAll(resp.Body)
require.NoError(t, err)
defer resp.Body.Close()
//t.Log(string(msg))
Expand Down Expand Up @@ -625,7 +625,7 @@ func TestSignAccountDelayed(t *testing.T) {
require.True(t, resp.StatusCode == http.StatusAccepted)

// check if retrieved jwt is what was signed
msg, err := ioutil.ReadAll(resp.Body)
msg, err := io.ReadAll(resp.Body)
require.NoError(t, err)
defer resp.Body.Close()
t.Log(string(msg))
Expand Down
4 changes: 2 additions & 2 deletions server/core/handlers_activations.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package core

import (
"io/ioutil"
"io"
"net/http"
"strings"

Expand All @@ -36,7 +36,7 @@ func (h *JwtHandler) UpdateActivationJWT(w http.ResponseWriter, r *http.Request,
return
}

theJWT, err := ioutil.ReadAll(r.Body)
theJWT, err := io.ReadAll(r.Body)
defer r.Body.Close()
if err != nil {
h.sendErrorResponse(http.StatusBadRequest, "bad activation JWT in request", "", err, w)
Expand Down

0 comments on commit 69cb476

Please sign in to comment.