14 std::cout
<< "sizeof(Session) == " << sizeof(Session
) << '\n';
15 std::cout
<< "sizeof(sock_) == " << sizeof(Session::sock_
) << '\n';
16 std::cout
<< "sizeof(client_) == " << sizeof(Session::client_
)
18 std::cout
<< "sizeof(reverse_path_) == " << sizeof(Session::reverse_path_
)
20 std::cout
<< "sizeof(forward_path_) == " << sizeof(Session::forward_path_
)
22 std::cout
<< "sizeof(binarymime_) == " << sizeof(Session::binarymime_
)
25 setenv("GHSMTP_SERVER_ID", "digilicious.com", 1);
27 int fd_null
= open("/dev/null", O_WRONLY
);
28 PCHECK(fd_null
>= 0) << " can't open /dev/null";
30 auto const config_path
= osutil::get_config_dir();
31 auto read_hook
= []() { std::cout
<< "Session-test read_hook\n"; };
32 Session
sess(config_path
, read_hook
, STDIN_FILENO
, fd_null
);
34 auto sender
{Domain
{"example.er"}}; // Not a public suffix
35 auto error_msg
{std::string
{}};
36 CHECK(sess
.verify_sender_domain_(sender
, error_msg
));
39 CHECK(!sess
.verify_sender_domain_(
40 Domain("invalid-domain-has-only-one-lable"), error_msg
));
43 CHECK(sess
.verify_sender_domain_(Domain("lots.of.lables.digilicious.com"),
45 CHECK(sess
.verify_sender_domain_(Domain("allowlisted.digilicious.com"),
47 CHECK(sess
.verify_sender_domain_(
48 Domain("reg-domain-is-allowlisted.digilicious.com"), error_msg
));
51 CHECK(sess
.verify_sender_domain_(Domain(""), error_msg
));
53 CHECK(!sess
.verify_sender_domain_(Domain("com"), error_msg
));
56 auto mb
{Mailbox
{"foo", "digilicious.com"}};
57 CHECK(sess
.verify_sender_spf_(mb
));
60 // auto error_msg{std::string{}};
61 // CHECK(!sess.verify_ip_address_("blocklisted.digilicious.com"s));
65 int main(int argc
, char* argv
[]) { Session_test::test(); }