forked from mirror/jwt
refactor test code
This commit is contained in:
parent
f4c00c0ac2
commit
0ef224e8f9
|
@ -1,9 +1,7 @@
|
||||||
package jwt
|
package jwt
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"io/ioutil"
|
||||||
"io"
|
|
||||||
"os"
|
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
@ -29,11 +27,7 @@ var rsaTestData = []struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRS256Verify(t *testing.T) {
|
func TestRS256Verify(t *testing.T) {
|
||||||
file, _ := os.Open("test/sample_key.pub")
|
key, _ := ioutil.ReadFile("test/sample_key.pub")
|
||||||
buf := new(bytes.Buffer)
|
|
||||||
io.Copy(buf, file)
|
|
||||||
key := buf.Bytes()
|
|
||||||
file.Close()
|
|
||||||
|
|
||||||
for _, data := range rsaTestData {
|
for _, data := range rsaTestData {
|
||||||
parts := strings.Split(data.tokenString, ".")
|
parts := strings.Split(data.tokenString, ".")
|
||||||
|
@ -50,11 +44,7 @@ func TestRS256Verify(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRS256Sign(t *testing.T) {
|
func TestRS256Sign(t *testing.T) {
|
||||||
file, _ := os.Open("test/sample_key")
|
key, _ := ioutil.ReadFile("test/sample_key")
|
||||||
buf := new(bytes.Buffer)
|
|
||||||
io.Copy(buf, file)
|
|
||||||
key := buf.Bytes()
|
|
||||||
file.Close()
|
|
||||||
|
|
||||||
for _, data := range rsaTestData {
|
for _, data := range rsaTestData {
|
||||||
if data.valid {
|
if data.valid {
|
||||||
|
|
Loading…
Reference in New Issue