Fix MakerWorld 2FA duplicate email loop and add email SMTP diagnostics
This commit is contained in:
@@ -215,4 +215,72 @@ class MakerWorldImporterTest extends TestCase
|
||||
$disconnectResponse->assertRedirect();
|
||||
$this->assertNull(Setting::get('makerworld_token'));
|
||||
}
|
||||
|
||||
public function test_makerworld_login_with_2fa_redirects_to_auth_tab_without_duplicate_email(): void
|
||||
{
|
||||
Http::fake([
|
||||
'https://api.bambulab.com/v1/user-service/user/login' => Http::response([
|
||||
'loginType' => 'verifyCode',
|
||||
'message' => 'Verification code sent',
|
||||
], 200),
|
||||
'https://api.bambulab.com/v1/user-service/user/sendemail/code' => Http::response([
|
||||
'success' => true,
|
||||
], 200),
|
||||
]);
|
||||
|
||||
$response = $this->post(route('admin.makerworld.login'), [
|
||||
'account' => 'test2fa@jouwdriedee.nl',
|
||||
'password' => 'secret_pass',
|
||||
]);
|
||||
|
||||
$response->assertRedirect(route('admin.makerworld.index', ['tab' => 'auth']));
|
||||
$response->assertSessionHas('makerworld_2fa_account', 'test2fa@jouwdriedee.nl');
|
||||
|
||||
// Verify that sendemail/code was NOT called automatically (Bambu Lab already sent it on login)
|
||||
Http::assertNotSent(function ($request) {
|
||||
return str_contains($request->url(), 'sendemail/code');
|
||||
});
|
||||
}
|
||||
|
||||
public function test_makerworld_can_verify_2fa_code(): void
|
||||
{
|
||||
Http::fake([
|
||||
'https://api.bambulab.com/v1/user-service/user/login' => Http::response([
|
||||
'accessToken' => 'token_after_2fa_code_9999',
|
||||
], 200),
|
||||
'https://api.bambulab.com/v1/design-user-service/my/preference' => Http::response([
|
||||
'uid' => 12345,
|
||||
'name' => 'Verified User',
|
||||
], 200),
|
||||
]);
|
||||
|
||||
$response = $this->post(route('admin.makerworld.verify-code'), [
|
||||
'account' => 'test2fa@jouwdriedee.nl',
|
||||
'code' => '123456',
|
||||
]);
|
||||
|
||||
$response->assertRedirect(route('admin.makerworld.index', ['tab' => 'collections']));
|
||||
$this->assertSame('token_after_2fa_code_9999', Setting::get('makerworld_token'));
|
||||
}
|
||||
|
||||
public function test_makerworld_can_manually_resend_2fa_code(): void
|
||||
{
|
||||
Http::fake([
|
||||
'https://api.bambulab.com/v1/user-service/user/sendemail/code' => Http::response([
|
||||
'success' => true,
|
||||
], 200),
|
||||
]);
|
||||
|
||||
$response = $this->post(route('admin.makerworld.resend-code'), [
|
||||
'account' => 'test2fa@jouwdriedee.nl',
|
||||
]);
|
||||
|
||||
$response->assertRedirect(route('admin.makerworld.index', ['tab' => 'auth']));
|
||||
$response->assertSessionHas('success');
|
||||
|
||||
Http::assertSent(function ($request) {
|
||||
return str_contains($request->url(), 'sendemail/code') &&
|
||||
$request['email'] === 'test2fa@jouwdriedee.nl';
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user