-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #158 from nats-io/go-mod-fixes
Separate test deps from v2 module
- Loading branch information
Showing
7 changed files
with
132 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,5 @@ | ||
module github.com/nats-io/jwt/v2 | ||
|
||
require ( | ||
github.com/nats-io/jwt v1.2.2 | ||
github.com/nats-io/nkeys v0.3.0 | ||
) | ||
go 1.16 | ||
|
||
replace github.com/nats-io/jwt v1.2.2 => ../ | ||
|
||
go 1.14 | ||
require github.com/nats-io/nkeys v0.3.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module github.com/nats-io/jwt/v2 | ||
|
||
go 1.16 | ||
|
||
require ( | ||
github.com/nats-io/jwt v1.2.2 | ||
github.com/nats-io/nkeys v0.3.0 | ||
) | ||
|
||
replace github.com/nats-io/jwt v1.2.2 => ../ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
github.com/nats-io/nkeys v0.3.0 h1:cgM5tL53EvYRU+2YLXIK0G2mJtK12Ft9oeooSZMA2G8= | ||
github.com/nats-io/nkeys v0.3.0/go.mod h1:gvUNGjVcM2IPr5rCsRsC6Wb3Hr2CQAm08dsxtV6A5y4= | ||
golang.org/x/crypto v0.0.0-20210314154223-e6e6c4f2bb5b h1:wSOdpTq0/eI46Ez/LkDwIsAKA71YP2SRKBODiRWM0as= | ||
golang.org/x/crypto v0.0.0-20210314154223-e6e6c4f2bb5b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= | ||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= | ||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= | ||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= | ||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ import ( | |
"testing" | ||
"time" | ||
|
||
. "github.com/nats-io/jwt/v2" | ||
jwtv1 "github.com/nats-io/jwt" | ||
) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/* | ||
* Copyright 2018-2021 The NATS Authors | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package jwt | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"runtime" | ||
"strings" | ||
"testing" | ||
|
||
. "github.com/nats-io/jwt/v2" | ||
"github.com/nats-io/nkeys" | ||
) | ||
|
||
func Trace(message string) string { | ||
lines := make([]string, 0, 32) | ||
err := errors.New(message) | ||
msg := err.Error() | ||
lines = append(lines, msg) | ||
|
||
for i := 2; true; i++ { | ||
_, file, line, ok := runtime.Caller(i) | ||
if !ok { | ||
break | ||
} | ||
msg := fmt.Sprintf("%s:%d", file, line) | ||
lines = append(lines, msg) | ||
} | ||
return strings.Join(lines, "\n") | ||
} | ||
|
||
func AssertEquals(expected, v interface{}, t *testing.T) { | ||
if expected != v { | ||
t.Fatalf("%v", Trace(fmt.Sprintf("The expected value %v != %v", expected, v))) | ||
} | ||
} | ||
|
||
func AssertNil(v interface{}, t *testing.T) { | ||
if v != nil { | ||
t.FailNow() | ||
} | ||
} | ||
|
||
func AssertNoError(err error, t *testing.T) { | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
} | ||
|
||
func AssertTrue(condition bool, t *testing.T) { | ||
if !condition { | ||
t.FailNow() | ||
} | ||
} | ||
|
||
func AssertFalse(condition bool, t *testing.T) { | ||
if condition { | ||
t.FailNow() | ||
} | ||
} | ||
|
||
func createAccountNKey(t *testing.T) nkeys.KeyPair { | ||
kp, err := nkeys.CreateAccount() | ||
if err != nil { | ||
t.Fatal("error creating account kp", err) | ||
} | ||
return kp | ||
} | ||
|
||
func createOperatorNKey(t *testing.T) nkeys.KeyPair { | ||
kp, err := nkeys.CreateOperator() | ||
if err != nil { | ||
t.Fatal("error creating operator kp", err) | ||
} | ||
return kp | ||
} | ||
|
||
func publicKey(kp nkeys.KeyPair, t *testing.T) string { | ||
pk, err := kp.PublicKey() | ||
if err != nil { | ||
t.Fatal("error reading public key", err) | ||
} | ||
return pk | ||
} | ||
|
||
func encode(c Claims, kp nkeys.KeyPair, t *testing.T) string { | ||
s, err := c.Encode(kp) | ||
if err != nil { | ||
t.Fatal("error encoding claim", err) | ||
} | ||
return s | ||
} |