1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
/* Copyright (c) 2017-2018 Dovecot authors, see the included COPYING file */
#include "test-auth.h"
#include "auth-common.h"
#include "passdb.h"
struct auth_penalty *auth_penalty;
time_t process_start_time;
bool worker, worker_restart_request;
static struct passdb_module *mock_passdb_mod = NULL;
static pool_t mock_pool;
void auth_module_load(const char *names ATTR_UNUSED)
{
}
void auth_refresh_proctitle(void) {
}
static void passdb_mock_init(struct passdb_module *module ATTR_UNUSED)
{
}
static void passdb_mock_deinit(struct passdb_module *module ATTR_UNUSED)
{
}
static void passdb_mock_verify_plain(struct auth_request *request, const char *password ATTR_UNUSED,
verify_plain_callback_t *callback)
{
callback(PASSDB_RESULT_OK, request);
}
static void passdb_mock_lookup_credentials(struct auth_request *request,
lookup_credentials_callback_t *callback)
{
passdb_handle_credentials(PASSDB_RESULT_OK, "password", "PLAIN",
callback, request);
}
static struct passdb_module_interface mock_interface = {
.name = "mock",
.init = passdb_mock_init,
.deinit = passdb_mock_deinit,
.verify_plain = passdb_mock_verify_plain,
.lookup_credentials = passdb_mock_lookup_credentials,
};
struct auth_passdb_settings mock_passdb_set = {
.name = "mock",
.driver = "mock",
.args = "",
.default_fields = "",
.override_fields = "",
.mechanisms = "",
.username_filter = "",
.skip = "never",
.result_success = "return-ok",
.result_failure = "continue",
.result_internalfail = "continue",
.deny = FALSE,
.pass = FALSE,
.master = FALSE,
.auth_verbose = "default"
};
void passdb_mock_mod_init(void)
{
if (mock_passdb_mod != NULL)
return;
mock_pool = pool_allocfree_create("auth mock");
passdb_register_module(&mock_interface);
struct auth_passdb_settings set = {
.name = "mock",
.driver = "mock",
.args = "",
.default_fields = "",
.override_fields = "",
.mechanisms = "",
.username_filter = "",
.skip = "never",
.result_success = "return-ok",
.result_failure = "continue",
.result_internalfail = "continue",
.deny = FALSE,
.pass = FALSE,
.master = FALSE,
.auth_verbose = "default"
};
mock_passdb_mod = passdb_preinit(mock_pool, &set);
passdb_init(mock_passdb_mod);
}
void passdb_mock_mod_deinit(void)
{
passdb_deinit(mock_passdb_mod);
passdb_unregister_module(&mock_interface);
pool_unref(&mock_pool);
}
struct auth_passdb *passdb_mock(void)
{
struct auth_passdb *ret = i_new(struct auth_passdb, 1);
ret->set = &mock_passdb_set;
ret->passdb = mock_passdb_mod;
return ret;
}
|