Skip to content

Replaced imap with mailhog and refreshed the test. #13197

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

SakiTakamachi
Copy link
Member

@SakiTakamachi SakiTakamachi commented Jan 19, 2024

The original test wasn't very good, so I improved it by the way.

  • TODO: Once the SDKs are merged, change the SDK repository URL back

@SakiTakamachi SakiTakamachi force-pushed the replace_imap_to_mailhog branch 18 times, most recently from 45b0a17 to a6c9cd4 Compare January 21, 2024 10:47
@SakiTakamachi SakiTakamachi self-assigned this Jan 21, 2024
@SakiTakamachi SakiTakamachi removed their assignment Jan 21, 2024
@SakiTakamachi SakiTakamachi force-pushed the replace_imap_to_mailhog branch from a6c9cd4 to aad70ab Compare January 21, 2024 11:42
@SakiTakamachi
Copy link
Member Author

SakiTakamachi commented Jan 21, 2024

I replaced imap with mailhog and refreshed the test.

Since the SDK has not been merged yet, it is temporarily downloading the SDK from my repository.

php/php-sdk-binary-tools#8

@SakiTakamachi SakiTakamachi marked this pull request as ready for review January 21, 2024 12:25
@SakiTakamachi SakiTakamachi changed the title [WIP] Replaced imap with mailhog and refreshed the test. Replaced imap with mailhog and refreshed the test. Jan 21, 2024
Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine? But I don't really understand email in the first place.

The only reason I was the maintainer for ext/imap was because I did the migration of resource to object

imap
--CONFLICTS--
imap
curl
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically, all of those tests also require JSON extension (which I know can't be disabled now; but who knows if this will always be the case)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I overlooked it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't set json as it cannot be disabled (we actually removed it from EXTENSIONS and skip parts in all tests when to got always enabled).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we actually remove them? I don't really see any harm in having it in the EXTENSIONS section as that section is mainly used for Windows to load shared extensions if available and skip if not.

Copy link
Member

@bukka bukka Jan 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah think it got removed from tests. It's not shared extension for Windows either so there is no point to specify it. It's like adding standard or spl there...

@staabm
Copy link
Contributor

staabm commented Jan 22, 2024

we are using mailhog for several years, so please take this as constructive feedback about problems mailhog has:

  • nearly not maintained
  • last time I looked at it, there was no support for issues in the tracker
  • when mails contain attachments you are running a use-cases which turn the webinterface to be super slaggy/slow
  • the chaos monkey feature can be enabled easily by any end-user by mistake, which makes testing super unreliable

we want to move to mailpit which is very similar, but seems more maintained and was created by its author mostly because of the above mentioned mailhog problems

@SakiTakamachi
Copy link
Member Author

SakiTakamachi commented Jan 22, 2024

@staabm
Thanks for the feedback!

Yeah, mailhog hasn't been updated in a long time, so my friend recommended mailpit to me.

But since these tests are for Windows, I needed to include an executable in the SDK. For now, I am planning to include only the 64-bit version of the executable file in the SDK, but depending on the situation, we may need to add the 32-bit version.

I'm sorry if I overlooked it, but the mailpit Windows version executable should only support 64bit.

Personally, I am thinking of using mailhog for a while, and if there are no requests for the 32-bit version, I will decide that there is no problem with just the 64-bit version, and then suggest switching to mailpit.

@iluuu1994
Copy link
Member

@SakiTakamachi Just in case you're unaware, the Windows 32-bit build runs on 64-bit Windows. So it seems like there should be no issue using the 64-bit mailpit service in the 32-bit build. Maybe I'm missing some details, I did not follow the conversation.

@SakiTakamachi
Copy link
Member Author

@iluuu1994
I see, in that case it might make sense to adopt mailpit. I'm going to replace it.

Copy link
Member

@bukka bukka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added some suggestions for improvement but it looks good in general.

Comment on lines +6 to +10
$c = curl_init();
curl_setopt($c, CURLOPT_URL, 'http://localhost:8025/api/v2/search?kind=to&query='.$to);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
$res = curl_exec($c);
curl_close($c);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why don't you just use following?

$res = file_get_contents("http://localhost:8025/api/v2/search?kind=to&query=$to");

that would remove unnecessary dependency on curl...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I completely forgot about it...

return json_decode($res, true);
}

function getHeaders ($response)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we mostly try to follow PSR-12 in tests (not strictly but better not to do space before ( in this case)

Comment on lines +58 to +63
$c = curl_init();
curl_setopt($c, CURLOPT_URL, 'http://localhost:8025/api/v2/messages/'.$id);
curl_setopt($c, CURLOPT_CUSTOMREQUEST, 'DELETE');
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
curl_exec($c);
curl_close($c);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use stream - in this case you will need to also pass stream context to set method

imap
--CONFLICTS--
imap
curl
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't set json as it cannot be disabled (we actually removed it from EXTENSIONS and skip parts in all tests when to got always enabled).

Comment on lines +65 to +69
$res &&
getFromAddress($res) === $from &&
getToAddresses($res)[0] === $to &&
getSubject($res) === $subject &&
getBody($res) === $message
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as this is pretty much repeated everywhere, it might make sense to have a a function in utils for this. Maybe something like:

mailCheckResponse($res, $from, $to, $subject, $message)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. I'll make it a function.

@@ -113,6 +113,7 @@ curl -sLo hMailServer.exe https://www.hmailserver.com/download_file/?downloadid=
hMailServer.exe /verysilent
cd %APPVEYOR_BUILD_FOLDER%
%PHP_BUILD_DIR%\php.exe -dextension_dir=%PHP_BUILD_DIR% -dextension=com_dotnet appveyor\setup_hmailserver.php
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can probably remove this like, right?

@SakiTakamachi
Copy link
Member Author

The mailpit version has been completed, so it has been closed.

@SakiTakamachi SakiTakamachi deleted the replace_imap_to_mailhog branch February 10, 2024 01:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants