@@ -44,6 +44,67 @@ public async Task Can_Sign_In_Using_Weixin(string claimType, string claimValue)
44
44
AssertClaim ( claims , claimType , claimValue ) ;
45
45
}
46
46
47
+ [ Theory ]
48
+ [ InlineData ( ClaimTypes . NameIdentifier , "my-id" ) ]
49
+ [ InlineData ( ClaimTypes . Name , "John Smith" ) ]
50
+ [ InlineData ( ClaimTypes . Gender , "Male" ) ]
51
+ [ InlineData ( ClaimTypes . Country , "CN" ) ]
52
+ [ InlineData ( "urn:weixin:city" , "Beijing" ) ]
53
+ [ InlineData ( "urn:weixin:headimgurl" , "https://weixin.qq.local/image.png" ) ]
54
+ [ InlineData ( "urn:weixin:openid" , "my-open-id" ) ]
55
+ [ InlineData ( "urn:weixin:privilege" , "a,b,c" ) ]
56
+ [ InlineData ( "urn:weixin:province" , "Hebei" ) ]
57
+ public async Task Can_Sign_In_Using_Wechat ( string claimType , string claimValue )
58
+ {
59
+ // Arrange
60
+ static void ConfigureServices ( IServiceCollection services )
61
+ {
62
+ services . PostConfigureAll < WeixinAuthenticationOptions > ( ( options ) =>
63
+ {
64
+ options . AuthorizationEndpoint = "https://open.weixin.qq.com/connect/oauth2/authorize" ;
65
+ } ) ;
66
+ }
67
+
68
+ using var server = CreateTestServer ( ConfigureServices ) ;
69
+
70
+ // Act
71
+ var claims = await AuthenticateUserAsync ( server ) ;
72
+
73
+ // Assert
74
+ AssertClaim ( claims , claimType , claimValue ) ;
75
+ }
76
+
77
+ [ Theory ]
78
+ [ InlineData ( ClaimTypes . NameIdentifier , "my-open-id" ) ]
79
+ [ InlineData ( ClaimTypes . Name , "John Smith" ) ]
80
+ [ InlineData ( ClaimTypes . Gender , "Male" ) ]
81
+ [ InlineData ( ClaimTypes . Country , "CN" ) ]
82
+ [ InlineData ( "urn:weixin:city" , "Beijing" ) ]
83
+ [ InlineData ( "urn:weixin:headimgurl" , "https://weixin.qq.local/image.png" ) ]
84
+ [ InlineData ( "urn:weixin:openid" , "my-open-id" ) ]
85
+ [ InlineData ( "urn:weixin:privilege" , "a,b,c" ) ]
86
+ [ InlineData ( "urn:weixin:province" , "Hebei" ) ]
87
+ public async Task Can_Sign_In_Using_Weixin_With_No_Union_Id ( string claimType , string claimValue )
88
+ {
89
+ // Arrange
90
+ static void ConfigureServices ( IServiceCollection services )
91
+ {
92
+ services . PostConfigureAll < WeixinAuthenticationOptions > ( ( options ) =>
93
+ {
94
+ options . AuthorizationEndpoint = "https://open.weixin.qq.com/connect/oauth2/authorize" ;
95
+ options . UserInformationEndpoint = "https://api.weixin.qq.com/sns/userinfo/nounionid" ;
96
+ } ) ;
97
+ }
98
+
99
+ using var server = CreateTestServer ( ConfigureServices ) ;
100
+
101
+ // Act
102
+ var claims = await AuthenticateUserAsync ( server ) ;
103
+
104
+ // Assert
105
+ AssertClaim ( claims , claimType , claimValue ) ;
106
+ }
107
+
47
108
[ Theory ]
48
109
[ InlineData ( false ) ]
49
110
[ InlineData ( true ) ]
@@ -55,7 +116,7 @@ public async Task BuildChallengeUrl_Generates_Correct_Url(bool usePkce)
55
116
UsePkce = usePkce ,
56
117
} ;
57
118
58
- string redirectUrl = "https://my-site.local/signin-weixin" ;
119
+ var redirectUrl = "https://my-site.local/signin-weixin" ;
59
120
60
121
// Act
61
122
Uri actual = await BuildChallengeUriAsync (
0 commit comments