I think imposing extracting an optional port to AuthenticationConfig is not the right approach, trying to handle the default port ourself is not either, we tried that and fail (see bug #150860).
The simplest approach seems to be to extract the port in smtp_connection.py just before calling auth.get_user() (auth.get_password() can reuse that).
The relevant tests are in bzrlib/tests/test_smtp_connection.py and that's where you could add a test that reproduce the bug. You can then fix the code and the test will prove that your fix is correct.
I think imposing extracting an optional port to AuthenticationC onfig is not the right approach, trying to handle the default port ourself is not either, we tried that and fail (see bug #150860).
The simplest approach seems to be to extract the port in smtp_connection.py just before calling auth.get_user() (auth.get_ password( ) can reuse that).
The relevant tests are in bzrlib/ tests/test_ smtp_connection .py and that's where you could add a test that reproduce the bug. You can then fix the code and the test will prove that your fix is correct.