@@ -150,132 +150,6 @@ public function testDebugDisabled()
150
150
$ this ->assertEmpty ($ this ->getLogFileContents ());
151
151
}
152
152
153
- /**
154
- * Test that debug logging works when enabled and an API call is made.
155
- *
156
- * @since 1.2.0
157
- *
158
- * @return void
159
- */
160
- public function testDebugEnabled ()
161
- {
162
- // Setup API with debugging enabled.
163
- $ api = new ConvertKit_API (
164
- clientID: $ _ENV ['CONVERTKIT_OAUTH_CLIENT_ID ' ],
165
- clientSecret: $ _ENV ['CONVERTKIT_OAUTH_CLIENT_SECRET ' ],
166
- accessToken: $ _ENV ['CONVERTKIT_OAUTH_ACCESS_TOKEN ' ],
167
- debug: true
168
- );
169
- $ result = $ api ->get_account ();
170
-
171
- // Confirm that the log includes expected data.
172
- $ this ->assertStringContainsString ('ck-debug.INFO: GET account ' , $ this ->getLogFileContents ());
173
- $ this ->assertStringContainsString ('ck-debug.INFO: Finish request successfully ' , $ this ->getLogFileContents ());
174
- }
175
-
176
- /**
177
- * Test that debug logging works when enabled, a custom debug log file and path is specified
178
- * and an API call is made.
179
- *
180
- * @since 1.3.0
181
- *
182
- * @return void
183
- */
184
- public function testDebugEnabledWithCustomLogFile ()
185
- {
186
- // Define custom log file location.
187
- $ this ->logFile = dirname (dirname (__FILE__ )) . '/src/logs/debug-custom.log ' ;
188
-
189
- // Setup API with debugging enabled.
190
- $ api = new ConvertKit_API (
191
- clientID: $ _ENV ['CONVERTKIT_OAUTH_CLIENT_ID ' ],
192
- clientSecret: $ _ENV ['CONVERTKIT_OAUTH_CLIENT_SECRET ' ],
193
- accessToken: $ _ENV ['CONVERTKIT_OAUTH_ACCESS_TOKEN ' ],
194
- debug: true ,
195
- debugLogFileLocation: $ this ->logFile
196
- );
197
- $ result = $ api ->get_account ();
198
-
199
- // Confirm log file exists.
200
- $ this ->assertFileExists ($ this ->logFile );
201
-
202
- // Confirm that the log includes expected data.
203
- $ this ->assertStringContainsString ('ck-debug.INFO: GET account ' , $ this ->getLogFileContents ());
204
- $ this ->assertStringContainsString ('ck-debug.INFO: Finish request successfully ' , $ this ->getLogFileContents ());
205
- }
206
-
207
- /**
208
- * Test that debug logging works when enabled and an API call is made, with email addresses and credentials
209
- * masked in the log file.
210
- *
211
- * @since 2.0.0
212
- *
213
- * @return void
214
- */
215
- public function testDebugCredentialsAndEmailsAreMasked ()
216
- {
217
- // Setup API with debugging enabled.
218
- $ api = new ConvertKit_API (
219
- clientID: $ _ENV ['CONVERTKIT_OAUTH_CLIENT_ID ' ],
220
- clientSecret: $ _ENV ['CONVERTKIT_OAUTH_CLIENT_SECRET ' ],
221
- accessToken: $ _ENV ['CONVERTKIT_OAUTH_ACCESS_TOKEN ' ],
222
- debug: true
223
- );
224
-
225
- // Create log entries with Client ID, Client Secret, Access Token and Email Address, as if an API method
226
- // were to log this sensitive data.
227
- $ this ->callPrivateMethod ($ api , 'create_log ' , ['Client ID: ' . $ _ENV ['CONVERTKIT_OAUTH_CLIENT_ID ' ]]);
228
- $ this ->callPrivateMethod ($ api , 'create_log ' , ['Client Secret: ' . $ _ENV ['CONVERTKIT_OAUTH_CLIENT_SECRET ' ]]);
229
- $ this ->callPrivateMethod ($ api , 'create_log ' , ['Access Token: ' . $ _ENV ['CONVERTKIT_OAUTH_ACCESS_TOKEN ' ]]);
230
- $ this ->callPrivateMethod ($ api , 'create_log ' , ['Email: ' . $ _ENV ['CONVERTKIT_API_SUBSCRIBER_EMAIL ' ]]);
231
-
232
- // Confirm that the log includes the masked Client ID, Secret, Access Token and Email Address.
233
- $ this ->assertStringContainsString (
234
- str_repeat (
235
- '* ' ,
236
- (strlen ($ _ENV ['CONVERTKIT_OAUTH_CLIENT_ID ' ]) - 4 )
237
- ) . substr ($ _ENV ['CONVERTKIT_OAUTH_CLIENT_ID ' ], -4 ),
238
- $ this ->getLogFileContents ()
239
- );
240
- $ this ->assertStringContainsString (
241
- str_repeat (
242
- '* ' ,
243
- (strlen ($ _ENV ['CONVERTKIT_OAUTH_CLIENT_SECRET ' ]) - 4 )
244
- ) . substr ($ _ENV ['CONVERTKIT_OAUTH_CLIENT_SECRET ' ], -4 ),
245
- $ this ->getLogFileContents ()
246
- );
247
- $ this ->assertStringContainsString (
248
- str_repeat (
249
- '* ' ,
250
- (strlen ($ _ENV ['CONVERTKIT_OAUTH_ACCESS_TOKEN ' ]) - 4 )
251
- ) . substr ($ _ENV ['CONVERTKIT_OAUTH_ACCESS_TOKEN ' ], -4 ),
252
- $ this ->getLogFileContents ()
253
- );
254
- $ this ->assertStringContainsString (
255
- 'o****@n********.c** ' ,
256
- $ this ->getLogFileContents ()
257
- );
258
-
259
- // Confirm that the log does not include the unmasked Client ID, Secret, Access Token or Email Address.
260
- $ this ->assertStringNotContainsString ($ _ENV ['CONVERTKIT_OAUTH_CLIENT_ID ' ], $ this ->getLogFileContents ());
261
- $ this ->assertStringNotContainsString ($ _ENV ['CONVERTKIT_OAUTH_CLIENT_SECRET ' ], $ this ->getLogFileContents ());
262
- $ this ->assertStringNotContainsString ($ _ENV ['CONVERTKIT_OAUTH_ACCESS_TOKEN ' ], $ this ->getLogFileContents ());
263
- $ this ->assertStringNotContainsString ($ _ENV ['CONVERTKIT_API_SUBSCRIBER_EMAIL ' ], $ this ->getLogFileContents ());
264
- }
265
-
266
- /**
267
- * Test that debug logging is not performed when disabled and an API call is made.
268
- *
269
- * @since 1.2.0
270
- *
271
- * @return void
272
- */
273
- public function testDebugDisabled ()
274
- {
275
- $ result = $ this ->api ->get_account ();
276
- $ this ->assertEmpty ($ this ->getLogFileContents ());
277
- }
278
-
279
153
/**
280
154
* Test that calling request_headers() returns the expected array of headers
281
155
*
0 commit comments