@@ -24,89 +24,83 @@ public static void Validate_Does_Not_Throw_If_ClientSecret_Is_Not_Provided(strin
2424 options . Validate ( ) ;
2525 }
2626
27- [ Theory ]
28- [ InlineData ( true , false ) ]
29- [ InlineData ( false , false ) ]
30- [ InlineData ( false , true ) ]
31- public static void Validate_Throws_If_SaveTokens_Or_Pkce_Is_Disabled ( bool usePkce , bool saveTokens )
27+ [ Fact ]
28+ public static void Validate_Does_Throw_If_Scope_Does_Not_Contain_Scope_shop_r ( )
3229 {
3330 // Arrange
3431 var options = new EtsyAuthenticationOptions ( )
3532 {
3633 ClientId = "my-client-id" ,
3734 ClientSecret = "my-client-secret" ,
38- SaveTokens = saveTokens ,
39- UsePkce = usePkce ,
4035 } ;
36+ options . Scope . Clear ( ) ;
37+ options . Scope . Add ( EtsyAuthenticationConstants . Scopes . EmailRead ) ;
4138
42- // Act and Assert
43- _ = Assert . Throws < ArgumentException > ( options . Validate ) ;
39+ // Act
40+ _ = Assert . Throws < ArgumentOutOfRangeException > ( options . Validate ) ;
4441 }
4542
4643 [ Fact ]
47- public static void Validate_Throws_If_Scope_Is_Empty ( )
44+ public static void Validate_Does_Not_Throw_When_IncludeDetailedUserInfo_Is_False_And_Contains_Scope_email_r ( )
4845 {
4946 // Arrange
5047 var options = new EtsyAuthenticationOptions ( )
5148 {
5249 ClientId = "my-client-id" ,
5350 ClientSecret = "my-client-secret" ,
54- Scope = { } ,
51+ IncludeDetailedUserInfo = false ,
5552 } ;
5653
57- // Act and Assert
58- _ = Assert . Throws < ArgumentOutOfRangeException > ( options . Validate ) ;
54+ // Adding email scope should be harmless when IncludeDetailedUserInfo is false
55+ options . Scope . Add ( EtsyAuthenticationConstants . Scopes . EmailRead ) ;
56+
57+ // Act (no Assert)
58+ options . Validate ( ) ;
5959 }
6060
6161 [ Fact ]
62- public static void Validate_Throws_If_Scope_Does_Not_Contain_Scope_shop_r ( )
62+ public static void Validate_Throws_If_AuthorizationEndpoint_Is_Null ( )
6363 {
6464 // Arrange
6565 var options = new EtsyAuthenticationOptions ( )
6666 {
67+ AuthorizationEndpoint = null ! ,
6768 ClientId = "my-client-id" ,
6869 ClientSecret = "my-client-secret" ,
6970 } ;
70- options . Scope . Clear ( ) ;
71- options . Scope . Add ( ClaimTypes . Email ) ;
7271
7372 // Act and Assert
74- _ = Assert . Throws < ArgumentOutOfRangeException > ( options . Validate ) ;
73+ _ = Assert . Throws < ArgumentNullException > ( nameof ( options . AuthorizationEndpoint ) , options . Validate ) ;
7574 }
7675
7776 [ Fact ]
78- public static void Validate_Throws_If_IncludeDetailedUserInfo_Is_True_But_Does_Not_Contain_Scope_email_r ( )
77+ public static void Validate_Throws_If_TokenEndpoint_Is_Null ( )
7978 {
8079 // Arrange
8180 var options = new EtsyAuthenticationOptions ( )
8281 {
8382 ClientId = "my-client-id" ,
8483 ClientSecret = "my-client-secret" ,
85- IncludeDetailedUserInfo = true ,
84+ TokenEndpoint = null ! ,
8685 } ;
8786
88- // Not Adding email scope, shop scope is already added by default
89-
9087 // Act and Assert
91- _ = Assert . Throws < ArgumentOutOfRangeException > ( options . Validate ) ;
88+ _ = Assert . Throws < ArgumentNullException > ( nameof ( options . TokenEndpoint ) , options . Validate ) ;
9289 }
9390
9491 [ Fact ]
95- public static void Validate_Does_Not_Throw_When_IncludeDetailedUserInfo_Is_False_And_Contains_Scope_email_r ( )
92+ public static void Validate_Throws_If_UserInformationEndpoint_Is_Null ( )
9693 {
9794 // Arrange
9895 var options = new EtsyAuthenticationOptions ( )
9996 {
10097 ClientId = "my-client-id" ,
10198 ClientSecret = "my-client-secret" ,
102- IncludeDetailedUserInfo = false ,
99+ TokenEndpoint = null ! ,
103100 } ;
104101
105- // Adding email scope
106- options . Scope . Add ( ClaimTypes . Email ) ;
107-
108- // Act (no Assert)
109- options . Validate ( ) ;
102+ // Act and Assert
103+ _ = Assert . Throws < ArgumentNullException > ( nameof ( options . UserInformationEndpoint ) , options . Validate ) ;
110104 }
111105
112106 [ Fact ]
@@ -121,6 +115,7 @@ public static void Validate_Throws_If_CallbackPath_Is_Null()
121115 } ;
122116
123117 // Act and Assert
124- _ = Assert . Throws < ArgumentNullException > ( nameof ( EtsyAuthenticationOptions . CallbackPath ) , options . Validate ) ;
118+ var ex = Assert . Throws < ArgumentException > ( options . Validate ) ;
119+ ex . ParamName . ShouldBe ( nameof ( options . CallbackPath ) ) ;
125120 }
126121}
0 commit comments