@@ -809,45 +809,7 @@ public async Task ReplyPathWillAuthenticateValidAuthorizeCodeAndState(string cla
809
809
{
810
810
o . ClaimsIssuer = claimsIssuer ;
811
811
}
812
- o . BackchannelHttpHandler = new TestHttpMessageHandler
813
- {
814
- Sender = req =>
815
- {
816
- if ( req . RequestUri . AbsoluteUri == "https://www.googleapis.com/oauth2/v4/token" )
817
- {
818
- return ReturnJsonResponse ( new
819
- {
820
- access_token = "Test Access Token" ,
821
- expires_in = 3600 ,
822
- token_type = "Bearer"
823
- } ) ;
824
- }
825
- else if ( req . RequestUri . GetComponents ( UriComponents . SchemeAndServer | UriComponents . Path , UriFormat . UriEscaped ) == "https://www.googleapis.com/plus/v1/people/me" )
826
- {
827
- return ReturnJsonResponse ( new
828
- {
829
- id = "Test User ID" ,
830
- displayName = "Test Name" ,
831
- name = new
832
- {
833
- familyName = "Test Family Name" ,
834
- givenName = "Test Given Name"
835
- } ,
836
- url = "Profile link" ,
837
- emails = new [ ]
838
- {
839
- new
840
- {
841
- value = "Test email" ,
842
- type = "account"
843
- }
844
- }
845
- } ) ;
846
- }
847
-
848
- throw new NotImplementedException ( req . RequestUri . AbsoluteUri ) ;
849
- }
850
- } ;
812
+ o . BackchannelHttpHandler = CreateBackchannel ( ) ;
851
813
} ) ;
852
814
853
815
var properties = new AuthenticationProperties ( ) ;
@@ -999,46 +961,7 @@ public async Task AuthenticatedEventCanGetRefreshToken()
999
961
o . ClientId = "Test Id" ;
1000
962
o . ClientSecret = "Test Secret" ;
1001
963
o . StateDataFormat = stateFormat ;
1002
- o . BackchannelHttpHandler = new TestHttpMessageHandler
1003
- {
1004
- Sender = req =>
1005
- {
1006
- if ( req . RequestUri . AbsoluteUri == "https://www.googleapis.com/oauth2/v4/token" )
1007
- {
1008
- return ReturnJsonResponse ( new
1009
- {
1010
- access_token = "Test Access Token" ,
1011
- expires_in = 3600 ,
1012
- token_type = "Bearer" ,
1013
- refresh_token = "Test Refresh Token"
1014
- } ) ;
1015
- }
1016
- else if ( req . RequestUri . GetComponents ( UriComponents . SchemeAndServer | UriComponents . Path , UriFormat . UriEscaped ) == "https://www.googleapis.com/plus/v1/people/me" )
1017
- {
1018
- return ReturnJsonResponse ( new
1019
- {
1020
- id = "Test User ID" ,
1021
- displayName = "Test Name" ,
1022
- name = new
1023
- {
1024
- familyName = "Test Family Name" ,
1025
- givenName = "Test Given Name"
1026
- } ,
1027
- url = "Profile link" ,
1028
- emails = new [ ]
1029
- {
1030
- new
1031
- {
1032
- value = "Test email" ,
1033
- type = "account"
1034
- }
1035
- }
1036
- } ) ;
1037
- }
1038
-
1039
- throw new NotImplementedException ( req . RequestUri . AbsoluteUri ) ;
1040
- }
1041
- } ;
964
+ o . BackchannelHttpHandler = CreateBackchannel ( ) ;
1042
965
o . Events = new OAuthEvents
1043
966
{
1044
967
OnCreatingTicket = context =>
@@ -1079,46 +1002,7 @@ public async Task NullRedirectUriWillRedirectToSlash()
1079
1002
o . ClientId = "Test Id" ;
1080
1003
o . ClientSecret = "Test Secret" ;
1081
1004
o . StateDataFormat = stateFormat ;
1082
- o . BackchannelHttpHandler = new TestHttpMessageHandler
1083
- {
1084
- Sender = req =>
1085
- {
1086
- if ( req . RequestUri . AbsoluteUri == "https://www.googleapis.com/oauth2/v4/token" )
1087
- {
1088
- return ReturnJsonResponse ( new
1089
- {
1090
- access_token = "Test Access Token" ,
1091
- expires_in = 3600 ,
1092
- token_type = "Bearer" ,
1093
- refresh_token = "Test Refresh Token"
1094
- } ) ;
1095
- }
1096
- else if ( req . RequestUri . GetComponents ( UriComponents . SchemeAndServer | UriComponents . Path , UriFormat . UriEscaped ) == "https://www.googleapis.com/plus/v1/people/me" )
1097
- {
1098
- return ReturnJsonResponse ( new
1099
- {
1100
- id = "Test User ID" ,
1101
- displayName = "Test Name" ,
1102
- name = new
1103
- {
1104
- familyName = "Test Family Name" ,
1105
- givenName = "Test Given Name"
1106
- } ,
1107
- url = "Profile link" ,
1108
- emails = new [ ]
1109
- {
1110
- new
1111
- {
1112
- value = "Test email" ,
1113
- type = "account"
1114
- }
1115
- }
1116
- } ) ;
1117
- }
1118
-
1119
- throw new NotImplementedException ( req . RequestUri . AbsoluteUri ) ;
1120
- }
1121
- } ;
1005
+ o . BackchannelHttpHandler = CreateBackchannel ( ) ;
1122
1006
o . Events = new OAuthEvents
1123
1007
{
1124
1008
OnTicketReceived = context =>
@@ -1169,46 +1053,7 @@ public async Task ValidateAuthenticatedContext()
1169
1053
return Task . FromResult ( 0 ) ;
1170
1054
}
1171
1055
} ;
1172
- o . BackchannelHttpHandler = new TestHttpMessageHandler
1173
- {
1174
- Sender = req =>
1175
- {
1176
- if ( req . RequestUri . AbsoluteUri == "https://www.googleapis.com/oauth2/v4/token" )
1177
- {
1178
- return ReturnJsonResponse ( new
1179
- {
1180
- access_token = "Test Access Token" ,
1181
- expires_in = 3600 ,
1182
- token_type = "Bearer" ,
1183
- refresh_token = "Test Refresh Token"
1184
- } ) ;
1185
- }
1186
- else if ( req . RequestUri . GetComponents ( UriComponents . SchemeAndServer | UriComponents . Path , UriFormat . UriEscaped ) == "https://www.googleapis.com/plus/v1/people/me" )
1187
- {
1188
- return ReturnJsonResponse ( new
1189
- {
1190
- id = "Test User ID" ,
1191
- displayName = "Test Name" ,
1192
- name = new
1193
- {
1194
- familyName = "Test Family Name" ,
1195
- givenName = "Test Given Name"
1196
- } ,
1197
- url = "Profile link" ,
1198
- emails = new [ ]
1199
- {
1200
- new
1201
- {
1202
- value = "Test email" ,
1203
- type = "account"
1204
- }
1205
- }
1206
- } ) ;
1207
- }
1208
-
1209
- throw new NotImplementedException ( req . RequestUri . AbsoluteUri ) ;
1210
- }
1211
- } ;
1056
+ o . BackchannelHttpHandler = CreateBackchannel ( ) ;
1212
1057
} ) ;
1213
1058
1214
1059
var properties = new AuthenticationProperties ( ) ;
@@ -1439,29 +1284,20 @@ private HttpMessageHandler CreateBackchannel()
1439
1284
{
1440
1285
access_token = "Test Access Token" ,
1441
1286
expires_in = 3600 ,
1442
- token_type = "Bearer"
1287
+ token_type = "Bearer" ,
1288
+ refresh_token = "Test Refresh Token"
1443
1289
} ) ;
1444
1290
}
1445
- else if ( req . RequestUri . GetComponents ( UriComponents . SchemeAndServer | UriComponents . Path , UriFormat . UriEscaped ) == "https://www.googleapis.com/plus/v1/people/me " )
1291
+ else if ( req . RequestUri . GetComponents ( UriComponents . SchemeAndServer | UriComponents . Path , UriFormat . UriEscaped ) == "https://www.googleapis.com/oauth2/v2/userinfo " )
1446
1292
{
1447
1293
return ReturnJsonResponse ( new
1448
1294
{
1449
1295
id = "Test User ID" ,
1450
- displayName = "Test Name" ,
1451
- name = new
1452
- {
1453
- familyName = "Test Family Name" ,
1454
- givenName = "Test Given Name"
1455
- } ,
1456
- url = "Profile link" ,
1457
- emails = new [ ]
1458
- {
1459
- new
1460
- {
1461
- value = "Test email" ,
1462
- type = "account"
1463
- }
1464
- }
1296
+ name = "Test Name" ,
1297
+ given_name = "Test Given Name" ,
1298
+ family_name = "Test Family Name" ,
1299
+ link = "Profile link" ,
1300
+ email = "Test email" ,
1465
1301
} ) ;
1466
1302
}
1467
1303
0 commit comments