mirror of
https://github.com/falk-werner/webfused
synced 2024-10-27 20:44:08 +00:00
use wrap utility
This commit is contained in:
parent
ea56c6e86c
commit
bd4323e53b
@ -18,12 +18,12 @@ using ::webfused_test::MockLibConfig;
|
||||
TEST(config, is_loadable)
|
||||
{
|
||||
StrictMock<MockConfigBuilder> builder;
|
||||
EXPECT_CALL(builder, create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, setLogger(_,_,_)).Times(1).WillOnce(Return(true));
|
||||
EXPECT_CALL(builder, setServerVhostname(StrEq("localhost"))).Times(1);
|
||||
EXPECT_CALL(builder, setServerPort(8080)).Times(1);
|
||||
EXPECT_CALL(builder, addAuthProvider(_, _)).Times(1).WillOnce(Return(true));
|
||||
EXPECT_CALL(builder, addFilesystem(_,_)).Times(1).WillOnce(Return(true));
|
||||
EXPECT_CALL(builder, wfd_config_create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, wfd_config_set_logger(_,_,_,_)).Times(1).WillOnce(Return(true));
|
||||
EXPECT_CALL(builder, wfd_config_set_server_vhostname(_,StrEq("localhost"))).Times(1);
|
||||
EXPECT_CALL(builder, wfd_config_set_server_port(_,8080)).Times(1);
|
||||
EXPECT_CALL(builder, wfd_config_add_auth_provider(_,_, _)).Times(1).WillOnce(Return(true));
|
||||
EXPECT_CALL(builder, wfd_config_add_filesystem(_,_,_)).Times(1).WillOnce(Return(true));
|
||||
|
||||
struct wfd_config * config = wfd_config_load_file("webfused.conf");
|
||||
ASSERT_NE(nullptr, config);
|
||||
@ -36,7 +36,7 @@ TEST(config, minimal_config)
|
||||
EXPECT_CALL(logger, onclose()).Times(1);
|
||||
|
||||
StrictMock<MockConfigBuilder> builder;
|
||||
EXPECT_CALL(builder, create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, wfd_config_create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
|
||||
char const minimal[] = "version = { major = 1, minor = 0 }\n";
|
||||
struct wfd_config * config = wfd_config_load_string(minimal);
|
||||
@ -50,8 +50,8 @@ TEST(config, invalid_config)
|
||||
EXPECT_CALL(logger, onclose()).Times(1);
|
||||
|
||||
StrictMock<MockConfigBuilder> builder;
|
||||
EXPECT_CALL(builder, create).Times(0);
|
||||
EXPECT_CALL(builder, dispose(_)).Times(0);
|
||||
EXPECT_CALL(builder, wfd_config_create).Times(0);
|
||||
EXPECT_CALL(builder, wfd_config_dispose(_)).Times(0);
|
||||
|
||||
char const syntax_error[] = "version.major = 1\n";
|
||||
|
||||
@ -66,8 +66,8 @@ TEST(config, invalid_config_file)
|
||||
EXPECT_CALL(logger, onclose()).Times(1);
|
||||
|
||||
StrictMock<MockConfigBuilder> builder;
|
||||
EXPECT_CALL(builder, create).Times(0);
|
||||
EXPECT_CALL(builder, dispose(_)).Times(0);
|
||||
EXPECT_CALL(builder, wfd_config_create).Times(0);
|
||||
EXPECT_CALL(builder, wfd_config_dispose(_)).Times(0);
|
||||
|
||||
struct wfd_config * config = wfd_config_load_file("invalid.conf");
|
||||
ASSERT_EQ(nullptr, config);
|
||||
@ -80,8 +80,8 @@ TEST(config, invalid_major_version_too_low)
|
||||
EXPECT_CALL(logger, onclose()).Times(1);
|
||||
|
||||
StrictMock<MockConfigBuilder> builder;
|
||||
EXPECT_CALL(builder, create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, dispose(_)).Times(1);
|
||||
EXPECT_CALL(builder, wfd_config_create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, wfd_config_dispose(_)).Times(1);
|
||||
|
||||
char const too_low[] = "version = { major = 0, minor = 0 }\n";
|
||||
|
||||
@ -96,8 +96,8 @@ TEST(config, invalid_major_version_too_high)
|
||||
EXPECT_CALL(logger, onclose()).Times(1);
|
||||
|
||||
StrictMock<MockConfigBuilder> builder;
|
||||
EXPECT_CALL(builder, create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, dispose(_)).Times(1);
|
||||
EXPECT_CALL(builder, wfd_config_create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, wfd_config_dispose(_)).Times(1);
|
||||
|
||||
char const too_high[] = "version = { major = 2, minor = 0 }\n";
|
||||
|
||||
@ -112,8 +112,8 @@ TEST(config, invalid_missing_major_version)
|
||||
EXPECT_CALL(logger, onclose()).Times(1);
|
||||
|
||||
StrictMock<MockConfigBuilder> builder;
|
||||
EXPECT_CALL(builder, create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, dispose(_)).Times(1);
|
||||
EXPECT_CALL(builder, wfd_config_create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, wfd_config_dispose(_)).Times(1);
|
||||
|
||||
char const too_high[] = "version = { minor = 0 }\n";
|
||||
|
||||
@ -128,8 +128,8 @@ TEST(config, invalid_missing_minor_version)
|
||||
EXPECT_CALL(logger, onclose()).Times(1);
|
||||
|
||||
StrictMock<MockConfigBuilder> builder;
|
||||
EXPECT_CALL(builder, create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, dispose(_)).Times(1);
|
||||
EXPECT_CALL(builder, wfd_config_create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, wfd_config_dispose(_)).Times(1);
|
||||
|
||||
char const too_high[] = "version = { major = 1 }\n";
|
||||
|
||||
@ -144,7 +144,7 @@ TEST(config, valid_older_minor)
|
||||
EXPECT_CALL(logger, onclose()).Times(1);
|
||||
|
||||
StrictMock<MockConfigBuilder> builder;
|
||||
EXPECT_CALL(builder, create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, wfd_config_create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
|
||||
char const valid[] = "version = { major = 1, minor = -1 }\n";
|
||||
|
||||
@ -159,7 +159,7 @@ TEST(config, valid_newer_minor)
|
||||
EXPECT_CALL(logger, onclose()).Times(1);
|
||||
|
||||
StrictMock<MockConfigBuilder> builder;
|
||||
EXPECT_CALL(builder, create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, wfd_config_create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
|
||||
char const valid[] = "version = { major = 1, minor = 1 }\n";
|
||||
|
||||
@ -174,8 +174,8 @@ TEST(config, vhost_name)
|
||||
EXPECT_CALL(logger, onclose()).Times(1);
|
||||
|
||||
StrictMock<MockConfigBuilder> builder;
|
||||
EXPECT_CALL(builder, create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, setServerVhostname(StrEq("some.host"))).Times(1);
|
||||
EXPECT_CALL(builder, wfd_config_create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, wfd_config_set_server_vhostname(_,StrEq("some.host"))).Times(1);
|
||||
|
||||
char const config_text[] =
|
||||
"version = { major = 1, minor = 0 }\n"
|
||||
@ -195,8 +195,8 @@ TEST(config, port)
|
||||
EXPECT_CALL(logger, onclose()).Times(1);
|
||||
|
||||
StrictMock<MockConfigBuilder> builder;
|
||||
EXPECT_CALL(builder, create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, setServerPort(54321)).Times(1);
|
||||
EXPECT_CALL(builder, wfd_config_create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, wfd_config_set_server_port(_,54321)).Times(1);
|
||||
|
||||
char const config_text[] =
|
||||
"version = { major = 1, minor = 0 }\n"
|
||||
@ -216,8 +216,8 @@ TEST(config, tls_certificate)
|
||||
EXPECT_CALL(logger, onclose()).Times(1);
|
||||
|
||||
StrictMock<MockConfigBuilder> builder;
|
||||
EXPECT_CALL(builder, create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, setServerCert(StrEq("/path/to/cert.pem"))).Times(1);
|
||||
EXPECT_CALL(builder, wfd_config_create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, wfd_config_set_server_cert(_, StrEq("/path/to/cert.pem"))).Times(1);
|
||||
|
||||
char const config_text[] =
|
||||
"version = { major = 1, minor = 0 }\n"
|
||||
@ -240,8 +240,8 @@ TEST(config, tls_key)
|
||||
EXPECT_CALL(logger, onclose()).Times(1);
|
||||
|
||||
StrictMock<MockConfigBuilder> builder;
|
||||
EXPECT_CALL(builder, create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, setServerKey(StrEq("/path/to/key.pem"))).Times(1);
|
||||
EXPECT_CALL(builder, wfd_config_create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, wfd_config_set_server_key(_,StrEq("/path/to/key.pem"))).Times(1);
|
||||
|
||||
char const config_text[] =
|
||||
"version = { major = 1, minor = 0 }\n"
|
||||
@ -264,8 +264,8 @@ TEST(config, document_root)
|
||||
EXPECT_CALL(logger, onclose()).Times(1);
|
||||
|
||||
StrictMock<MockConfigBuilder> builder;
|
||||
EXPECT_CALL(builder, create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, setServerDocumentRoot(StrEq("/var/www"))).Times(1);
|
||||
EXPECT_CALL(builder, wfd_config_create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, wfd_config_set_server_document_root(_,StrEq("/var/www"))).Times(1);
|
||||
|
||||
char const config_text[] =
|
||||
"version = { major = 1, minor = 0 }\n"
|
||||
@ -285,8 +285,8 @@ TEST(config, authentication)
|
||||
EXPECT_CALL(logger, onclose()).Times(1);
|
||||
|
||||
StrictMock<MockConfigBuilder> builder;
|
||||
EXPECT_CALL(builder, create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, addAuthProvider(_, _)).Times(1).WillOnce(Return(true));
|
||||
EXPECT_CALL(builder, wfd_config_create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, wfd_config_add_auth_provider(_,_, _)).Times(1).WillOnce(Return(true));
|
||||
|
||||
char const config_text[] =
|
||||
"version = { major = 1, minor = 0 }\n"
|
||||
@ -309,9 +309,9 @@ TEST(config, failed_create_authenticator)
|
||||
EXPECT_CALL(logger, onclose()).Times(1);
|
||||
|
||||
StrictMock<MockConfigBuilder> builder;
|
||||
EXPECT_CALL(builder, create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, dispose(_)).Times(1);
|
||||
EXPECT_CALL(builder, addAuthProvider(_, _)).Times(1).WillOnce(Return(false));
|
||||
EXPECT_CALL(builder, wfd_config_create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, wfd_config_dispose(_)).Times(1);
|
||||
EXPECT_CALL(builder, wfd_config_add_auth_provider(_,_, _)).Times(1).WillOnce(Return(false));
|
||||
|
||||
char const config_text[] =
|
||||
"version = { major = 1, minor = 0 }\n"
|
||||
@ -334,8 +334,8 @@ TEST(config, failed_missing_auth_provider)
|
||||
EXPECT_CALL(logger, onclose()).Times(1);
|
||||
|
||||
StrictMock<MockConfigBuilder> builder;
|
||||
EXPECT_CALL(builder, create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, dispose(_)).Times(1);
|
||||
EXPECT_CALL(builder, wfd_config_create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, wfd_config_dispose(_)).Times(1);
|
||||
|
||||
char const config_text[] =
|
||||
"version = { major = 1, minor = 0 }\n"
|
||||
@ -357,8 +357,8 @@ TEST(config, failed_missing_auth_settings)
|
||||
EXPECT_CALL(logger, onclose()).Times(1);
|
||||
|
||||
StrictMock<MockConfigBuilder> builder;
|
||||
EXPECT_CALL(builder, create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, dispose(_)).Times(1);
|
||||
EXPECT_CALL(builder, wfd_config_create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, wfd_config_dispose(_)).Times(1);
|
||||
|
||||
char const config_text[] =
|
||||
"version = { major = 1, minor = 0 }\n"
|
||||
@ -380,8 +380,8 @@ TEST(config, failed_auth_settings_get_elem)
|
||||
EXPECT_CALL(logger, onclose()).Times(1);
|
||||
|
||||
StrictMock<MockConfigBuilder> builder;
|
||||
EXPECT_CALL(builder, create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, dispose(_)).Times(1);
|
||||
EXPECT_CALL(builder, wfd_config_create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, wfd_config_dispose(_)).Times(1);
|
||||
|
||||
MockLibConfig libconfig;
|
||||
EXPECT_CALL(libconfig, config_setting_get_elem(_,_)).Times(1).WillOnce(Return(nullptr));
|
||||
@ -407,8 +407,8 @@ TEST(config, filesystems)
|
||||
EXPECT_CALL(logger, onclose()).Times(1);
|
||||
|
||||
StrictMock<MockConfigBuilder> builder;
|
||||
EXPECT_CALL(builder, create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, addFilesystem(_, _)).Times(1).WillOnce(Return(true));
|
||||
EXPECT_CALL(builder, wfd_config_create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, wfd_config_add_filesystem(_,_, _)).Times(1).WillOnce(Return(true));
|
||||
|
||||
char const config_text[] =
|
||||
"version = { major = 1, minor = 0 }\n"
|
||||
@ -428,8 +428,8 @@ TEST(config, filesystems_empty)
|
||||
EXPECT_CALL(logger, onclose()).Times(1);
|
||||
|
||||
StrictMock<MockConfigBuilder> builder;
|
||||
EXPECT_CALL(builder, create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, addFilesystem(_, _)).Times(0);
|
||||
EXPECT_CALL(builder, wfd_config_create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, wfd_config_add_filesystem(_,_, _)).Times(0);
|
||||
|
||||
char const config_text[] =
|
||||
"version = { major = 1, minor = 0 }\n"
|
||||
@ -448,9 +448,9 @@ TEST(config, filesystems_failed_add)
|
||||
EXPECT_CALL(logger, onclose()).Times(1);
|
||||
|
||||
StrictMock<MockConfigBuilder> builder;
|
||||
EXPECT_CALL(builder, create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, dispose(_)).Times(1);
|
||||
EXPECT_CALL(builder, addFilesystem(_, _)).Times(1).WillOnce(Return(false));
|
||||
EXPECT_CALL(builder, wfd_config_create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, wfd_config_dispose(_)).Times(1);
|
||||
EXPECT_CALL(builder, wfd_config_add_filesystem(_,_, _)).Times(1).WillOnce(Return(false));
|
||||
|
||||
char const config_text[] =
|
||||
"version = { major = 1, minor = 0 }\n"
|
||||
@ -470,9 +470,9 @@ TEST(config, filesystems_failed_missing_name)
|
||||
EXPECT_CALL(logger, onclose()).Times(1);
|
||||
|
||||
StrictMock<MockConfigBuilder> builder;
|
||||
EXPECT_CALL(builder, create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, dispose(_)).Times(1);
|
||||
EXPECT_CALL(builder, addFilesystem(_, _)).Times(0);
|
||||
EXPECT_CALL(builder, wfd_config_create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, wfd_config_dispose(_)).Times(1);
|
||||
EXPECT_CALL(builder, wfd_config_add_filesystem(_,_, _)).Times(0);
|
||||
|
||||
char const config_text[] =
|
||||
"version = { major = 1, minor = 0 }\n"
|
||||
@ -492,9 +492,9 @@ TEST(config, filesystems_failed_missing_mountpoint)
|
||||
EXPECT_CALL(logger, onclose()).Times(1);
|
||||
|
||||
StrictMock<MockConfigBuilder> builder;
|
||||
EXPECT_CALL(builder, create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, dispose(_)).Times(1);
|
||||
EXPECT_CALL(builder, addFilesystem(_, _)).Times(0);
|
||||
EXPECT_CALL(builder, wfd_config_create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, wfd_config_dispose(_)).Times(1);
|
||||
EXPECT_CALL(builder, wfd_config_add_filesystem(_,_, _)).Times(0);
|
||||
|
||||
char const config_text[] =
|
||||
"version = { major = 1, minor = 0 }\n"
|
||||
@ -514,9 +514,9 @@ TEST(config, filesystems_failed_missing_elem)
|
||||
EXPECT_CALL(logger, onclose()).Times(1);
|
||||
|
||||
StrictMock<MockConfigBuilder> builder;
|
||||
EXPECT_CALL(builder, create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, dispose(_)).Times(1);
|
||||
EXPECT_CALL(builder, addFilesystem(_, _)).Times(0);
|
||||
EXPECT_CALL(builder, wfd_config_create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, wfd_config_dispose(_)).Times(1);
|
||||
EXPECT_CALL(builder, wfd_config_add_filesystem(_,_, _)).Times(0);
|
||||
|
||||
MockLibConfig libconfig;
|
||||
EXPECT_CALL(libconfig, config_setting_get_elem(_,_)).Times(1).WillOnce(Return(nullptr));
|
||||
@ -539,8 +539,8 @@ TEST(config, log)
|
||||
EXPECT_CALL(logger, onclose()).Times(1);
|
||||
|
||||
StrictMock<MockConfigBuilder> builder;
|
||||
EXPECT_CALL(builder, create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, setLogger(_, _, _)).Times(1).WillOnce(Return(true));
|
||||
EXPECT_CALL(builder, wfd_config_create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, wfd_config_set_logger(_,_, _, _)).Times(1).WillOnce(Return(true));
|
||||
|
||||
char const config_text[] =
|
||||
"version = { major = 1, minor = 0 }\n"
|
||||
@ -561,9 +561,9 @@ TEST(config, log_fail_set_logger)
|
||||
EXPECT_CALL(logger, onclose()).Times(1);
|
||||
|
||||
StrictMock<MockConfigBuilder> builder;
|
||||
EXPECT_CALL(builder, create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, dispose(_)).Times(1);
|
||||
EXPECT_CALL(builder, setLogger(_, _, _)).Times(1).WillOnce(Return(false));
|
||||
EXPECT_CALL(builder, wfd_config_create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, wfd_config_dispose(_)).Times(1);
|
||||
EXPECT_CALL(builder, wfd_config_set_logger(_,_, _, _)).Times(1).WillOnce(Return(false));
|
||||
|
||||
char const config_text[] =
|
||||
"version = { major = 1, minor = 0 }\n"
|
||||
@ -584,9 +584,9 @@ TEST(config, log_fail_missing_provider)
|
||||
EXPECT_CALL(logger, onclose()).Times(1);
|
||||
|
||||
StrictMock<MockConfigBuilder> builder;
|
||||
EXPECT_CALL(builder, create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, dispose(_)).Times(1);
|
||||
EXPECT_CALL(builder, setLogger(_, _, _)).Times(0);
|
||||
EXPECT_CALL(builder, wfd_config_create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, wfd_config_dispose(_)).Times(1);
|
||||
EXPECT_CALL(builder, wfd_config_set_logger(_,_, _, _)).Times(0);
|
||||
|
||||
char const config_text[] =
|
||||
"version = { major = 1, minor = 0 }\n"
|
||||
@ -606,9 +606,9 @@ TEST(config, log_fail_missing_level)
|
||||
EXPECT_CALL(logger, onclose()).Times(1);
|
||||
|
||||
StrictMock<MockConfigBuilder> builder;
|
||||
EXPECT_CALL(builder, create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, dispose(_)).Times(1);
|
||||
EXPECT_CALL(builder, setLogger(_, _, _)).Times(0);
|
||||
EXPECT_CALL(builder, wfd_config_create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, wfd_config_dispose(_)).Times(1);
|
||||
EXPECT_CALL(builder, wfd_config_set_logger(_,_, _, _)).Times(0);
|
||||
|
||||
char const config_text[] =
|
||||
"version = { major = 1, minor = 0 }\n"
|
||||
@ -629,9 +629,9 @@ TEST(config, log_fail_invalid_level)
|
||||
EXPECT_CALL(logger, onclose()).Times(1);
|
||||
|
||||
StrictMock<MockConfigBuilder> builder;
|
||||
EXPECT_CALL(builder, create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, dispose(_)).Times(1);
|
||||
EXPECT_CALL(builder, setLogger(_, _, _)).Times(0);
|
||||
EXPECT_CALL(builder, wfd_config_create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, wfd_config_dispose(_)).Times(1);
|
||||
EXPECT_CALL(builder, wfd_config_set_logger(_, _, _, _)).Times(0);
|
||||
|
||||
char const config_text[] =
|
||||
"version = { major = 1, minor = 0 }\n"
|
||||
@ -651,8 +651,8 @@ TEST(config, set_user)
|
||||
EXPECT_CALL(logger, onclose()).Times(1);
|
||||
|
||||
StrictMock<MockConfigBuilder> builder;
|
||||
EXPECT_CALL(builder, create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, setUser(_, _)).Times(1);
|
||||
EXPECT_CALL(builder, wfd_config_create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, wfd_config_set_user(_, _, _)).Times(1);
|
||||
|
||||
char const config_text[] =
|
||||
"version = { major = 1, minor = 0 }\n"
|
||||
@ -673,9 +673,9 @@ TEST(config, set_user_fail_missing_name)
|
||||
EXPECT_CALL(logger, onclose()).Times(1);
|
||||
|
||||
StrictMock<MockConfigBuilder> builder;
|
||||
EXPECT_CALL(builder, create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, dispose(_)).Times(1);
|
||||
EXPECT_CALL(builder, setUser(_, _)).Times(0);
|
||||
EXPECT_CALL(builder, wfd_config_create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, wfd_config_dispose(_)).Times(1);
|
||||
EXPECT_CALL(builder, wfd_config_set_user(_, _, _)).Times(0);
|
||||
|
||||
char const config_text[] =
|
||||
"version = { major = 1, minor = 0 }\n"
|
||||
@ -695,9 +695,9 @@ TEST(config, set_user_fail_missing_group)
|
||||
EXPECT_CALL(logger, onclose()).Times(1);
|
||||
|
||||
StrictMock<MockConfigBuilder> builder;
|
||||
EXPECT_CALL(builder, create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, dispose(_)).Times(1);
|
||||
EXPECT_CALL(builder, setUser(_, _)).Times(0);
|
||||
EXPECT_CALL(builder, wfd_config_create).Times(1).WillOnce(Return(builder.getBuilder()));
|
||||
EXPECT_CALL(builder, wfd_config_dispose(_)).Times(1);
|
||||
EXPECT_CALL(builder, wfd_config_set_user(_, _, _)).Times(0);
|
||||
|
||||
char const config_text[] =
|
||||
"version = { major = 1, minor = 0 }\n"
|
||||
|
@ -1,235 +1,21 @@
|
||||
#include "mock/config_builder.hpp"
|
||||
#include "util/wrap.hpp"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
using webfused_test::IConfigBuilder;
|
||||
|
||||
static IConfigBuilder * wfd_MockConfigBuilder = nullptr;
|
||||
|
||||
extern struct wfd_config *
|
||||
__real_wfd_config_create(void);
|
||||
|
||||
extern void
|
||||
__real_wfd_config_dispose(
|
||||
struct wfd_config * config);
|
||||
|
||||
extern void
|
||||
__real_wfd_config_set_server_vhostname(
|
||||
struct wfd_config * config,
|
||||
char const * vhost_name);
|
||||
|
||||
extern void
|
||||
__real_wfd_config_set_server_port(
|
||||
struct wfd_config * config,
|
||||
int port);
|
||||
|
||||
extern void
|
||||
__real_wfd_config_set_server_key(
|
||||
struct wfd_config * config,
|
||||
char const * key_path);
|
||||
|
||||
extern void
|
||||
__real_wfd_config_set_server_cert(
|
||||
struct wfd_config * config,
|
||||
char const * cert_path);
|
||||
|
||||
extern void
|
||||
__real_wfd_config_set_server_document_root(
|
||||
struct wfd_config * config,
|
||||
char const * document_root);
|
||||
|
||||
extern bool
|
||||
__real_wfd_config_add_auth_provider(
|
||||
struct wfd_config * config,
|
||||
char const * provider,
|
||||
struct wfd_settings * settings);
|
||||
|
||||
extern bool
|
||||
__real_wfd_config_add_filesystem(
|
||||
struct wfd_config * config,
|
||||
char const * name,
|
||||
char const * mount_point);
|
||||
|
||||
extern bool
|
||||
__real_wfd_config_set_logger(
|
||||
struct wfd_config * config,
|
||||
char const * provider,
|
||||
int level,
|
||||
struct wfd_settings * settings);
|
||||
|
||||
extern void
|
||||
__real_wfd_config_set_user(
|
||||
struct wfd_config * config,
|
||||
char const * user,
|
||||
char const * group);
|
||||
|
||||
struct wfd_config *
|
||||
__wrap_wfd_config_create(void)
|
||||
{
|
||||
if (nullptr == wfd_MockConfigBuilder)
|
||||
{
|
||||
return __real_wfd_config_create();
|
||||
}
|
||||
else
|
||||
{
|
||||
return wfd_MockConfigBuilder->create();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
__wrap_wfd_config_dispose(
|
||||
struct wfd_config * config)
|
||||
{
|
||||
if (nullptr == wfd_MockConfigBuilder)
|
||||
{
|
||||
__real_wfd_config_dispose(config);
|
||||
}
|
||||
else
|
||||
{
|
||||
wfd_MockConfigBuilder->dispose(config);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
__wrap_wfd_config_set_server_vhostname(
|
||||
struct wfd_config * config,
|
||||
char const * vhost_name)
|
||||
{
|
||||
if (nullptr == wfd_MockConfigBuilder)
|
||||
{
|
||||
__real_wfd_config_set_server_vhostname(config, vhost_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
wfd_MockConfigBuilder->setServerVhostname(vhost_name);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
__wrap_wfd_config_set_server_port(
|
||||
struct wfd_config * config,
|
||||
int port)
|
||||
{
|
||||
if (nullptr == wfd_MockConfigBuilder)
|
||||
{
|
||||
__real_wfd_config_set_server_port(config, port);
|
||||
}
|
||||
else
|
||||
{
|
||||
wfd_MockConfigBuilder->setServerPort(port);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
__wrap_wfd_config_set_server_key(
|
||||
struct wfd_config * config,
|
||||
char const * key_path)
|
||||
{
|
||||
if (nullptr == wfd_MockConfigBuilder)
|
||||
{
|
||||
__real_wfd_config_set_server_key(config, key_path);
|
||||
}
|
||||
else
|
||||
{
|
||||
wfd_MockConfigBuilder->setServerKey(key_path);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
__wrap_wfd_config_set_server_cert(
|
||||
struct wfd_config * config,
|
||||
char const * cert_path)
|
||||
{
|
||||
if (nullptr == wfd_MockConfigBuilder)
|
||||
{
|
||||
__real_wfd_config_set_server_cert(config, cert_path);
|
||||
}
|
||||
else
|
||||
{
|
||||
wfd_MockConfigBuilder->setServerCert(cert_path);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
__wrap_wfd_config_set_server_document_root(
|
||||
struct wfd_config * config,
|
||||
char const * document_root)
|
||||
{
|
||||
if (nullptr == wfd_MockConfigBuilder)
|
||||
{
|
||||
__real_wfd_config_set_server_document_root(config, document_root);
|
||||
}
|
||||
else
|
||||
{
|
||||
wfd_MockConfigBuilder->setServerDocumentRoot(document_root);
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
__wrap_wfd_config_add_auth_provider(
|
||||
struct wfd_config * config,
|
||||
char const * provider,
|
||||
struct wfd_settings * settings)
|
||||
{
|
||||
if (nullptr == wfd_MockConfigBuilder)
|
||||
{
|
||||
return __real_wfd_config_add_auth_provider(config, provider, settings);
|
||||
}
|
||||
else
|
||||
{
|
||||
return wfd_MockConfigBuilder->addAuthProvider(provider, settings);
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
__wrap_wfd_config_add_filesystem(
|
||||
struct wfd_config * config,
|
||||
char const * name,
|
||||
char const * mount_point)
|
||||
{
|
||||
if (nullptr == wfd_MockConfigBuilder)
|
||||
{
|
||||
return __real_wfd_config_add_filesystem(config, name, mount_point);
|
||||
}
|
||||
else
|
||||
{
|
||||
return wfd_MockConfigBuilder->addFilesystem(name, mount_point);
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
__wrap_wfd_config_set_logger(
|
||||
struct wfd_config * config,
|
||||
char const * provider,
|
||||
int level,
|
||||
struct wfd_settings * settings)
|
||||
{
|
||||
if (nullptr == wfd_MockConfigBuilder)
|
||||
{
|
||||
return __real_wfd_config_set_logger(config, provider, level, settings);
|
||||
}
|
||||
else
|
||||
{
|
||||
return wfd_MockConfigBuilder->setLogger(provider, level, settings);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
__wrap_wfd_config_set_user(
|
||||
struct wfd_config * config,
|
||||
char const * user,
|
||||
char const * group)
|
||||
{
|
||||
if (nullptr == wfd_MockConfigBuilder)
|
||||
{
|
||||
__real_wfd_config_set_user(config, user, group);
|
||||
}
|
||||
else
|
||||
{
|
||||
wfd_MockConfigBuilder->setUser(user, group);
|
||||
}
|
||||
}
|
||||
static webfused_test::IConfigBuilder * wfd_MockConfigBuilder = nullptr;
|
||||
|
||||
WFD_WRAP_FUNC0(wfd_MockConfigBuilder, wfd_config *, wfd_config_create);
|
||||
WFD_WRAP_FUNC1(wfd_MockConfigBuilder, void, wfd_config_dispose, wfd_config *);
|
||||
WFD_WRAP_FUNC2(wfd_MockConfigBuilder, void, wfd_config_set_server_vhostname, wfd_config *, char const *);
|
||||
WFD_WRAP_FUNC2(wfd_MockConfigBuilder, void, wfd_config_set_server_port, wfd_config *, int);
|
||||
WFD_WRAP_FUNC2(wfd_MockConfigBuilder, void, wfd_config_set_server_key, wfd_config *, char const *);
|
||||
WFD_WRAP_FUNC2(wfd_MockConfigBuilder, void, wfd_config_set_server_cert, wfd_config *, char const *);
|
||||
WFD_WRAP_FUNC2(wfd_MockConfigBuilder, void, wfd_config_set_server_document_root, wfd_config *, char const *);
|
||||
WFD_WRAP_FUNC3(wfd_MockConfigBuilder, bool, wfd_config_add_auth_provider, wfd_config *, char const *, wfd_settings *);
|
||||
WFD_WRAP_FUNC3(wfd_MockConfigBuilder, bool, wfd_config_add_filesystem, wfd_config *, char const *, char const *);
|
||||
WFD_WRAP_FUNC4(wfd_MockConfigBuilder, bool, wfd_config_set_logger, wfd_config *, char const *, int, wfd_settings *);
|
||||
WFD_WRAP_FUNC3(wfd_MockConfigBuilder, void, wfd_config_set_user, wfd_config *, char const *, char const *);
|
||||
}
|
||||
|
||||
namespace webfused_test
|
||||
|
@ -11,17 +11,17 @@ class IConfigBuilder
|
||||
{
|
||||
public:
|
||||
virtual ~IConfigBuilder() = default;
|
||||
virtual wfd_config * create(void) = 0;
|
||||
virtual void dispose(wfd_config * config) = 0;
|
||||
virtual void setServerVhostname(char const * vhostname) = 0;
|
||||
virtual void setServerPort(int port) = 0;
|
||||
virtual void setServerKey(char const * key_path) = 0;
|
||||
virtual void setServerCert(char const * cert_path) = 0;
|
||||
virtual void setServerDocumentRoot(char const * document_root) = 0;
|
||||
virtual bool addAuthProvider(char const * provider, wfd_settings * settings) = 0;
|
||||
virtual bool addFilesystem(char const * name, char const * mountpoint) = 0;
|
||||
virtual bool setLogger(char const * provider, int level, wfd_settings * settings) = 0;
|
||||
virtual void setUser(char const * user, char const * group) = 0;
|
||||
virtual wfd_config * wfd_config_create(void) = 0;
|
||||
virtual void wfd_config_dispose(wfd_config * config) = 0;
|
||||
virtual void wfd_config_set_server_vhostname(wfd_config * config, char const * vhostname) = 0;
|
||||
virtual void wfd_config_set_server_port(wfd_config * config, int port) = 0;
|
||||
virtual void wfd_config_set_server_key(wfd_config * config, char const * key_path) = 0;
|
||||
virtual void wfd_config_set_server_cert(wfd_config * config, char const * cert_path) = 0;
|
||||
virtual void wfd_config_set_server_document_root(wfd_config * config, char const * document_root) = 0;
|
||||
virtual bool wfd_config_add_auth_provider(wfd_config * config, char const * provider, wfd_settings * settings) = 0;
|
||||
virtual bool wfd_config_add_filesystem(wfd_config * config, char const * name, char const * mountpoint) = 0;
|
||||
virtual bool wfd_config_set_logger(wfd_config * config, char const * provider, int level, wfd_settings * settings) = 0;
|
||||
virtual void wfd_config_set_user(wfd_config * config, char const * user, char const * group) = 0;
|
||||
};
|
||||
|
||||
class MockConfigBuilder: public IConfigBuilder
|
||||
@ -29,17 +29,17 @@ class MockConfigBuilder: public IConfigBuilder
|
||||
public:
|
||||
MockConfigBuilder();
|
||||
~MockConfigBuilder() override;
|
||||
MOCK_METHOD0(create, wfd_config * (void));
|
||||
MOCK_METHOD1(dispose, void (wfd_config * config));
|
||||
MOCK_METHOD1(setServerVhostname, void (char const * vhostname));
|
||||
MOCK_METHOD1(setServerPort, void (int port));
|
||||
MOCK_METHOD1(setServerKey, void (char const * key_path));
|
||||
MOCK_METHOD1(setServerCert, void (char const * cert_path));
|
||||
MOCK_METHOD1(setServerDocumentRoot, void (char const * document_root));
|
||||
MOCK_METHOD2(addAuthProvider, bool (char const * provider, wfd_settings * settings));
|
||||
MOCK_METHOD2(addFilesystem, bool (char const * name, char const * mountpoint));
|
||||
MOCK_METHOD3(setLogger, bool (char const * provider, int level, wfd_settings * settings));
|
||||
MOCK_METHOD2(setUser, void (char const * user, char const * group));
|
||||
MOCK_METHOD0(wfd_config_create, wfd_config * (void));
|
||||
MOCK_METHOD1(wfd_config_dispose, void (wfd_config * config));
|
||||
MOCK_METHOD2(wfd_config_set_server_vhostname, void (wfd_config * config, char const * vhostname));
|
||||
MOCK_METHOD2(wfd_config_set_server_port, void (wfd_config * config, int port));
|
||||
MOCK_METHOD2(wfd_config_set_server_key, void (wfd_config * config, char const * key_path));
|
||||
MOCK_METHOD2(wfd_config_set_server_cert, void (wfd_config * config, char const * cert_path));
|
||||
MOCK_METHOD2(wfd_config_set_server_document_root, void (wfd_config * config, char const * document_root));
|
||||
MOCK_METHOD3(wfd_config_add_auth_provider, bool (wfd_config * config, char const * provider, wfd_settings * settings));
|
||||
MOCK_METHOD3(wfd_config_add_filesystem, bool (wfd_config * config, char const * name, char const * mountpoint));
|
||||
MOCK_METHOD4(wfd_config_set_logger, bool (wfd_config * config, char const * provider, int level, wfd_settings * settings));
|
||||
MOCK_METHOD3(wfd_config_set_user, void (wfd_config * config, char const * user, char const * group));
|
||||
|
||||
struct wfd_config * getBuilder();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user