@@ -809,45 +809,7 @@ public async Task ReplyPathWillAuthenticateValidAuthorizeCodeAndState(string cla
809809 {
810810 o . ClaimsIssuer = claimsIssuer ;
811811 }
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 ( ) ;
851813 } ) ;
852814
853815 var properties = new AuthenticationProperties ( ) ;
@@ -999,46 +961,7 @@ public async Task AuthenticatedEventCanGetRefreshToken()
999961 o . ClientId = "Test Id" ;
1000962 o . ClientSecret = "Test Secret" ;
1001963 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 ( ) ;
1042965 o . Events = new OAuthEvents
1043966 {
1044967 OnCreatingTicket = context =>
@@ -1079,46 +1002,7 @@ public async Task NullRedirectUriWillRedirectToSlash()
10791002 o . ClientId = "Test Id" ;
10801003 o . ClientSecret = "Test Secret" ;
10811004 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 ( ) ;
11221006 o . Events = new OAuthEvents
11231007 {
11241008 OnTicketReceived = context =>
@@ -1169,46 +1053,7 @@ public async Task ValidateAuthenticatedContext()
11691053 return Task . FromResult ( 0 ) ;
11701054 }
11711055 } ;
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 ( ) ;
12121057 } ) ;
12131058
12141059 var properties = new AuthenticationProperties ( ) ;
@@ -1439,29 +1284,20 @@ private HttpMessageHandler CreateBackchannel()
14391284 {
14401285 access_token = "Test Access Token" ,
14411286 expires_in = 3600 ,
1442- token_type = "Bearer"
1287+ token_type = "Bearer" ,
1288+ refresh_token = "Test Refresh Token"
14431289 } ) ;
14441290 }
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 " )
14461292 {
14471293 return ReturnJsonResponse ( new
14481294 {
14491295 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" ,
14651301 } ) ;
14661302 }
14671303
0 commit comments