evcc-io/vehicle/oidc/oidc_test.go
andig 57495de286
Some checks failed
Build / Build (push) Failing after 2m9s
Build / Build UI (push) Failing after 1m46s
Build / Publish :latest (push) Has been skipped
Build / Publish :release (push) Has been skipped
Build / Release (push) Has been skipped
Fix token refresh (#764)
2021-03-15 15:29:14 +01:00

31 lines
528 B
Go

package oidc
import (
"encoding/json"
"testing"
)
func TestUnmarshalJSON(t *testing.T) {
var tok Token
str := `{"access_token":"access","refresh_token":"refresh","token_type":"bearer","expires_in":3600}`
if err := json.Unmarshal([]byte(str), &tok); err != nil {
t.Error(err)
}
if tok.AccessToken != "access" {
t.Error("AccessToken")
}
if tok.RefreshToken != "refresh" {
t.Error("RefreshToken")
}
if tok.TokenType != "bearer" {
t.Error("TokenType")
}
if tok.Expiry.IsZero() {
t.Error("Expiry")
}
}