aboutsummaryrefslogtreecommitdiff
path: root/lib/smtp/client_test.go
AgeCommit message (Collapse)Author
2026-01-15all: convert license and copyright to use SPDX identifiersShulhan
With help of spdxconv tool [1], we able to bulk update all files license and copyright format to comply with SPDX formats. [1] https://kilabit.info/project/spdxconv/
2024-03-05all: comply with linter recommendations #1Shulhan
Instead of annotating the lines that caught by linters, fix it to comply with the recommendations. This causes several breaking changes, especially related to naming, * api/slack: [Message.IconUrl] become [Message.IconURL] * lib/dns: DefaultSoaMinumumTtl become DefaultSoaMinimumTTL * lib/email: [Message.SetBodyHtml] become [Message.SetBodyHTML] * lib/http: [Client.GenerateHttpRequest] become [Client.GenerateHTTPRequest] * lib/http: [ClientOptions.ServerUrl] become [ClientOptions.ServerURL] * lib/http: [EndpointRequest.HttpWriter] become [EndpointRequest.HTTPWriter] * lib/http: [EndpointRequest.HttpRequest] become [EndpointRequest.HTTPRequest] * lib/http: [ServerOptions.EnableIndexHtml] become [ServerOptions.EnableIndexHTML] * lib/http: [SSEConn.HttpRequest] become [SSEConn.HTTPRequest] * lib/smtp: [ClientOptions.ServerUrl] become [ClientOptions.ServerURL] * lib/ssh/sftp: [FileAttrs.SetUid] become [FileAttrs.SetUID] * lib/ssh/sftp: [FileAttrs.Uid] become [FileAttrs.UID]
2024-03-02all: move the repository to "git.sr.ht/~shulhan/pakakeh.go"Shulhan
There are several reasons that why we move from github.com. First, related to the name of package. We accidentally name the package with "share" a common word in English that does not reflect the content of repository. By moving to other repository, we can rename it to better and unique name, in this "pakakeh.go". Pakakeh is Minang word for tools, and ".go" suffix indicate that the repository related to Go programming language. Second, supporting open source. The new repository is hosted under sourcehut.org, the founder is known to support open source, and all their services are licensed under AGPL, unlike GitHub that are closed sources. Third, regarding GitHub CoPilot. The GitHub Terms of Service [1], allow any public content that are hosted there granted them to parse the content. On one side, GitHub helps and flourish the open source, but on another side have an issues regarding scraping the copyleft license [2]. [1]: https://docs.github.com/en/site-policy/github-terms/github-terms-of-service#4-license-grant-to-us [2]: https://githubcopilotinvestigation.com
2023-12-13all: fix linter warnings reported by reviveShulhan
There are some reports that I disagree with revive, in example, code should not declare the type after variables. In my opinion, on some cases, declaring the type make the code more readable and explicit. Since I did not want to add new configuration file, we changes it and follow revive for now.
2023-05-30lib/smtp: implement Client SendEmailShulhan
Somehow in 3a1a2715b25f, we include this method without implementing it. The SendEmail method simplify sending email by automatically create [MailTx] for passing it to method Client.MailTx. The test right now use live connection since the Server is not ready yet.
2022-10-05lib/stmp: fix tests with -count=X, where X>1Shulhan
This changes require all unit tests to use their own client.
2022-02-18lib/smtp: refactoring NewClient to use struct instead of parametersShulhan
Previously, to create new client one must pass three parameters to NewClient function: localName, remoteURL, and insecure. If we want to add another parameters in the future, it will cause the function signature changes. This changes simplify creating NewClient by passing single struct with new parameters: AuthUser, AuthPass, and AuthMechanism. If both AuthUser and AuthPass is not empty, the NewClient will authenticate the connection, minimize number of step on the caller.
2022-02-18lib/smtp: rename Mechanism to SaslMechanismShulhan
2022-02-18lib/smtp: realign all structsShulhan
The goal is to minimize memory consumed by struct instance. Changes, * Client: from 112 to 80 bytes (-32 bytes) * Command: from 48 to 32 bytes (-8 bytes) * Domain: from 32 to 24 bytes (-8 bytes) * LocalStorage: from 72 to 40 bytes (-32 bytes) * MailTx: from 128 to 112 bytes (-16 bytes) * receiver: from 152 to 104 bytes (-48 bytes) * Response: from 32 to 24 bytes (-8 bytes) * Server: from 144 to 128 bytes (-16 bytes) * ServerInfo: from 40 to 32 bytes (-8 bytes)
2021-03-14all: refactoring the test.Assert and test.AssertBench signatureShulhan
Previously, the test.Assert and test.AssertBench functions has the boolean parameter to print the stack trace of test in case its not equal. Since this parameter is not mandatory and its usually always set to "true", we remove them from function signature to simplify the call to Assert and AssertBench.
2020-02-13smtp: Disable test on lookupShulhan
The lookup test should use local DNS server instead of relying on external DNS response.
2019-10-03smtp: remove test for NewClientShulhan
This test takes too long due to connection timed out.
2019-09-05all: fix test for Go 1.13Shulhan
2019-06-14smtp: fix test on Lookup ip addressShulhan
2019-03-31smtp: remove unused variable testClientSMTPAddressShulhan
2019-03-26smtp: make new client to be implicit connect with EHLOShulhan
Previously, Connect and Ehlo are separated functions that must be called by client manually to connect and to send EHLO command to server. This commit unexport Connect and Ehlo, and call them implicitly when creating NewClient. This minimize any command that require Ehlo first, for example when upgrading connection with STARTTLS and on mail transaction.
2019-03-26smtp: change the type of server info extension to map of stringShulhan
If we use slice of string to manage server extension we lost the extension parameter due to split by " " on extension string. This commit change the type of extension on ServerInfo as a mapping between extension name and their parameters.
2019-03-26smtp: change the NewClient remote address to URL based formatShulhan
Previously, the remote address parameter on NewClient use the format of "(hostname|ip-address)[:port]" to connect. This format does not have any flags to indicate whether server support TLS or not. We can check the port number and assume that port number 465 or 587 to support TLS, but we can't do TLS on non well known port. This commit change the remote address parameter to use URL based format, remoteURL = [ scheme "://" ](domain | IP-address [":" port]) scheme = "smtp" / "smtps" If scheme is "smtp", client will assume that no STARTTLS command will be issued after connection has been established; otherwise if scheme is "smtps", client will send STARTTLS command on any or missing port given in URL.
2019-02-26smtp: implement server with local handlerShulhan
LocalHandler is SMTP server that contains domain and user's accounts in server environment. The LocalHandler replace the HandlerPosix and remove unused Storage interface and field in server.
2019-02-26smtp: remove environment typesShulhan
The original purpose of environment is to allow bootstraping SMTP server using user defined methods (e.g. from file or database), but since primary or virtual domains is only set once, its setting can be acquired and set before server started using any methods. As replacement of environment, the primary domain (previously Hostname) and virtual domains (previously Domains) are embedded directly as fields of server.
2019-02-23smtp: use different port between normal listener and TLS listenerShulhan
By default normal listener will listen to port 25 and TLS port will listen on port 465.
2019-02-05lib/smtp: changes affected by refactoring on lib/io.ReaderShulhan
2019-01-29lib/smtp: fix error message with first-letter capital or end with newlineShulhan
2019-01-15lib/smtp: add unit test for NewClientShulhan
2019-01-15lib/smtp: export the field ServerInfo in Client structShulhan
The non nil ServerInfo indicate that client has been called EHLO or HELO before, which required for client to check whether server support AUTH extension or not.
2019-01-15lib/smtp: test client authentication with two handshakeShulhan
2019-01-15lib/smtp: implement SMTP service extension for Authentication (RFC 4954)Shulhan
The SMTP AUTH is implemented as a core command instead of as an extension.
2019-01-08lib/smtp: add option "insecure" to client ConnectShulhan
This option allow client to connect to server with self-signed certificate.
2019-01-07lib/smtp: library for SMTP server and clientShulhan