1818
1919#import " OIDAuthorizationRequestTests.h"
2020
21- #import " OIDServiceConfigurationTests.h"
22-
2321#if SWIFT_PACKAGE
2422@import AppAuthCore;
23+ @import TestHelpers;
2524#else
2625#import " Source/AppAuthCore/OIDAuthorizationRequest.h"
2726#import " Source/AppAuthCore/OIDScopeUtilities.h"
28- #import " Source/AppAuthCore/OIDServiceConfiguration.h"
27+ #import " UnitTests/TestHelpers/OIDServiceConfiguration+TestHelper.h"
28+ #import " UnitTests/TestHelpers/OIDAuthorizationRequest+TestHelper.h"
2929#endif
3030
3131// Ignore warnings about "Use of GNU statement expression extension" which is raised by our use of
3232// the XCTAssert___ macros.
3333#pragma GCC diagnostic push
3434#pragma GCC diagnostic ignored "-Wgnu"
3535
36- /* ! @brief Test value for the @c responseType property.
37- */
38- static NSString *const kTestResponseType = @" code" ;
39-
40- /* ! @brief Test value for the @c clientID property.
41- */
42- static NSString *const kTestClientID = @" ClientID" ;
43-
44- /* ! @brief Test value for the @c clientID property.
45- */
46- static NSString *const kTestClientSecret = @" ClientSecret" ;
47-
48- /* ! @brief Test value for the @c scope property.
49- */
50- static NSString *const kTestScope = @" Scope" ;
51-
52- /* ! @brief Test value for the @c scope property.
53- */
54- static NSString *const kTestScopeA = @" ScopeA" ;
55-
5636/* ! @brief Test value for the @c scope property.
5737 */
5838static NSString *const kTestScopesMerged = @" Scope ScopeA" ;
5939
60- /* ! @brief Test value for the @c redirectURL property.
61- */
62- static NSString *const kTestRedirectURL = @" http://www.google.com/" ;
63-
64- /* ! @brief Test key for the @c additionalParameters property.
65- */
66- static NSString *const kTestAdditionalParameterKey = @" A" ;
67-
68- /* ! @brief Test value for the @c additionalParameters property.
69- */
70- static NSString *const kTestAdditionalParameterValue = @" 1" ;
71-
72- /* ! @brief Test value for the @c state property.
73- */
74- static NSString *const kTestState = @" State" ;
75-
76- /* ! @brief Test value for the @c nonce property.
77- */
78- static NSString *const kTestNonce = @" Nonce" ;
79-
80- /* ! @brief Test value for the @c codeVerifier property.
81- */
82- static NSString *const kTestCodeVerifier = @" code verifier" ;
83-
8440/* ! @brief This test scope contains a character which is one character below the allowed character
8541 range.
8642 */
@@ -144,28 +100,8 @@ + (NSString *)codeChallengeMethod {
144100 return OIDOAuthorizationRequestCodeChallengeMethodS256;
145101}
146102
147- + (OIDAuthorizationRequest *)testInstance {
148- NSDictionary *additionalParameters =
149- @{ kTestAdditionalParameterKey : kTestAdditionalParameterValue };
150- OIDServiceConfiguration *configuration = [OIDServiceConfigurationTests testInstance ];
151- OIDAuthorizationRequest *request =
152- [[OIDAuthorizationRequest alloc ] initWithConfiguration: configuration
153- clientId: kTestClientID
154- clientSecret: kTestClientSecret
155- scope: [OIDScopeUtilities scopesWithArray: @[ kTestScope , kTestScopeA ]]
156- redirectURL: [NSURL URLWithString: kTestRedirectURL ]
157- responseType: kTestResponseType
158- state: kTestState
159- nonce: kTestNonce
160- codeVerifier: kTestCodeVerifier
161- codeChallenge: [[self class ] codeChallenge ]
162- codeChallengeMethod: [[self class ] codeChallengeMethod ]
163- additionalParameters: additionalParameters];
164- return request;
165- }
166-
167103+ (OIDAuthorizationRequest *)testInstanceCodeFlow {
168- OIDServiceConfiguration *configuration = [OIDServiceConfigurationTests testInstance ];
104+ OIDServiceConfiguration *configuration = [OIDServiceConfiguration testInstance ];
169105 OIDAuthorizationRequest *request =
170106 [[OIDAuthorizationRequest alloc ] initWithConfiguration: configuration
171107 clientId: kTestClientID
@@ -183,7 +119,7 @@ + (OIDAuthorizationRequest *)testInstanceCodeFlow {
183119}
184120
185121+ (OIDAuthorizationRequest *)testInstanceCodeFlowClientAuth {
186- OIDServiceConfiguration *configuration = [OIDServiceConfigurationTests testInstance ];
122+ OIDServiceConfiguration *configuration = [OIDServiceConfiguration testInstance ];
187123 OIDAuthorizationRequest *request =
188124 [[OIDAuthorizationRequest alloc ] initWithConfiguration: configuration
189125 clientId: kTestClientID
@@ -205,7 +141,7 @@ + (OIDAuthorizationRequest *)testInstanceCodeFlowClientAuth {
205141- (void )testScopeInitializerWithManyScopesAndNoClientSecret {
206142 NSDictionary *additionalParameters =
207143 @{ kTestAdditionalParameterKey : kTestAdditionalParameterValue };
208- OIDServiceConfiguration *configuration = [OIDServiceConfigurationTests testInstance ];
144+ OIDServiceConfiguration *configuration = [OIDServiceConfiguration testInstance ];
209145 OIDAuthorizationRequest *request =
210146 [[OIDAuthorizationRequest alloc ] initWithConfiguration: configuration
211147 clientId: kTestClientID
@@ -226,7 +162,7 @@ - (void)testScopeInitializerWithManyScopesAndNoClientSecret {
226162- (void )testScopeInitializerWithManyScopesAndClientSecret {
227163 NSDictionary *additionalParameters =
228164 @{ kTestAdditionalParameterKey : kTestAdditionalParameterValue };
229- OIDServiceConfiguration *configuration = [OIDServiceConfigurationTests testInstance ];
165+ OIDServiceConfiguration *configuration = [OIDServiceConfiguration testInstance ];
230166 OIDAuthorizationRequest *request =
231167 [[OIDAuthorizationRequest alloc ] initWithConfiguration: configuration
232168 clientId: kTestClientID
@@ -249,7 +185,7 @@ - (void)testScopeInitializerWithManyScopesAndClientSecret {
249185 process and checking to make sure the source and destination instances are equivalent.
250186 */
251187- (void )testCopying {
252- OIDAuthorizationRequest *request = [[ self class ] testInstance ];
188+ OIDAuthorizationRequest *request = [OIDAuthorizationRequest testInstance ];
253189
254190 XCTAssertEqualObjects (request.responseType , kTestResponseType , @" " );
255191 XCTAssertEqualObjects (request.scope , kTestScopesMerged , @" " );
@@ -285,7 +221,7 @@ - (void)testCopying {
285221 checking to make sure the source and destination instances are equivalent.
286222 */
287223- (void )testSecureCoding {
288- OIDAuthorizationRequest *request = [[ self class ] testInstance ];
224+ OIDAuthorizationRequest *request = [OIDAuthorizationRequest testInstance ];
289225
290226 XCTAssertEqualObjects (request.responseType , kTestResponseType , @" " );
291227 XCTAssertEqualObjects (request.scope , kTestScopesMerged , @" " );
@@ -327,7 +263,7 @@ - (void)testSecureCoding {
327263 */
328264- (void )testDisallowedCharactersInScopes {
329265 NSURL *redirectURL = [NSURL URLWithString: kTestRedirectURL ];
330- OIDServiceConfiguration *configuration = [OIDServiceConfigurationTests testInstance ];
266+ OIDServiceConfiguration *configuration = [OIDServiceConfiguration testInstance ];
331267 XCTAssertThrows (
332268 [[OIDAuthorizationRequest alloc ] initWithConfiguration: configuration
333269 clientId: kTestClientID
@@ -441,7 +377,7 @@ - (void)testPKCEVerifierRecommendations {
441377- (void )testSupportedResponseTypes {
442378 NSDictionary *additionalParameters =
443379 @{ kTestAdditionalParameterKey : kTestAdditionalParameterValue };
444- OIDServiceConfiguration *configuration = [OIDServiceConfigurationTests testInstance ];
380+ OIDServiceConfiguration *configuration = [OIDServiceConfiguration testInstance ];
445381
446382 NSString *scope = [OIDScopeUtilities scopesWithArray: @[ kTestScope , kTestScopeA ]];
447383
@@ -524,7 +460,7 @@ - (void)testSupportedResponseTypes {
524460}
525461
526462- (void )testExternalUserAgentMethods {
527- OIDAuthorizationRequest *request = [[ self class ] testInstance ];
463+ OIDAuthorizationRequest *request = [OIDAuthorizationRequest testInstance ];
528464 XCTAssertEqualObjects ([request externalUserAgentRequestURL ], [request authorizationRequestURL ]);
529465 XCTAssert ([[request redirectScheme ] isEqualToString: request.redirectURL.scheme]);
530466}
0 commit comments