From 0ef224e8f98d6507177643240ae71b9d90d86aef Mon Sep 17 00:00:00 2001 From: Cenk Alti Date: Thu, 2 Jan 2014 19:14:07 +0200 Subject: [PATCH] refactor test code --- rs256_test.go | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/rs256_test.go b/rs256_test.go index dad1caf..2d79214 100644 --- a/rs256_test.go +++ b/rs256_test.go @@ -1,9 +1,7 @@ package jwt import ( - "bytes" - "io" - "os" + "io/ioutil" "strings" "testing" ) @@ -29,11 +27,7 @@ var rsaTestData = []struct { } func TestRS256Verify(t *testing.T) { - file, _ := os.Open("test/sample_key.pub") - buf := new(bytes.Buffer) - io.Copy(buf, file) - key := buf.Bytes() - file.Close() + key, _ := ioutil.ReadFile("test/sample_key.pub") for _, data := range rsaTestData { parts := strings.Split(data.tokenString, ".") @@ -50,11 +44,7 @@ func TestRS256Verify(t *testing.T) { } func TestRS256Sign(t *testing.T) { - file, _ := os.Open("test/sample_key") - buf := new(bytes.Buffer) - io.Copy(buf, file) - key := buf.Bytes() - file.Close() + key, _ := ioutil.ReadFile("test/sample_key") for _, data := range rsaTestData { if data.valid {