@@ -2101,26 +2101,43 @@ await SendRequestAsync(request => request
21012101 [ Fact ]
21022102 public async Task GetUserByOAuthProviderAsync_DifferentAccountEntries_DoNotMatch ( )
21032103 {
2104+ // Arrange
21042105 var user = await _userRepository . GetByEmailAddressAsync ( SampleDataService . TEST_USER_EMAIL ) ;
21052106 Assert . NotNull ( user ) ;
21062107 user . AddOAuthAccount ( "google" , "shared-subject" , user . EmailAddress ) ;
21072108 user . AddOAuthAccount ( "github" , "other-subject" , user . EmailAddress ) ;
21082109 await _userRepository . SaveAsync ( user , o => o . ImmediateConsistency ( ) ) ;
2109- Assert . Null ( await _userRepository . GetUserByOAuthProviderAsync ( "github" , "shared-subject" ) ) ;
2110- Assert . Equal ( user . Id , ( await _userRepository . GetUserByOAuthProviderAsync ( "google" , "shared-subject" ) ) ! . Id ) ;
2110+
2111+ // Act
2112+ var githubUser = await _userRepository . GetUserByOAuthProviderAsync ( "github" , "shared-subject" ) ;
2113+ var googleUser = await _userRepository . GetUserByOAuthProviderAsync ( "google" , "shared-subject" ) ;
2114+
2115+ // Assert
2116+ Assert . Null ( githubUser ) ;
2117+ Assert . NotNull ( googleUser ) ;
2118+ Assert . Equal ( user . Id , googleUser . Id ) ;
21112119 }
21122120
21132121 [ Fact ]
21142122 public async Task GetUserByOAuthProviderAsync_DuplicateIdentity_RejectsAmbiguousOwner ( )
21152123 {
2124+ // Arrange
21162125 foreach ( string email in new [ ] { SampleDataService . TEST_USER_EMAIL , SampleDataService . TEST_ORG_USER_EMAIL } )
21172126 {
21182127 var user = await _userRepository . GetByEmailAddressAsync ( email ) ;
21192128 Assert . NotNull ( user ) ;
21202129 user . AddOAuthAccount ( "github" , "duplicate-subject" , user . EmailAddress ) ;
21212130 await _userRepository . SaveAsync ( user , o => o . ImmediateConsistency ( ) ) ;
21222131 }
2123- await Assert . ThrowsAsync < UnauthorizedAccessException > ( ( ) => _userRepository . GetUserByOAuthProviderAsync ( "github" , "duplicate-subject" ) ) ;
2132+
2133+ // Act
2134+ var exception = await Record . ExceptionAsync ( async ( ) =>
2135+ {
2136+ _ = await _userRepository . GetUserByOAuthProviderAsync ( "github" , "duplicate-subject" ) ;
2137+ } ) ;
2138+
2139+ // Assert
2140+ Assert . IsType < UnauthorizedAccessException > ( exception ) ;
21242141 }
21252142
21262143 private async Task AssertExternalLoginAsync ( TokenResult ? result , string providerName , string providerUserId )
0 commit comments