From 0aadf891a86b7a3f430aaeb4bc234c66df9a1a06 Mon Sep 17 00:00:00 2001 From: Falk Werner Date: Sun, 24 Mar 2019 04:00:06 +0100 Subject: [PATCH] adds type casts between API and implementation --- lib/wsfs/adapter/api.c | 40 +++++++++++++------------ lib/wsfs/adapter/impl/authenticate.h | 23 ++++++++++++++ lib/wsfs/adapter/impl/authenticator.c | 4 +-- lib/wsfs/adapter/impl/authenticator.h | 10 ++++--- lib/wsfs/adapter/impl/authenticators.c | 4 +-- lib/wsfs/adapter/impl/authenticators.h | 8 ++--- lib/wsfs/adapter/impl/credentials.c | 8 ++--- lib/wsfs/adapter/impl/credentials.h | 10 +++---- lib/wsfs/adapter/impl/server.c | 26 ++++++++-------- lib/wsfs/adapter/impl/server.h | 14 ++++----- lib/wsfs/adapter/impl/server_config.c | 32 ++++++++++---------- lib/wsfs/adapter/impl/server_config.h | 30 +++++++++---------- lib/wsfs/adapter/impl/server_protocol.c | 20 ++++++------- lib/wsfs/adapter/impl/server_protocol.h | 16 +++++----- lib/wsfs/adapter/impl/session.c | 2 +- lib/wsfs/adapter/impl/session.h | 4 +-- test/mock_authenticator.cc | 6 ++-- test/mock_authenticator.hpp | 10 +++---- test/test_authenticator.cc | 4 +-- test/test_authenticators.cc | 6 ++-- test/test_credentials.cc | 10 +++---- 21 files changed, 157 insertions(+), 130 deletions(-) create mode 100644 lib/wsfs/adapter/impl/authenticate.h diff --git a/lib/wsfs/adapter/api.c b/lib/wsfs/adapter/api.c index 752215a..73057df 100644 --- a/lib/wsfs/adapter/api.c +++ b/lib/wsfs/adapter/api.c @@ -4,31 +4,32 @@ #include "wsfs/adapter/impl/server_protocol.h" #include "wsfs/adapter/impl/server_config.h" #include "wsfs/adapter/impl/credentials.h" +#include "wsfs/adapter/impl/authenticate.h" // server struct wsfs_server * wsfs_server_create( struct wsfs_server_config * config) { - return server_create(config); + return (struct wsfs_server *) server_create((struct server_config*) config); } void wsfs_server_dispose( struct wsfs_server * server) { - server_dispose(server); + server_dispose((struct server *) server); } void wsfs_server_run( struct wsfs_server * server) { - server_run(server); + server_run((struct server *) server); } void wsfs_server_shutdown( struct wsfs_server * server) { - server_shutdown(server); + server_shutdown((struct server *) server); } // server protocol @@ -36,20 +37,20 @@ void wsfs_server_shutdown( struct wsfs_server_protocol * wsfs_server_protocol_create( char * mount_point) { - return server_protocol_create(mount_point); + return (struct wsfs_server_protocol *) server_protocol_create(mount_point); } void wsfs_server_protocol_dispose( struct wsfs_server_protocol * protocol) { - server_protocol_dispose(protocol); + server_protocol_dispose((struct server_protocol *) protocol); } void wsfs_server_protocol_init_lws( struct wsfs_server_protocol * protocol, struct lws_protocols * lws_protocol) { - server_protocol_init_lws(protocol, lws_protocol); + server_protocol_init_lws((struct server_protocol *) protocol, lws_protocol); } void wsfs_server_protocol_add_authenticator( @@ -58,62 +59,63 @@ void wsfs_server_protocol_add_authenticator( wsfs_authenticate_fn * authenticate, void * user_data) { - server_protocol_add_authenticator(protocol, type, authenticate, user_data); + server_protocol_add_authenticator((struct server_protocol *) protocol, + type, (authenticate_fn*) authenticate, user_data); } // server_config struct wsfs_server_config * wsfs_server_config_create(void) { - return server_config_create(); + return (struct wsfs_server_config*) server_config_create(); } void wsfs_server_config_dispose( struct wsfs_server_config * config) { - server_config_dispose(config); + server_config_dispose((struct server_config*) config); } void wsfs_server_config_set_mountpoint( struct wsfs_server_config * config, char const * mount_point) { - server_config_set_mountpoint(config, mount_point); + server_config_set_mountpoint((struct server_config*) config, mount_point); } void wsfs_server_config_set_documentroot( struct wsfs_server_config * config, char const * document_root) { - server_config_set_documentroot(config, document_root); + server_config_set_documentroot((struct server_config*) config, document_root); } void wsfs_server_config_set_keypath( struct wsfs_server_config * config, char const * key_path) { - server_config_set_keypath(config, key_path); + server_config_set_keypath((struct server_config*) config, key_path); } void wsfs_server_config_set_certpath( struct wsfs_server_config * config, char const * cert_path) { - server_config_set_certpath(config, cert_path); + server_config_set_certpath((struct server_config*) config, cert_path); } void wsfs_server_config_set_vhostname( struct wsfs_server_config * config, char const * vhost_name) { - server_config_set_vhostname(config, vhost_name); + server_config_set_vhostname((struct server_config*) config, vhost_name); } void wsfs_server_config_set_port( struct wsfs_server_config * config, int port) { - server_config_set_port(config, port); + server_config_set_port((struct server_config*) config, port); } void wsfs_server_config_add_authenticator( @@ -122,7 +124,7 @@ void wsfs_server_config_add_authenticator( wsfs_authenticate_fn * authenticate, void * user_data) { - server_config_add_authenticator(config, type, authenticate, user_data); + server_config_add_authenticator((struct server_config*) config, type, (authenticate_fn*) authenticate, user_data); } // credentials @@ -130,12 +132,12 @@ void wsfs_server_config_add_authenticator( char const * wsfs_credentials_type( struct wsfs_credentials const * credentials) { - return credentials_type(credentials); + return credentials_type((struct credentials *) credentials); } char const * wsfs_credentials_get( struct wsfs_credentials const * credentials, char const * key) { - return credentials_get(credentials, key); + return credentials_get((struct credentials *) credentials, key); } diff --git a/lib/wsfs/adapter/impl/authenticate.h b/lib/wsfs/adapter/impl/authenticate.h new file mode 100644 index 0000000..2448f6b --- /dev/null +++ b/lib/wsfs/adapter/impl/authenticate.h @@ -0,0 +1,23 @@ +#ifndef WSFS_ADAPTER_IMPL_AUTHENTICATE_H +#define WSFS_ADAPTER_IMPL_AUTHENTICATE_H + +#ifndef __cplusplus +#include +#endif + +#ifdef __cplusplus +extern "C" +{ +#endif + +struct credentials; + +typedef bool authenticate_fn( + struct credentials * credentials, + void * user_data); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/lib/wsfs/adapter/impl/authenticator.c b/lib/wsfs/adapter/impl/authenticator.c index 7780957..bb2c006 100644 --- a/lib/wsfs/adapter/impl/authenticator.c +++ b/lib/wsfs/adapter/impl/authenticator.c @@ -7,7 +7,7 @@ struct authenticator * authenticator_create( char const * type, - wsfs_authenticate_fn * authenticate, + authenticate_fn * authenticate, void * user_data) { struct authenticator * authenticator = malloc(sizeof(struct authenticator)); @@ -31,7 +31,7 @@ void authenticator_dispose( bool authenticator_autenticate( struct authenticator * authenticator, - struct wsfs_credentials * credentials) + struct credentials * credentials) { bool result; diff --git a/lib/wsfs/adapter/impl/authenticator.h b/lib/wsfs/adapter/impl/authenticator.h index 8e1c4af..0308597 100644 --- a/lib/wsfs/adapter/impl/authenticator.h +++ b/lib/wsfs/adapter/impl/authenticator.h @@ -5,24 +5,26 @@ #include #endif -#include "wsfs/adapter/authenticate.h" +#include "wsfs/adapter/impl/authenticate.h" #ifdef __cplusplus extern "C" { #endif +struct credentials; + struct authenticator { char * type; - wsfs_authenticate_fn * authenticate; + authenticate_fn * authenticate; void * user_data; struct authenticator * next; }; extern struct authenticator * authenticator_create( char const * type, - wsfs_authenticate_fn * authenticate, + authenticate_fn * authenticate, void * user_data); extern void authenticator_dispose( @@ -30,7 +32,7 @@ extern void authenticator_dispose( extern bool authenticator_autenticate( struct authenticator * authenticator, - struct wsfs_credentials * credentials); + struct credentials * credentials); diff --git a/lib/wsfs/adapter/impl/authenticators.c b/lib/wsfs/adapter/impl/authenticators.c index ec6212c..d67bb5e 100644 --- a/lib/wsfs/adapter/impl/authenticators.c +++ b/lib/wsfs/adapter/impl/authenticators.c @@ -74,7 +74,7 @@ extern void authenticators_move( void authenticators_add( struct authenticators * authenticators, char const * type, - wsfs_authenticate_fn * authenticate, + authenticate_fn * authenticate, void * user_data) { struct authenticator * authenticator = authenticator_create(type, authenticate, user_data); @@ -84,7 +84,7 @@ void authenticators_add( bool authenticators_authenticate( struct authenticators * authenticators, - struct wsfs_credentials * credentials) + struct credentials * credentials) { bool result = (NULL == authenticators->first); diff --git a/lib/wsfs/adapter/impl/authenticators.h b/lib/wsfs/adapter/impl/authenticators.h index 04c7daa..93228ab 100644 --- a/lib/wsfs/adapter/impl/authenticators.h +++ b/lib/wsfs/adapter/impl/authenticators.h @@ -5,7 +5,7 @@ #include #endif -#include "wsfs/adapter/authenticate.h" +#include "wsfs/adapter/impl/authenticate.h" #ifdef __cplusplus extern "C" @@ -13,7 +13,7 @@ extern "C" #endif struct authenticator; -struct wsfs_credentials; +struct credentials; struct authenticators { @@ -37,12 +37,12 @@ extern void authenticators_move( extern void authenticators_add( struct authenticators * authenticators, char const * type, - wsfs_authenticate_fn * authenticate, + authenticate_fn * authenticate, void * user_data); extern bool authenticators_authenticate( struct authenticators * authenticators, - struct wsfs_credentials * credentials); + struct credentials * credentials); #ifdef __cplusplus } diff --git a/lib/wsfs/adapter/impl/credentials.c b/lib/wsfs/adapter/impl/credentials.c index 89baff6..dd395e0 100644 --- a/lib/wsfs/adapter/impl/credentials.c +++ b/lib/wsfs/adapter/impl/credentials.c @@ -2,7 +2,7 @@ #include void credentials_init( - struct wsfs_credentials * credentials, + struct credentials * credentials, char const * type, json_t * data) { @@ -12,20 +12,20 @@ void credentials_init( } void credentials_cleanup( - struct wsfs_credentials * credentials) + struct credentials * credentials) { free(credentials->type); json_decref(credentials->data); } char const * credentials_type( - struct wsfs_credentials const * credentials) + struct credentials const * credentials) { return credentials->type; } char const * credentials_get( - struct wsfs_credentials const * credentials, + struct credentials const * credentials, char const * key) { char const * result = NULL; diff --git a/lib/wsfs/adapter/impl/credentials.h b/lib/wsfs/adapter/impl/credentials.h index 6d99f88..b646b4f 100644 --- a/lib/wsfs/adapter/impl/credentials.h +++ b/lib/wsfs/adapter/impl/credentials.h @@ -8,25 +8,25 @@ extern "C" { #endif -struct wsfs_credentials +struct credentials { char * type; json_t * data; }; extern void credentials_init( - struct wsfs_credentials * credentials, + struct credentials * credentials, char const * type, json_t * data); extern void credentials_cleanup( - struct wsfs_credentials * credentials); + struct credentials * credentials); extern char const * credentials_type( - struct wsfs_credentials const * credentials); + struct credentials const * credentials); extern char const * credentials_get( - struct wsfs_credentials const * credentials, + struct credentials const * credentials, char const * key); #ifdef __cplusplus diff --git a/lib/wsfs/adapter/impl/server.c b/lib/wsfs/adapter/impl/server.c index d36212d..43d9648 100644 --- a/lib/wsfs/adapter/impl/server.c +++ b/lib/wsfs/adapter/impl/server.c @@ -15,10 +15,10 @@ #define WSFS_SERVER_PROTOCOL_COUNT 3 #define WSFS_SERVER_TIMEOUT (1 * 1000) -struct wsfs_server +struct server { - struct wsfs_server_config config; - struct wsfs_server_protocol protocol; + struct server_config config; + struct server_protocol protocol; struct lws_protocols ws_protocols[WSFS_SERVER_PROTOCOL_COUNT]; struct lws_context * context; volatile bool shutdown_requested; @@ -27,13 +27,13 @@ struct wsfs_server }; static bool server_tls_enabled( - struct wsfs_server * server) + struct server * server) { return ((server->config.key_path != NULL) && (server->config.cert_path != NULL)); } static struct lws_context * server_context_create( - struct wsfs_server * server) + struct server * server) { lws_set_log_level(WSFS_DISABLE_LWS_LOG, NULL); @@ -79,7 +79,7 @@ static struct lws_context * server_context_create( } static bool server_check_mountpoint( - struct wsfs_server_config * config) + struct server_config * config) { bool result = false; @@ -98,14 +98,14 @@ static bool server_check_mountpoint( return result; } -struct wsfs_server * server_create( - struct wsfs_server_config * config) +struct server * server_create( + struct server_config * config) { - struct wsfs_server * server = NULL; + struct server * server = NULL; if (server_check_mountpoint(config)) { - server = malloc(sizeof(struct wsfs_server)); + server = malloc(sizeof(struct server)); if (NULL != server) { if (server_protocol_init(&server->protocol, config->mount_point)) @@ -127,7 +127,7 @@ struct wsfs_server * server_create( } void server_dispose( - struct wsfs_server * server) + struct server * server) { lws_context_destroy(server->context); server_protocol_cleanup(&server->protocol); @@ -136,7 +136,7 @@ void server_dispose( } void server_run( - struct wsfs_server * server) + struct server * server) { int n = 0; while ((0 <= n) && (!server->shutdown_requested)) @@ -146,7 +146,7 @@ void server_run( } void server_shutdown( - struct wsfs_server * server) + struct server * server) { server->shutdown_requested = true; } diff --git a/lib/wsfs/adapter/impl/server.h b/lib/wsfs/adapter/impl/server.h index 1e72606..349dd58 100644 --- a/lib/wsfs/adapter/impl/server.h +++ b/lib/wsfs/adapter/impl/server.h @@ -6,20 +6,20 @@ extern "C" { #endif -struct wsfs_server; -struct wsfs_server_config; +struct server; +struct server_config; -extern struct wsfs_server * server_create( - struct wsfs_server_config * config); +extern struct server * server_create( + struct server_config * config); extern void server_dispose( - struct wsfs_server * server); + struct server * server); extern void server_run( - struct wsfs_server * server); + struct server * server); extern void server_shutdown( - struct wsfs_server * server); + struct server * server); #ifdef __cplusplus } diff --git a/lib/wsfs/adapter/impl/server_config.c b/lib/wsfs/adapter/impl/server_config.c index 071c161..ae0e652 100644 --- a/lib/wsfs/adapter/impl/server_config.c +++ b/lib/wsfs/adapter/impl/server_config.c @@ -15,15 +15,15 @@ static char * server_config_strdup(char const * value) } void server_config_init( - struct wsfs_server_config * config) + struct server_config * config) { - memset(config, 0, sizeof(struct wsfs_server_config)); + memset(config, 0, sizeof(struct server_config)); authenticators_init(&config->authenticators); } void server_config_cleanup( - struct wsfs_server_config * config) + struct server_config * config) { authenticators_cleanup(&config->authenticators); @@ -37,8 +37,8 @@ void server_config_cleanup( } void server_config_clone( - struct wsfs_server_config * config, - struct wsfs_server_config * clone) + struct server_config * config, + struct server_config * clone) { clone->mount_point = server_config_strdup(config->mount_point); clone->document_root = server_config_strdup(config->document_root); @@ -50,9 +50,9 @@ void server_config_clone( authenticators_clone(&config->authenticators, &clone->authenticators); } -struct wsfs_server_config * server_config_create(void) +struct server_config * server_config_create(void) { - struct wsfs_server_config * config = malloc(sizeof(struct wsfs_server_config)); + struct server_config * config = malloc(sizeof(struct server_config)); if (NULL != config) { server_config_init(config); @@ -62,14 +62,14 @@ struct wsfs_server_config * server_config_create(void) } void server_config_dispose( - struct wsfs_server_config * config) + struct server_config * config) { server_config_cleanup(config); free(config); } void server_config_set_mountpoint( - struct wsfs_server_config * config, + struct server_config * config, char const * mount_point) { free(config->mount_point); @@ -77,7 +77,7 @@ void server_config_set_mountpoint( } void server_config_set_documentroot( - struct wsfs_server_config * config, + struct server_config * config, char const * document_root) { free(config->document_root); @@ -85,7 +85,7 @@ void server_config_set_documentroot( } void server_config_set_keypath( - struct wsfs_server_config * config, + struct server_config * config, char const * key_path) { free(config->key_path); @@ -93,7 +93,7 @@ void server_config_set_keypath( } void server_config_set_certpath( - struct wsfs_server_config * config, + struct server_config * config, char const * cert_path) { free(config->cert_path); @@ -101,7 +101,7 @@ void server_config_set_certpath( } void server_config_set_vhostname( - struct wsfs_server_config * config, + struct server_config * config, char const * vhost_name) { free(config->vhost_name); @@ -109,16 +109,16 @@ void server_config_set_vhostname( } void server_config_set_port( - struct wsfs_server_config * config, + struct server_config * config, int port) { config->port = port; } void server_config_add_authenticator( - struct wsfs_server_config * config, + struct server_config * config, char const * type, - wsfs_authenticate_fn * authenticate, + authenticate_fn * authenticate, void * user_data ) { diff --git a/lib/wsfs/adapter/impl/server_config.h b/lib/wsfs/adapter/impl/server_config.h index 18cd224..79446bb 100644 --- a/lib/wsfs/adapter/impl/server_config.h +++ b/lib/wsfs/adapter/impl/server_config.h @@ -7,7 +7,7 @@ extern "C" { #endif -struct wsfs_server_config +struct server_config { char * mount_point; char * document_root; @@ -18,49 +18,49 @@ struct wsfs_server_config struct authenticators authenticators; }; -extern struct wsfs_server_config * server_config_create(void); +extern struct server_config * server_config_create(void); extern void server_config_dispose( - struct wsfs_server_config * config); + struct server_config * config); extern void server_config_init( - struct wsfs_server_config * config); + struct server_config * config); extern void server_config_cleanup( - struct wsfs_server_config * config); + struct server_config * config); extern void server_config_clone( - struct wsfs_server_config * config, - struct wsfs_server_config * clone); + struct server_config * config, + struct server_config * clone); extern void server_config_set_mountpoint( - struct wsfs_server_config * config, + struct server_config * config, char const * mount_point); extern void server_config_set_documentroot( - struct wsfs_server_config * config, + struct server_config * config, char const * document_root); extern void server_config_set_keypath( - struct wsfs_server_config * config, + struct server_config * config, char const * key_path); extern void server_config_set_certpath( - struct wsfs_server_config * config, + struct server_config * config, char const * cert_path); extern void server_config_set_vhostname( - struct wsfs_server_config * config, + struct server_config * config, char const * vhost_name); extern void server_config_set_port( - struct wsfs_server_config * config, + struct server_config * config, int port); extern void server_config_add_authenticator( - struct wsfs_server_config * config, + struct server_config * config, char const * type, - wsfs_authenticate_fn * authenticate, + authenticate_fn * authenticate, void * user_data ); diff --git a/lib/wsfs/adapter/impl/server_protocol.c b/lib/wsfs/adapter/impl/server_protocol.c index afd6137..a4913bf 100644 --- a/lib/wsfs/adapter/impl/server_protocol.c +++ b/lib/wsfs/adapter/impl/server_protocol.c @@ -16,7 +16,7 @@ static int server_protocol_callback( size_t len) { struct lws_protocols const * ws_protocol = lws_get_protocol(wsi); - struct wsfs_server_protocol * protocol = ws_protocol->user; + struct server_protocol * protocol = ws_protocol->user; timeout_manager_check(&protocol->timeout_manager); struct session * session = session_manager_get(&protocol->session_manager, wsi); @@ -74,7 +74,7 @@ static bool server_protocol_invoke( void * user_data, json_t const * request) { - struct wsfs_server_protocol * protocol = user_data; + struct server_protocol * protocol = user_data; struct session * session = &protocol->session_manager.session; struct wsfs_message * message = wsfs_message_create(request); @@ -84,10 +84,10 @@ static bool server_protocol_invoke( } -struct wsfs_server_protocol * server_protocol_create( +struct server_protocol * server_protocol_create( char * mount_point) { - struct wsfs_server_protocol * protocol = malloc(sizeof(struct wsfs_server_protocol)); + struct server_protocol * protocol = malloc(sizeof(struct server_protocol)); if (NULL != protocol) { if (!server_protocol_init(protocol, mount_point)) @@ -101,14 +101,14 @@ struct wsfs_server_protocol * server_protocol_create( } void server_protocol_dispose( - struct wsfs_server_protocol * protocol) + struct server_protocol * protocol) { server_protocol_cleanup(protocol); free(protocol); } void server_protocol_init_lws( - struct wsfs_server_protocol * protocol, + struct server_protocol * protocol, struct lws_protocols * lws_protocol) { lws_protocol->callback = &server_protocol_callback; @@ -117,7 +117,7 @@ void server_protocol_init_lws( } bool server_protocol_init( - struct wsfs_server_protocol * protocol, + struct server_protocol * protocol, char * mount_point) { timeout_manager_init(&protocol->timeout_manager); @@ -147,7 +147,7 @@ bool server_protocol_init( } void server_protocol_cleanup( - struct wsfs_server_protocol * protocol) + struct server_protocol * protocol) { filesystem_cleanup(&protocol->filesystem); jsonrpc_server_cleanup(&protocol->rpc); @@ -157,9 +157,9 @@ void server_protocol_cleanup( } void server_protocol_add_authenticator( - struct wsfs_server_protocol * protocol, + struct server_protocol * protocol, char const * type, - wsfs_authenticate_fn * authenticate, + authenticate_fn * authenticate, void * user_data) { authenticators_add(&protocol->authenticators, type, authenticate, user_data); diff --git a/lib/wsfs/adapter/impl/server_protocol.h b/lib/wsfs/adapter/impl/server_protocol.h index dcf9e35..0ca772b 100644 --- a/lib/wsfs/adapter/impl/server_protocol.h +++ b/lib/wsfs/adapter/impl/server_protocol.h @@ -14,7 +14,7 @@ extern "C" struct lws_protocols; -struct wsfs_server_protocol +struct server_protocol { struct timeout_manager timeout_manager; struct filesystem filesystem; @@ -24,26 +24,26 @@ struct wsfs_server_protocol }; extern bool server_protocol_init( - struct wsfs_server_protocol * protocol, + struct server_protocol * protocol, char * mount_point); extern void server_protocol_cleanup( - struct wsfs_server_protocol * protocol); + struct server_protocol * protocol); -extern struct wsfs_server_protocol * server_protocol_create( +extern struct server_protocol * server_protocol_create( char * mount_point); extern void server_protocol_dispose( - struct wsfs_server_protocol * protocol); + struct server_protocol * protocol); extern void server_protocol_init_lws( - struct wsfs_server_protocol * protocol, + struct server_protocol * protocol, struct lws_protocols * lws_protocol); extern void server_protocol_add_authenticator( - struct wsfs_server_protocol * protocol, + struct server_protocol * protocol, char const * type, - wsfs_authenticate_fn * authenticate, + authenticate_fn * authenticate, void * user_data); #ifdef __cplusplus diff --git a/lib/wsfs/adapter/impl/session.c b/lib/wsfs/adapter/impl/session.c index fa0d107..d829bc9 100644 --- a/lib/wsfs/adapter/impl/session.c +++ b/lib/wsfs/adapter/impl/session.c @@ -32,7 +32,7 @@ void session_cleanup( void session_authenticate( struct session * session, - struct wsfs_credentials * creds) + struct credentials * creds) { session->is_authenticated = authenticators_authenticate(session->authenticators, creds); } diff --git a/lib/wsfs/adapter/impl/session.h b/lib/wsfs/adapter/impl/session.h index 0ff9f92..013f809 100644 --- a/lib/wsfs/adapter/impl/session.h +++ b/lib/wsfs/adapter/impl/session.h @@ -18,7 +18,7 @@ extern "C" struct lws; struct wsfs_message; -struct wsfs_credentials; +struct credentials; struct authenticators; struct jsonrpc_server; @@ -39,7 +39,7 @@ extern void session_init( extern void session_authenticate( struct session * session, - struct wsfs_credentials * creds); + struct credentials * creds); extern bool session_send( struct session * session, diff --git a/test/mock_authenticator.cc b/test/mock_authenticator.cc index f455270..b516f01 100644 --- a/test/mock_authenticator.cc +++ b/test/mock_authenticator.cc @@ -23,17 +23,17 @@ void set_authenticator(size_t i, Authenticator * authenticator) g_authenticators[i] = authenticator; } -bool authenticate(struct wsfs_credentials * creds, void * user_data) +bool authenticate(struct credentials * creds, void * user_data) { return g_authenticators[0]->authenticate(creds, user_data); } -bool authenticate_1(struct wsfs_credentials * creds, void * user_data) +bool authenticate_1(struct credentials * creds, void * user_data) { return g_authenticators[1]->authenticate(creds, user_data); } -bool authenticate_2(struct wsfs_credentials * creds, void * user_data) +bool authenticate_2(struct credentials * creds, void * user_data) { return g_authenticators[2]->authenticate(creds, user_data); } diff --git a/test/mock_authenticator.hpp b/test/mock_authenticator.hpp index 1660fc9..2fcab3d 100644 --- a/test/mock_authenticator.hpp +++ b/test/mock_authenticator.hpp @@ -12,22 +12,22 @@ class Authenticator public: virtual ~Authenticator() { } virtual bool authenticate( - struct wsfs_credentials * credentials, + struct credentials * credentials, void * user_data) = 0; }; class MockAuthenticator: public Authenticator { public: - MOCK_METHOD2(authenticate, bool (struct wsfs_credentials * credentials, void * user_data)); + MOCK_METHOD2(authenticate, bool (struct credentials * credentials, void * user_data)); }; void set_authenticator(Authenticator * authenticator); void set_authenticator(size_t index, Authenticator * authenticator); -bool authenticate(struct wsfs_credentials * creds, void * user_data); -bool authenticate_1(struct wsfs_credentials * creds, void * user_data); -bool authenticate_2(struct wsfs_credentials * creds, void * user_data); +bool authenticate(struct credentials * creds, void * user_data); +bool authenticate_1(struct credentials * creds, void * user_data); +bool authenticate_2(struct credentials * creds, void * user_data); } diff --git a/test/test_authenticator.cc b/test/test_authenticator.cc index 00a46c2..eaa516e 100644 --- a/test/test_authenticator.cc +++ b/test/test_authenticator.cc @@ -19,7 +19,7 @@ TEST(Authenticator, Authenticate) MockAuthenticator mock; set_authenticator(&mock); - struct wsfs_credentials creds; + struct credentials creds; credentials_init(&creds, "username", nullptr); char dummy[] = "usr_data"; void * user_data = reinterpret_cast(dummy); @@ -45,7 +45,7 @@ TEST(Authenticator, SkipAuthenticationWithWrongType) MockAuthenticator mock; set_authenticator(&mock); - struct wsfs_credentials creds; + struct credentials creds; credentials_init(&creds, "username", nullptr); EXPECT_CALL(mock, authenticate(_, _)) .Times(0); diff --git a/test/test_authenticators.cc b/test/test_authenticators.cc index 19ed443..27ffdcf 100644 --- a/test/test_authenticators.cc +++ b/test/test_authenticators.cc @@ -67,7 +67,7 @@ TEST(Authenticators, Move) TEST(Authenticators, AuthenticateWithoutAuthenticators) { - struct wsfs_credentials creds; + struct credentials creds; credentials_init(&creds, "username", nullptr); struct authenticators authenticators; @@ -100,7 +100,7 @@ TEST(Authenticators, FailToAuthenticateWithoutCredentials) TEST(Authenticators, AuthenticateWithMultipleCredentials) { - struct wsfs_credentials creds; + struct credentials creds; credentials_init(&creds, "username", nullptr); MockAuthenticator username_mock; @@ -128,7 +128,7 @@ TEST(Authenticators, AuthenticateWithMultipleCredentials) TEST(Authenticators, FailedAuthenticateWithWrongType) { - struct wsfs_credentials creds; + struct credentials creds; credentials_init(&creds, "token", nullptr); MockAuthenticator username_mock; diff --git a/test/test_credentials.cc b/test/test_credentials.cc index 5ca62e6..df579ec 100644 --- a/test/test_credentials.cc +++ b/test/test_credentials.cc @@ -5,7 +5,7 @@ TEST(Credentials, Type) { - struct wsfs_credentials creds; + struct credentials creds; credentials_init(&creds, "test", nullptr); ASSERT_STREQ("test", credentials_type(&creds)); @@ -14,7 +14,7 @@ TEST(Credentials, Type) TEST(Credentials, Get) { - struct wsfs_credentials creds; + struct credentials creds; json_t * data = json_object(); json_object_set_new(data, "username", json_string("bob")); json_object_set_new(data, "password", json_string("")); @@ -30,7 +30,7 @@ TEST(Credentials, Get) TEST(Credentials, FailedToGetNonexistingValue) { - struct wsfs_credentials creds; + struct credentials creds; json_t * data = json_object(); credentials_init(&creds, "username", data); @@ -44,7 +44,7 @@ TEST(Credentials, FailedToGetNonexistingValue) TEST(Credentials, FailedToGetWithoutData) { - struct wsfs_credentials creds; + struct credentials creds; credentials_init(&creds, "username", nullptr); ASSERT_STREQ("username",credentials_type(&creds)); @@ -56,7 +56,7 @@ TEST(Credentials, FailedToGetWithoutData) TEST(Credentials, FailedToGetWrongDataType) { - struct wsfs_credentials creds; + struct credentials creds; json_t * data = json_string("invalid_creds"); credentials_init(&creds, "username", data);