Commit a81872bd authored by Sietse Ringers's avatar Sietse Ringers
Browse files

Fix timestamp (de)serializing

parent 11cf952d
......@@ -4,6 +4,8 @@ import (
"encoding/json"
"testing"
"time"
"github.com/credentials/irmago"
"github.com/stretchr/testify/require"
)
......@@ -50,6 +52,17 @@ func TestAttributeDisjunctionMarshaling(t *testing.T) {
require.True(t, disjunction.Satisfied())
}
func TestTimestamp(t *testing.T) {
mytime := Timestamp(time.Unix(1500000000, 0))
timestruct := struct{ Time *Timestamp }{Time: &mytime}
bytes, err := json.Marshal(timestruct)
require.NoError(t, err)
timestruct = struct{ Time *Timestamp }{}
require.NoError(t, json.Unmarshal(bytes, &timestruct))
require.Equal(t, time.Time(*timestruct.Time).Unix(), int64(1500000000))
}
func TestServiceProviderRequest(t *testing.T) {
var sprequest ServiceProviderRequest
......
......@@ -44,16 +44,16 @@ type SignatureRequest struct {
}
type CredentialRequest struct {
Validity Timestamp
Validity *Timestamp
KeyCounter int
Credential irmago.CredentialTypeIdentifier
Attributes map[string]string
}
type ServerRequest struct {
ServerName string `json:"iss"`
IssuedAt Timestamp `json:"iat"`
Type string `json:"subject"`
ServerName string `json:"iss"`
IssuedAt *Timestamp `json:"iat"`
Type string `json:"subject"`
}
type IssuanceRequest struct {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment