File: device_authorization_test.go

package info (click to toggle)
golang-github-zitadel-oidc 3.37.0-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, sid, trixie
  • size: 1,484 kB
  • sloc: makefile: 5
file content (30 lines) | stat: -rw-r--r-- 658 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package oidc

import (
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestDeviceAuthorizationResponse_UnmarshalJSON(t *testing.T) {
	jsonStr := `{
		"device_code": "deviceCode",
		"user_code": "userCode",
		"verification_url": "http://example.com/verify",
		"expires_in": 3600,
		"interval": 5
	}`

	expected := &DeviceAuthorizationResponse{
		DeviceCode:      "deviceCode",
		UserCode:        "userCode",
		VerificationURI: "http://example.com/verify",
		ExpiresIn:       3600,
		Interval:        5,
	}

	var resp DeviceAuthorizationResponse
	err := resp.UnmarshalJSON([]byte(jsonStr))
	assert.NoError(t, err)
	assert.Equal(t, expected, &resp)
}