mirror of
https://github.com/falk-werner/webfuse
synced 2024-10-27 20:34:10 +00:00
adds type casts between API and implementation
This commit is contained in:
parent
feed9751d3
commit
0aadf891a8
@ -4,31 +4,32 @@
|
|||||||
#include "wsfs/adapter/impl/server_protocol.h"
|
#include "wsfs/adapter/impl/server_protocol.h"
|
||||||
#include "wsfs/adapter/impl/server_config.h"
|
#include "wsfs/adapter/impl/server_config.h"
|
||||||
#include "wsfs/adapter/impl/credentials.h"
|
#include "wsfs/adapter/impl/credentials.h"
|
||||||
|
#include "wsfs/adapter/impl/authenticate.h"
|
||||||
|
|
||||||
// server
|
// server
|
||||||
|
|
||||||
struct wsfs_server * wsfs_server_create(
|
struct wsfs_server * wsfs_server_create(
|
||||||
struct wsfs_server_config * config)
|
struct wsfs_server_config * config)
|
||||||
{
|
{
|
||||||
return server_create(config);
|
return (struct wsfs_server *) server_create((struct server_config*) config);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wsfs_server_dispose(
|
void wsfs_server_dispose(
|
||||||
struct wsfs_server * server)
|
struct wsfs_server * server)
|
||||||
{
|
{
|
||||||
server_dispose(server);
|
server_dispose((struct server *) server);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wsfs_server_run(
|
void wsfs_server_run(
|
||||||
struct wsfs_server * server)
|
struct wsfs_server * server)
|
||||||
{
|
{
|
||||||
server_run(server);
|
server_run((struct server *) server);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wsfs_server_shutdown(
|
void wsfs_server_shutdown(
|
||||||
struct wsfs_server * server)
|
struct wsfs_server * server)
|
||||||
{
|
{
|
||||||
server_shutdown(server);
|
server_shutdown((struct server *) server);
|
||||||
}
|
}
|
||||||
|
|
||||||
// server protocol
|
// server protocol
|
||||||
@ -36,20 +37,20 @@ void wsfs_server_shutdown(
|
|||||||
struct wsfs_server_protocol * wsfs_server_protocol_create(
|
struct wsfs_server_protocol * wsfs_server_protocol_create(
|
||||||
char * mount_point)
|
char * mount_point)
|
||||||
{
|
{
|
||||||
return server_protocol_create(mount_point);
|
return (struct wsfs_server_protocol *) server_protocol_create(mount_point);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wsfs_server_protocol_dispose(
|
void wsfs_server_protocol_dispose(
|
||||||
struct wsfs_server_protocol * protocol)
|
struct wsfs_server_protocol * protocol)
|
||||||
{
|
{
|
||||||
server_protocol_dispose(protocol);
|
server_protocol_dispose((struct server_protocol *) protocol);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wsfs_server_protocol_init_lws(
|
void wsfs_server_protocol_init_lws(
|
||||||
struct wsfs_server_protocol * protocol,
|
struct wsfs_server_protocol * protocol,
|
||||||
struct lws_protocols * lws_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(
|
void wsfs_server_protocol_add_authenticator(
|
||||||
@ -58,62 +59,63 @@ void wsfs_server_protocol_add_authenticator(
|
|||||||
wsfs_authenticate_fn * authenticate,
|
wsfs_authenticate_fn * authenticate,
|
||||||
void * user_data)
|
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
|
// server_config
|
||||||
|
|
||||||
struct wsfs_server_config * wsfs_server_config_create(void)
|
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(
|
void wsfs_server_config_dispose(
|
||||||
struct wsfs_server_config * config)
|
struct wsfs_server_config * config)
|
||||||
{
|
{
|
||||||
server_config_dispose(config);
|
server_config_dispose((struct server_config*) config);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wsfs_server_config_set_mountpoint(
|
void wsfs_server_config_set_mountpoint(
|
||||||
struct wsfs_server_config * config,
|
struct wsfs_server_config * config,
|
||||||
char const * mount_point)
|
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(
|
void wsfs_server_config_set_documentroot(
|
||||||
struct wsfs_server_config * config,
|
struct wsfs_server_config * config,
|
||||||
char const * document_root)
|
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(
|
void wsfs_server_config_set_keypath(
|
||||||
struct wsfs_server_config * config,
|
struct wsfs_server_config * config,
|
||||||
char const * key_path)
|
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(
|
void wsfs_server_config_set_certpath(
|
||||||
struct wsfs_server_config * config,
|
struct wsfs_server_config * config,
|
||||||
char const * cert_path)
|
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(
|
void wsfs_server_config_set_vhostname(
|
||||||
struct wsfs_server_config * config,
|
struct wsfs_server_config * config,
|
||||||
char const * vhost_name)
|
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(
|
void wsfs_server_config_set_port(
|
||||||
struct wsfs_server_config * config,
|
struct wsfs_server_config * config,
|
||||||
int port)
|
int port)
|
||||||
{
|
{
|
||||||
server_config_set_port(config, port);
|
server_config_set_port((struct server_config*) config, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wsfs_server_config_add_authenticator(
|
void wsfs_server_config_add_authenticator(
|
||||||
@ -122,7 +124,7 @@ void wsfs_server_config_add_authenticator(
|
|||||||
wsfs_authenticate_fn * authenticate,
|
wsfs_authenticate_fn * authenticate,
|
||||||
void * user_data)
|
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
|
// credentials
|
||||||
@ -130,12 +132,12 @@ void wsfs_server_config_add_authenticator(
|
|||||||
char const * wsfs_credentials_type(
|
char const * wsfs_credentials_type(
|
||||||
struct wsfs_credentials const * credentials)
|
struct wsfs_credentials const * credentials)
|
||||||
{
|
{
|
||||||
return credentials_type(credentials);
|
return credentials_type((struct credentials *) credentials);
|
||||||
}
|
}
|
||||||
|
|
||||||
char const * wsfs_credentials_get(
|
char const * wsfs_credentials_get(
|
||||||
struct wsfs_credentials const * credentials,
|
struct wsfs_credentials const * credentials,
|
||||||
char const * key)
|
char const * key)
|
||||||
{
|
{
|
||||||
return credentials_get(credentials, key);
|
return credentials_get((struct credentials *) credentials, key);
|
||||||
}
|
}
|
||||||
|
23
lib/wsfs/adapter/impl/authenticate.h
Normal file
23
lib/wsfs/adapter/impl/authenticate.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#ifndef WSFS_ADAPTER_IMPL_AUTHENTICATE_H
|
||||||
|
#define WSFS_ADAPTER_IMPL_AUTHENTICATE_H
|
||||||
|
|
||||||
|
#ifndef __cplusplus
|
||||||
|
#include <stdbool.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct credentials;
|
||||||
|
|
||||||
|
typedef bool authenticate_fn(
|
||||||
|
struct credentials * credentials,
|
||||||
|
void * user_data);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
struct authenticator * authenticator_create(
|
struct authenticator * authenticator_create(
|
||||||
char const * type,
|
char const * type,
|
||||||
wsfs_authenticate_fn * authenticate,
|
authenticate_fn * authenticate,
|
||||||
void * user_data)
|
void * user_data)
|
||||||
{
|
{
|
||||||
struct authenticator * authenticator = malloc(sizeof(struct authenticator));
|
struct authenticator * authenticator = malloc(sizeof(struct authenticator));
|
||||||
@ -31,7 +31,7 @@ void authenticator_dispose(
|
|||||||
|
|
||||||
bool authenticator_autenticate(
|
bool authenticator_autenticate(
|
||||||
struct authenticator * authenticator,
|
struct authenticator * authenticator,
|
||||||
struct wsfs_credentials * credentials)
|
struct credentials * credentials)
|
||||||
{
|
{
|
||||||
bool result;
|
bool result;
|
||||||
|
|
||||||
|
@ -5,24 +5,26 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wsfs/adapter/authenticate.h"
|
#include "wsfs/adapter/impl/authenticate.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
struct credentials;
|
||||||
|
|
||||||
struct authenticator
|
struct authenticator
|
||||||
{
|
{
|
||||||
char * type;
|
char * type;
|
||||||
wsfs_authenticate_fn * authenticate;
|
authenticate_fn * authenticate;
|
||||||
void * user_data;
|
void * user_data;
|
||||||
struct authenticator * next;
|
struct authenticator * next;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct authenticator * authenticator_create(
|
extern struct authenticator * authenticator_create(
|
||||||
char const * type,
|
char const * type,
|
||||||
wsfs_authenticate_fn * authenticate,
|
authenticate_fn * authenticate,
|
||||||
void * user_data);
|
void * user_data);
|
||||||
|
|
||||||
extern void authenticator_dispose(
|
extern void authenticator_dispose(
|
||||||
@ -30,7 +32,7 @@ extern void authenticator_dispose(
|
|||||||
|
|
||||||
extern bool authenticator_autenticate(
|
extern bool authenticator_autenticate(
|
||||||
struct authenticator * authenticator,
|
struct authenticator * authenticator,
|
||||||
struct wsfs_credentials * credentials);
|
struct credentials * credentials);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ extern void authenticators_move(
|
|||||||
void authenticators_add(
|
void authenticators_add(
|
||||||
struct authenticators * authenticators,
|
struct authenticators * authenticators,
|
||||||
char const * type,
|
char const * type,
|
||||||
wsfs_authenticate_fn * authenticate,
|
authenticate_fn * authenticate,
|
||||||
void * user_data)
|
void * user_data)
|
||||||
{
|
{
|
||||||
struct authenticator * authenticator = authenticator_create(type, authenticate, user_data);
|
struct authenticator * authenticator = authenticator_create(type, authenticate, user_data);
|
||||||
@ -84,7 +84,7 @@ void authenticators_add(
|
|||||||
|
|
||||||
bool authenticators_authenticate(
|
bool authenticators_authenticate(
|
||||||
struct authenticators * authenticators,
|
struct authenticators * authenticators,
|
||||||
struct wsfs_credentials * credentials)
|
struct credentials * credentials)
|
||||||
{
|
{
|
||||||
bool result = (NULL == authenticators->first);
|
bool result = (NULL == authenticators->first);
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wsfs/adapter/authenticate.h"
|
#include "wsfs/adapter/impl/authenticate.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C"
|
||||||
@ -13,7 +13,7 @@ extern "C"
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct authenticator;
|
struct authenticator;
|
||||||
struct wsfs_credentials;
|
struct credentials;
|
||||||
|
|
||||||
struct authenticators
|
struct authenticators
|
||||||
{
|
{
|
||||||
@ -37,12 +37,12 @@ extern void authenticators_move(
|
|||||||
extern void authenticators_add(
|
extern void authenticators_add(
|
||||||
struct authenticators * authenticators,
|
struct authenticators * authenticators,
|
||||||
char const * type,
|
char const * type,
|
||||||
wsfs_authenticate_fn * authenticate,
|
authenticate_fn * authenticate,
|
||||||
void * user_data);
|
void * user_data);
|
||||||
|
|
||||||
extern bool authenticators_authenticate(
|
extern bool authenticators_authenticate(
|
||||||
struct authenticators * authenticators,
|
struct authenticators * authenticators,
|
||||||
struct wsfs_credentials * credentials);
|
struct credentials * credentials);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
void credentials_init(
|
void credentials_init(
|
||||||
struct wsfs_credentials * credentials,
|
struct credentials * credentials,
|
||||||
char const * type,
|
char const * type,
|
||||||
json_t * data)
|
json_t * data)
|
||||||
{
|
{
|
||||||
@ -12,20 +12,20 @@ void credentials_init(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void credentials_cleanup(
|
void credentials_cleanup(
|
||||||
struct wsfs_credentials * credentials)
|
struct credentials * credentials)
|
||||||
{
|
{
|
||||||
free(credentials->type);
|
free(credentials->type);
|
||||||
json_decref(credentials->data);
|
json_decref(credentials->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
char const * credentials_type(
|
char const * credentials_type(
|
||||||
struct wsfs_credentials const * credentials)
|
struct credentials const * credentials)
|
||||||
{
|
{
|
||||||
return credentials->type;
|
return credentials->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
char const * credentials_get(
|
char const * credentials_get(
|
||||||
struct wsfs_credentials const * credentials,
|
struct credentials const * credentials,
|
||||||
char const * key)
|
char const * key)
|
||||||
{
|
{
|
||||||
char const * result = NULL;
|
char const * result = NULL;
|
||||||
|
@ -8,25 +8,25 @@ extern "C"
|
|||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct wsfs_credentials
|
struct credentials
|
||||||
{
|
{
|
||||||
char * type;
|
char * type;
|
||||||
json_t * data;
|
json_t * data;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern void credentials_init(
|
extern void credentials_init(
|
||||||
struct wsfs_credentials * credentials,
|
struct credentials * credentials,
|
||||||
char const * type,
|
char const * type,
|
||||||
json_t * data);
|
json_t * data);
|
||||||
|
|
||||||
extern void credentials_cleanup(
|
extern void credentials_cleanup(
|
||||||
struct wsfs_credentials * credentials);
|
struct credentials * credentials);
|
||||||
|
|
||||||
extern char const * credentials_type(
|
extern char const * credentials_type(
|
||||||
struct wsfs_credentials const * credentials);
|
struct credentials const * credentials);
|
||||||
|
|
||||||
extern char const * credentials_get(
|
extern char const * credentials_get(
|
||||||
struct wsfs_credentials const * credentials,
|
struct credentials const * credentials,
|
||||||
char const * key);
|
char const * key);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -15,10 +15,10 @@
|
|||||||
#define WSFS_SERVER_PROTOCOL_COUNT 3
|
#define WSFS_SERVER_PROTOCOL_COUNT 3
|
||||||
#define WSFS_SERVER_TIMEOUT (1 * 1000)
|
#define WSFS_SERVER_TIMEOUT (1 * 1000)
|
||||||
|
|
||||||
struct wsfs_server
|
struct server
|
||||||
{
|
{
|
||||||
struct wsfs_server_config config;
|
struct server_config config;
|
||||||
struct wsfs_server_protocol protocol;
|
struct server_protocol protocol;
|
||||||
struct lws_protocols ws_protocols[WSFS_SERVER_PROTOCOL_COUNT];
|
struct lws_protocols ws_protocols[WSFS_SERVER_PROTOCOL_COUNT];
|
||||||
struct lws_context * context;
|
struct lws_context * context;
|
||||||
volatile bool shutdown_requested;
|
volatile bool shutdown_requested;
|
||||||
@ -27,13 +27,13 @@ struct wsfs_server
|
|||||||
};
|
};
|
||||||
|
|
||||||
static bool server_tls_enabled(
|
static bool server_tls_enabled(
|
||||||
struct wsfs_server * server)
|
struct server * server)
|
||||||
{
|
{
|
||||||
return ((server->config.key_path != NULL) && (server->config.cert_path != NULL));
|
return ((server->config.key_path != NULL) && (server->config.cert_path != NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct lws_context * server_context_create(
|
static struct lws_context * server_context_create(
|
||||||
struct wsfs_server * server)
|
struct server * server)
|
||||||
{
|
{
|
||||||
lws_set_log_level(WSFS_DISABLE_LWS_LOG, NULL);
|
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(
|
static bool server_check_mountpoint(
|
||||||
struct wsfs_server_config * config)
|
struct server_config * config)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
@ -98,14 +98,14 @@ static bool server_check_mountpoint(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wsfs_server * server_create(
|
struct server * server_create(
|
||||||
struct wsfs_server_config * config)
|
struct server_config * config)
|
||||||
{
|
{
|
||||||
struct wsfs_server * server = NULL;
|
struct server * server = NULL;
|
||||||
|
|
||||||
if (server_check_mountpoint(config))
|
if (server_check_mountpoint(config))
|
||||||
{
|
{
|
||||||
server = malloc(sizeof(struct wsfs_server));
|
server = malloc(sizeof(struct server));
|
||||||
if (NULL != server)
|
if (NULL != server)
|
||||||
{
|
{
|
||||||
if (server_protocol_init(&server->protocol, config->mount_point))
|
if (server_protocol_init(&server->protocol, config->mount_point))
|
||||||
@ -127,7 +127,7 @@ struct wsfs_server * server_create(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void server_dispose(
|
void server_dispose(
|
||||||
struct wsfs_server * server)
|
struct server * server)
|
||||||
{
|
{
|
||||||
lws_context_destroy(server->context);
|
lws_context_destroy(server->context);
|
||||||
server_protocol_cleanup(&server->protocol);
|
server_protocol_cleanup(&server->protocol);
|
||||||
@ -136,7 +136,7 @@ void server_dispose(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void server_run(
|
void server_run(
|
||||||
struct wsfs_server * server)
|
struct server * server)
|
||||||
{
|
{
|
||||||
int n = 0;
|
int n = 0;
|
||||||
while ((0 <= n) && (!server->shutdown_requested))
|
while ((0 <= n) && (!server->shutdown_requested))
|
||||||
@ -146,7 +146,7 @@ void server_run(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void server_shutdown(
|
void server_shutdown(
|
||||||
struct wsfs_server * server)
|
struct server * server)
|
||||||
{
|
{
|
||||||
server->shutdown_requested = true;
|
server->shutdown_requested = true;
|
||||||
}
|
}
|
||||||
|
@ -6,20 +6,20 @@ extern "C"
|
|||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct wsfs_server;
|
struct server;
|
||||||
struct wsfs_server_config;
|
struct server_config;
|
||||||
|
|
||||||
extern struct wsfs_server * server_create(
|
extern struct server * server_create(
|
||||||
struct wsfs_server_config * config);
|
struct server_config * config);
|
||||||
|
|
||||||
extern void server_dispose(
|
extern void server_dispose(
|
||||||
struct wsfs_server * server);
|
struct server * server);
|
||||||
|
|
||||||
extern void server_run(
|
extern void server_run(
|
||||||
struct wsfs_server * server);
|
struct server * server);
|
||||||
|
|
||||||
extern void server_shutdown(
|
extern void server_shutdown(
|
||||||
struct wsfs_server * server);
|
struct server * server);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -15,15 +15,15 @@ static char * server_config_strdup(char const * value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void server_config_init(
|
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);
|
authenticators_init(&config->authenticators);
|
||||||
}
|
}
|
||||||
|
|
||||||
void server_config_cleanup(
|
void server_config_cleanup(
|
||||||
struct wsfs_server_config * config)
|
struct server_config * config)
|
||||||
{
|
{
|
||||||
authenticators_cleanup(&config->authenticators);
|
authenticators_cleanup(&config->authenticators);
|
||||||
|
|
||||||
@ -37,8 +37,8 @@ void server_config_cleanup(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void server_config_clone(
|
void server_config_clone(
|
||||||
struct wsfs_server_config * config,
|
struct server_config * config,
|
||||||
struct wsfs_server_config * clone)
|
struct server_config * clone)
|
||||||
{
|
{
|
||||||
clone->mount_point = server_config_strdup(config->mount_point);
|
clone->mount_point = server_config_strdup(config->mount_point);
|
||||||
clone->document_root = server_config_strdup(config->document_root);
|
clone->document_root = server_config_strdup(config->document_root);
|
||||||
@ -50,9 +50,9 @@ void server_config_clone(
|
|||||||
authenticators_clone(&config->authenticators, &clone->authenticators);
|
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)
|
if (NULL != config)
|
||||||
{
|
{
|
||||||
server_config_init(config);
|
server_config_init(config);
|
||||||
@ -62,14 +62,14 @@ struct wsfs_server_config * server_config_create(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void server_config_dispose(
|
void server_config_dispose(
|
||||||
struct wsfs_server_config * config)
|
struct server_config * config)
|
||||||
{
|
{
|
||||||
server_config_cleanup(config);
|
server_config_cleanup(config);
|
||||||
free(config);
|
free(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
void server_config_set_mountpoint(
|
void server_config_set_mountpoint(
|
||||||
struct wsfs_server_config * config,
|
struct server_config * config,
|
||||||
char const * mount_point)
|
char const * mount_point)
|
||||||
{
|
{
|
||||||
free(config->mount_point);
|
free(config->mount_point);
|
||||||
@ -77,7 +77,7 @@ void server_config_set_mountpoint(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void server_config_set_documentroot(
|
void server_config_set_documentroot(
|
||||||
struct wsfs_server_config * config,
|
struct server_config * config,
|
||||||
char const * document_root)
|
char const * document_root)
|
||||||
{
|
{
|
||||||
free(config->document_root);
|
free(config->document_root);
|
||||||
@ -85,7 +85,7 @@ void server_config_set_documentroot(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void server_config_set_keypath(
|
void server_config_set_keypath(
|
||||||
struct wsfs_server_config * config,
|
struct server_config * config,
|
||||||
char const * key_path)
|
char const * key_path)
|
||||||
{
|
{
|
||||||
free(config->key_path);
|
free(config->key_path);
|
||||||
@ -93,7 +93,7 @@ void server_config_set_keypath(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void server_config_set_certpath(
|
void server_config_set_certpath(
|
||||||
struct wsfs_server_config * config,
|
struct server_config * config,
|
||||||
char const * cert_path)
|
char const * cert_path)
|
||||||
{
|
{
|
||||||
free(config->cert_path);
|
free(config->cert_path);
|
||||||
@ -101,7 +101,7 @@ void server_config_set_certpath(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void server_config_set_vhostname(
|
void server_config_set_vhostname(
|
||||||
struct wsfs_server_config * config,
|
struct server_config * config,
|
||||||
char const * vhost_name)
|
char const * vhost_name)
|
||||||
{
|
{
|
||||||
free(config->vhost_name);
|
free(config->vhost_name);
|
||||||
@ -109,16 +109,16 @@ void server_config_set_vhostname(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void server_config_set_port(
|
void server_config_set_port(
|
||||||
struct wsfs_server_config * config,
|
struct server_config * config,
|
||||||
int port)
|
int port)
|
||||||
{
|
{
|
||||||
config->port = port;
|
config->port = port;
|
||||||
}
|
}
|
||||||
|
|
||||||
void server_config_add_authenticator(
|
void server_config_add_authenticator(
|
||||||
struct wsfs_server_config * config,
|
struct server_config * config,
|
||||||
char const * type,
|
char const * type,
|
||||||
wsfs_authenticate_fn * authenticate,
|
authenticate_fn * authenticate,
|
||||||
void * user_data
|
void * user_data
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct wsfs_server_config
|
struct server_config
|
||||||
{
|
{
|
||||||
char * mount_point;
|
char * mount_point;
|
||||||
char * document_root;
|
char * document_root;
|
||||||
@ -18,49 +18,49 @@ struct wsfs_server_config
|
|||||||
struct authenticators authenticators;
|
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(
|
extern void server_config_dispose(
|
||||||
struct wsfs_server_config * config);
|
struct server_config * config);
|
||||||
|
|
||||||
extern void server_config_init(
|
extern void server_config_init(
|
||||||
struct wsfs_server_config * config);
|
struct server_config * config);
|
||||||
|
|
||||||
extern void server_config_cleanup(
|
extern void server_config_cleanup(
|
||||||
struct wsfs_server_config * config);
|
struct server_config * config);
|
||||||
|
|
||||||
extern void server_config_clone(
|
extern void server_config_clone(
|
||||||
struct wsfs_server_config * config,
|
struct server_config * config,
|
||||||
struct wsfs_server_config * clone);
|
struct server_config * clone);
|
||||||
|
|
||||||
extern void server_config_set_mountpoint(
|
extern void server_config_set_mountpoint(
|
||||||
struct wsfs_server_config * config,
|
struct server_config * config,
|
||||||
char const * mount_point);
|
char const * mount_point);
|
||||||
|
|
||||||
extern void server_config_set_documentroot(
|
extern void server_config_set_documentroot(
|
||||||
struct wsfs_server_config * config,
|
struct server_config * config,
|
||||||
char const * document_root);
|
char const * document_root);
|
||||||
|
|
||||||
extern void server_config_set_keypath(
|
extern void server_config_set_keypath(
|
||||||
struct wsfs_server_config * config,
|
struct server_config * config,
|
||||||
char const * key_path);
|
char const * key_path);
|
||||||
|
|
||||||
extern void server_config_set_certpath(
|
extern void server_config_set_certpath(
|
||||||
struct wsfs_server_config * config,
|
struct server_config * config,
|
||||||
char const * cert_path);
|
char const * cert_path);
|
||||||
|
|
||||||
extern void server_config_set_vhostname(
|
extern void server_config_set_vhostname(
|
||||||
struct wsfs_server_config * config,
|
struct server_config * config,
|
||||||
char const * vhost_name);
|
char const * vhost_name);
|
||||||
|
|
||||||
extern void server_config_set_port(
|
extern void server_config_set_port(
|
||||||
struct wsfs_server_config * config,
|
struct server_config * config,
|
||||||
int port);
|
int port);
|
||||||
|
|
||||||
extern void server_config_add_authenticator(
|
extern void server_config_add_authenticator(
|
||||||
struct wsfs_server_config * config,
|
struct server_config * config,
|
||||||
char const * type,
|
char const * type,
|
||||||
wsfs_authenticate_fn * authenticate,
|
authenticate_fn * authenticate,
|
||||||
void * user_data
|
void * user_data
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ static int server_protocol_callback(
|
|||||||
size_t len)
|
size_t len)
|
||||||
{
|
{
|
||||||
struct lws_protocols const * ws_protocol = lws_get_protocol(wsi);
|
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);
|
timeout_manager_check(&protocol->timeout_manager);
|
||||||
struct session * session = session_manager_get(&protocol->session_manager, wsi);
|
struct session * session = session_manager_get(&protocol->session_manager, wsi);
|
||||||
@ -74,7 +74,7 @@ static bool server_protocol_invoke(
|
|||||||
void * user_data,
|
void * user_data,
|
||||||
json_t const * request)
|
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 session * session = &protocol->session_manager.session;
|
||||||
struct wsfs_message * message = wsfs_message_create(request);
|
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)
|
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 (NULL != protocol)
|
||||||
{
|
{
|
||||||
if (!server_protocol_init(protocol, mount_point))
|
if (!server_protocol_init(protocol, mount_point))
|
||||||
@ -101,14 +101,14 @@ struct wsfs_server_protocol * server_protocol_create(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void server_protocol_dispose(
|
void server_protocol_dispose(
|
||||||
struct wsfs_server_protocol * protocol)
|
struct server_protocol * protocol)
|
||||||
{
|
{
|
||||||
server_protocol_cleanup(protocol);
|
server_protocol_cleanup(protocol);
|
||||||
free(protocol);
|
free(protocol);
|
||||||
}
|
}
|
||||||
|
|
||||||
void server_protocol_init_lws(
|
void server_protocol_init_lws(
|
||||||
struct wsfs_server_protocol * protocol,
|
struct server_protocol * protocol,
|
||||||
struct lws_protocols * lws_protocol)
|
struct lws_protocols * lws_protocol)
|
||||||
{
|
{
|
||||||
lws_protocol->callback = &server_protocol_callback;
|
lws_protocol->callback = &server_protocol_callback;
|
||||||
@ -117,7 +117,7 @@ void server_protocol_init_lws(
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool server_protocol_init(
|
bool server_protocol_init(
|
||||||
struct wsfs_server_protocol * protocol,
|
struct server_protocol * protocol,
|
||||||
char * mount_point)
|
char * mount_point)
|
||||||
{
|
{
|
||||||
timeout_manager_init(&protocol->timeout_manager);
|
timeout_manager_init(&protocol->timeout_manager);
|
||||||
@ -147,7 +147,7 @@ bool server_protocol_init(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void server_protocol_cleanup(
|
void server_protocol_cleanup(
|
||||||
struct wsfs_server_protocol * protocol)
|
struct server_protocol * protocol)
|
||||||
{
|
{
|
||||||
filesystem_cleanup(&protocol->filesystem);
|
filesystem_cleanup(&protocol->filesystem);
|
||||||
jsonrpc_server_cleanup(&protocol->rpc);
|
jsonrpc_server_cleanup(&protocol->rpc);
|
||||||
@ -157,9 +157,9 @@ void server_protocol_cleanup(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void server_protocol_add_authenticator(
|
void server_protocol_add_authenticator(
|
||||||
struct wsfs_server_protocol * protocol,
|
struct server_protocol * protocol,
|
||||||
char const * type,
|
char const * type,
|
||||||
wsfs_authenticate_fn * authenticate,
|
authenticate_fn * authenticate,
|
||||||
void * user_data)
|
void * user_data)
|
||||||
{
|
{
|
||||||
authenticators_add(&protocol->authenticators, type, authenticate, user_data);
|
authenticators_add(&protocol->authenticators, type, authenticate, user_data);
|
||||||
|
@ -14,7 +14,7 @@ extern "C"
|
|||||||
|
|
||||||
struct lws_protocols;
|
struct lws_protocols;
|
||||||
|
|
||||||
struct wsfs_server_protocol
|
struct server_protocol
|
||||||
{
|
{
|
||||||
struct timeout_manager timeout_manager;
|
struct timeout_manager timeout_manager;
|
||||||
struct filesystem filesystem;
|
struct filesystem filesystem;
|
||||||
@ -24,26 +24,26 @@ struct wsfs_server_protocol
|
|||||||
};
|
};
|
||||||
|
|
||||||
extern bool server_protocol_init(
|
extern bool server_protocol_init(
|
||||||
struct wsfs_server_protocol * protocol,
|
struct server_protocol * protocol,
|
||||||
char * mount_point);
|
char * mount_point);
|
||||||
|
|
||||||
extern void server_protocol_cleanup(
|
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);
|
char * mount_point);
|
||||||
|
|
||||||
extern void server_protocol_dispose(
|
extern void server_protocol_dispose(
|
||||||
struct wsfs_server_protocol * protocol);
|
struct server_protocol * protocol);
|
||||||
|
|
||||||
extern void server_protocol_init_lws(
|
extern void server_protocol_init_lws(
|
||||||
struct wsfs_server_protocol * protocol,
|
struct server_protocol * protocol,
|
||||||
struct lws_protocols * lws_protocol);
|
struct lws_protocols * lws_protocol);
|
||||||
|
|
||||||
extern void server_protocol_add_authenticator(
|
extern void server_protocol_add_authenticator(
|
||||||
struct wsfs_server_protocol * protocol,
|
struct server_protocol * protocol,
|
||||||
char const * type,
|
char const * type,
|
||||||
wsfs_authenticate_fn * authenticate,
|
authenticate_fn * authenticate,
|
||||||
void * user_data);
|
void * user_data);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -32,7 +32,7 @@ void session_cleanup(
|
|||||||
|
|
||||||
void session_authenticate(
|
void session_authenticate(
|
||||||
struct session * session,
|
struct session * session,
|
||||||
struct wsfs_credentials * creds)
|
struct credentials * creds)
|
||||||
{
|
{
|
||||||
session->is_authenticated = authenticators_authenticate(session->authenticators, creds);
|
session->is_authenticated = authenticators_authenticate(session->authenticators, creds);
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ extern "C"
|
|||||||
|
|
||||||
struct lws;
|
struct lws;
|
||||||
struct wsfs_message;
|
struct wsfs_message;
|
||||||
struct wsfs_credentials;
|
struct credentials;
|
||||||
struct authenticators;
|
struct authenticators;
|
||||||
struct jsonrpc_server;
|
struct jsonrpc_server;
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ extern void session_init(
|
|||||||
|
|
||||||
extern void session_authenticate(
|
extern void session_authenticate(
|
||||||
struct session * session,
|
struct session * session,
|
||||||
struct wsfs_credentials * creds);
|
struct credentials * creds);
|
||||||
|
|
||||||
extern bool session_send(
|
extern bool session_send(
|
||||||
struct session * session,
|
struct session * session,
|
||||||
|
@ -23,17 +23,17 @@ void set_authenticator(size_t i, Authenticator * authenticator)
|
|||||||
g_authenticators[i] = 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);
|
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);
|
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);
|
return g_authenticators[2]->authenticate(creds, user_data);
|
||||||
}
|
}
|
||||||
|
@ -12,22 +12,22 @@ class Authenticator
|
|||||||
public:
|
public:
|
||||||
virtual ~Authenticator() { }
|
virtual ~Authenticator() { }
|
||||||
virtual bool authenticate(
|
virtual bool authenticate(
|
||||||
struct wsfs_credentials * credentials,
|
struct credentials * credentials,
|
||||||
void * user_data) = 0;
|
void * user_data) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MockAuthenticator: public Authenticator
|
class MockAuthenticator: public Authenticator
|
||||||
{
|
{
|
||||||
public:
|
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(Authenticator * authenticator);
|
||||||
void set_authenticator(size_t index, Authenticator * authenticator);
|
void set_authenticator(size_t index, Authenticator * authenticator);
|
||||||
|
|
||||||
bool authenticate(struct wsfs_credentials * creds, void * user_data);
|
bool authenticate(struct credentials * creds, void * user_data);
|
||||||
bool authenticate_1(struct wsfs_credentials * creds, void * user_data);
|
bool authenticate_1(struct credentials * creds, void * user_data);
|
||||||
bool authenticate_2(struct wsfs_credentials * creds, void * user_data);
|
bool authenticate_2(struct credentials * creds, void * user_data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ TEST(Authenticator, Authenticate)
|
|||||||
MockAuthenticator mock;
|
MockAuthenticator mock;
|
||||||
set_authenticator(&mock);
|
set_authenticator(&mock);
|
||||||
|
|
||||||
struct wsfs_credentials creds;
|
struct credentials creds;
|
||||||
credentials_init(&creds, "username", nullptr);
|
credentials_init(&creds, "username", nullptr);
|
||||||
char dummy[] = "usr_data";
|
char dummy[] = "usr_data";
|
||||||
void * user_data = reinterpret_cast<void*>(dummy);
|
void * user_data = reinterpret_cast<void*>(dummy);
|
||||||
@ -45,7 +45,7 @@ TEST(Authenticator, SkipAuthenticationWithWrongType)
|
|||||||
MockAuthenticator mock;
|
MockAuthenticator mock;
|
||||||
set_authenticator(&mock);
|
set_authenticator(&mock);
|
||||||
|
|
||||||
struct wsfs_credentials creds;
|
struct credentials creds;
|
||||||
credentials_init(&creds, "username", nullptr);
|
credentials_init(&creds, "username", nullptr);
|
||||||
EXPECT_CALL(mock, authenticate(_, _))
|
EXPECT_CALL(mock, authenticate(_, _))
|
||||||
.Times(0);
|
.Times(0);
|
||||||
|
@ -67,7 +67,7 @@ TEST(Authenticators, Move)
|
|||||||
|
|
||||||
TEST(Authenticators, AuthenticateWithoutAuthenticators)
|
TEST(Authenticators, AuthenticateWithoutAuthenticators)
|
||||||
{
|
{
|
||||||
struct wsfs_credentials creds;
|
struct credentials creds;
|
||||||
credentials_init(&creds, "username", nullptr);
|
credentials_init(&creds, "username", nullptr);
|
||||||
|
|
||||||
struct authenticators authenticators;
|
struct authenticators authenticators;
|
||||||
@ -100,7 +100,7 @@ TEST(Authenticators, FailToAuthenticateWithoutCredentials)
|
|||||||
|
|
||||||
TEST(Authenticators, AuthenticateWithMultipleCredentials)
|
TEST(Authenticators, AuthenticateWithMultipleCredentials)
|
||||||
{
|
{
|
||||||
struct wsfs_credentials creds;
|
struct credentials creds;
|
||||||
credentials_init(&creds, "username", nullptr);
|
credentials_init(&creds, "username", nullptr);
|
||||||
|
|
||||||
MockAuthenticator username_mock;
|
MockAuthenticator username_mock;
|
||||||
@ -128,7 +128,7 @@ TEST(Authenticators, AuthenticateWithMultipleCredentials)
|
|||||||
|
|
||||||
TEST(Authenticators, FailedAuthenticateWithWrongType)
|
TEST(Authenticators, FailedAuthenticateWithWrongType)
|
||||||
{
|
{
|
||||||
struct wsfs_credentials creds;
|
struct credentials creds;
|
||||||
credentials_init(&creds, "token", nullptr);
|
credentials_init(&creds, "token", nullptr);
|
||||||
|
|
||||||
MockAuthenticator username_mock;
|
MockAuthenticator username_mock;
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
TEST(Credentials, Type)
|
TEST(Credentials, Type)
|
||||||
{
|
{
|
||||||
struct wsfs_credentials creds;
|
struct credentials creds;
|
||||||
|
|
||||||
credentials_init(&creds, "test", nullptr);
|
credentials_init(&creds, "test", nullptr);
|
||||||
ASSERT_STREQ("test", credentials_type(&creds));
|
ASSERT_STREQ("test", credentials_type(&creds));
|
||||||
@ -14,7 +14,7 @@ TEST(Credentials, Type)
|
|||||||
|
|
||||||
TEST(Credentials, Get)
|
TEST(Credentials, Get)
|
||||||
{
|
{
|
||||||
struct wsfs_credentials creds;
|
struct credentials creds;
|
||||||
json_t * data = json_object();
|
json_t * data = json_object();
|
||||||
json_object_set_new(data, "username", json_string("bob"));
|
json_object_set_new(data, "username", json_string("bob"));
|
||||||
json_object_set_new(data, "password", json_string("<secret>"));
|
json_object_set_new(data, "password", json_string("<secret>"));
|
||||||
@ -30,7 +30,7 @@ TEST(Credentials, Get)
|
|||||||
|
|
||||||
TEST(Credentials, FailedToGetNonexistingValue)
|
TEST(Credentials, FailedToGetNonexistingValue)
|
||||||
{
|
{
|
||||||
struct wsfs_credentials creds;
|
struct credentials creds;
|
||||||
json_t * data = json_object();
|
json_t * data = json_object();
|
||||||
|
|
||||||
credentials_init(&creds, "username", data);
|
credentials_init(&creds, "username", data);
|
||||||
@ -44,7 +44,7 @@ TEST(Credentials, FailedToGetNonexistingValue)
|
|||||||
|
|
||||||
TEST(Credentials, FailedToGetWithoutData)
|
TEST(Credentials, FailedToGetWithoutData)
|
||||||
{
|
{
|
||||||
struct wsfs_credentials creds;
|
struct credentials creds;
|
||||||
|
|
||||||
credentials_init(&creds, "username", nullptr);
|
credentials_init(&creds, "username", nullptr);
|
||||||
ASSERT_STREQ("username",credentials_type(&creds));
|
ASSERT_STREQ("username",credentials_type(&creds));
|
||||||
@ -56,7 +56,7 @@ TEST(Credentials, FailedToGetWithoutData)
|
|||||||
|
|
||||||
TEST(Credentials, FailedToGetWrongDataType)
|
TEST(Credentials, FailedToGetWrongDataType)
|
||||||
{
|
{
|
||||||
struct wsfs_credentials creds;
|
struct credentials creds;
|
||||||
json_t * data = json_string("invalid_creds");
|
json_t * data = json_string("invalid_creds");
|
||||||
|
|
||||||
credentials_init(&creds, "username", data);
|
credentials_init(&creds, "username", data);
|
||||||
|
Loading…
Reference in New Issue
Block a user