Skip to content

Commit 82c1bf4

Browse files
authored
bug fix: add expires_in field to OpenIDTokenType (#130)
As we recently enforcing `DisallowUnknownFields()` while checking JSON input we need to add all required fields to `OpenIDTokenType` such as `expires_in`
1 parent 6573de0 commit 82c1bf4

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ type OpenIDTokenType struct {
5454
AccessToken string `json:"access_token"`
5555
TokenType string `json:"token_type"`
5656
MatrixServerName string `json:"matrix_server_name"`
57+
ExpiresIn int `json:"expires_in"`
5758
}
5859

5960
type LegacySFURequest struct {

main_test.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ func TestHandlePost(t *testing.T) {
145145
"access_token": "testAccessToken",
146146
"token_type": "testTokenType",
147147
"matrix_server_name": u.Host,
148+
"expires_in": 3600,
148149
},
149150
"member": map[string]interface{}{
150151
"id": "member_test_id",
@@ -253,6 +254,7 @@ func TestLegacyHandlePost(t *testing.T) {
253254
"access_token": "testAccessToken",
254255
"token_type": "testTokenType",
255256
"matrix_server_name": u.Host,
257+
"expires_in": 3600,
256258
},
257259
"device_id": "testDevice",
258260
}
@@ -650,7 +652,8 @@ func TestMapSFURequest(t *testing.T) {
650652
"openid_token": {
651653
"access_token": "test_token",
652654
"token_type": "Bearer",
653-
"matrix_server_name": "example.com"
655+
"matrix_server_name": "example.com",
656+
"expires_in": 3600
654657
},
655658
"device_id": "testDevice"
656659
}`,
@@ -660,6 +663,7 @@ func TestMapSFURequest(t *testing.T) {
660663
AccessToken: "test_token",
661664
TokenType: "Bearer",
662665
MatrixServerName: "example.com",
666+
ExpiresIn: 3600,
663667
},
664668
DeviceID: "testDevice",
665669
},
@@ -672,7 +676,8 @@ func TestMapSFURequest(t *testing.T) {
672676
"openid_token": {
673677
"access_token": "test_token",
674678
"token_type": "Bearer",
675-
"matrix_server_name": "example.com"
679+
"matrix_server_name": "example.com",
680+
"expires_in": 3600
676681
},
677682
"member": {
678683
"id": "test_id",
@@ -687,6 +692,7 @@ func TestMapSFURequest(t *testing.T) {
687692
AccessToken: "test_token",
688693
TokenType: "Bearer",
689694
MatrixServerName: "example.com",
695+
ExpiresIn: 3600,
690696
},
691697
Member: MatrixRTCMemberType{
692698
ID: "test_id",
@@ -714,7 +720,8 @@ func TestMapSFURequest(t *testing.T) {
714720
"openid_token": {
715721
"access_token": "test_token",
716722
"token_type": "Bearer",
717-
"matrix_server_name": "example.com"
723+
"matrix_server_name": "example.com",
724+
"expires_in": 3600
718725
},
719726
"device_id": "testDevice",
720727
"extra_field": "should_fail"
@@ -785,7 +792,8 @@ func TestMapSFURequestMemoryLeak(t *testing.T) {
785792
"openid_token": {
786793
"access_token": "test_token",
787794
"token_type": "Bearer",
788-
"matrix_server_name": "example.com"
795+
"matrix_server_name": "example.com",
796+
"expires_in": 3600
789797
},
790798
"member": {
791799
"id": "test_id",

0 commit comments

Comments
 (0)