| 1 |
package oidc |
| 2 |
|
| 3 |
import ( |
| 4 |
"testing" |
| 5 |
|
| 6 |
"github.com/stretchr/testify/assert" |
| 7 |
) |
| 8 |
|
| 9 |
func TestDeviceAuthorizationResponse_UnmarshalJSON(t *testing.T) { |
| 10 |
jsonStr := `{ |
| 11 |
"device_code": "deviceCode", |
| 12 |
"user_code": "userCode", |
| 13 |
"verification_url": "http://example.com/verify", |
| 14 |
"expires_in": 3600, |
| 15 |
"interval": 5 |
| 16 |
}` |
| 17 |
|
| 18 |
expected := &DeviceAuthorizationResponse{ |
| 19 |
DeviceCode: "deviceCode", |
| 20 |
UserCode: "userCode", |
| 21 |
VerificationURI: "http://example.com/verify", |
| 22 |
ExpiresIn: 3600, |
| 23 |
Interval: 5, |
| 24 |
} |
| 25 |
|
| 26 |
var resp DeviceAuthorizationResponse |
| 27 |
err := resp.UnmarshalJSON([]byte(jsonStr)) |
| 28 |
assert.NoError(t, err) |
| 29 |
assert.Equal(t, expected, &resp) |
| 30 |
} |