Skip to content

Commit

Permalink
Remove UnmarshalJSON as this is no longer necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
lestrrat committed Apr 27, 2019
1 parent 5603d7e commit 0062e54
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 25 deletions.
6 changes: 0 additions & 6 deletions jwt/internal/types/date.go
Expand Up @@ -81,9 +81,3 @@ func (n *NumericDate) MarshalJSON() ([]byte, error) {
}
return json.Marshal(n.Unix())
}

// UnmarshalJSON translates between JSON NumericDate and internal representation
// See https://tools.ietf.org/html/rfc7519#page-6
func (n *NumericDate) UnmarshalJSON(b []byte) error {
return n.Accept(string(b[:]))
}
19 changes: 0 additions & 19 deletions jwt/internal/types/date_test.go
Expand Up @@ -4,13 +4,10 @@ import (
"encoding/json"
"fmt"
"reflect"
"strings"
"testing"
"time"

"github.com/lestrrat-go/jwx/jwt"
"github.com/lestrrat-go/jwx/jwt/internal/types"
"github.com/stretchr/testify/assert"
)

func TestDate(t *testing.T) {
Expand All @@ -37,20 +34,4 @@ func TestDate(t *testing.T) {
})
}
})

for _, useNumber := range []bool{true, false} {
t.Run(fmt.Sprintf("Decoding with json.NewDecoder() (UseNumber=%t)", useNumber), func(t *testing.T) {
buf := strings.NewReader("127")
dec := json.NewDecoder(buf)
if useNumber {
dec.UseNumber()
}

var nd types.NumericDate
if !assert.NoError(t, dec.Decode(&nd), `Decode should succeed`) {
return
}
t.Logf("%s", nd)
})
}
}

0 comments on commit 0062e54

Please sign in to comment.