test: Introduce isds_change_password
[libisds.git] / test / simline / server.h
blobb1de86d0af582e0adef076f49c2a83d1fab40891
1 #ifndef __ISDS_SERVER_H
2 #define __ISDS_SERVER_H
4 #include "services.h"
6 extern const char *server_error;
8 /* Save pointer to static error message if not yet set */
9 void set_server_error(const char *message);
12 /* Creates listening TCP socket on localhost.
13 * Returns the socket descriptor or -1. */
14 int listen_on_socket(void);
17 /* Format socket address as printable string.
18 * @return allocated string or NULL in case of error. */
19 char *socket2address(int socket);
22 struct arguments_basic_authentication {
23 const char *username; /* Sets required user name server has to require.
24 Set NULL to disable HTTP authentication. */
25 const char *password; /* sets required password server has to require */
26 _Bool isds_deviations; /* is flag to set conformance level. If false,
27 server is compliant to standards (HTTP, SOAP)
28 if not conflicts with ISDS specification.
29 Otherwise server mimics real ISDS implementation
30 as much as possible. */
31 const struct service_configuration *services; /* Array of enabled
32 services. Last name must
33 be SERVICE_END. */
36 /* Do the server protocol.
37 * @server_socket is listening TCP socket of the server
38 * @server_arguments is pointer to structure:
39 * Never returns. Terminates by exit(). */
40 void server_basic_authentication(int server_socket,
41 const void *server_arguments);
44 /* One-time password authentication method */
45 enum auth_otp_method {
46 AUTH_OTP_HMAC = 0, /* HMAC-based OTP */
47 AUTH_OTP_TIME /* Time-based OTP */
50 struct arguments_otp_authentication {
51 enum auth_otp_method method; /* Selects OTP method to enable */
52 const char *username; /* Sets required user name server has to require.
53 Set NULL to disable HTTP authentication. */
54 const char *password; /* Sets password server has to require */
55 const char *otp; /* Sets OTP code server has to requiere */
56 _Bool isds_deviations; /* Is flag to set conformance level. If false,
57 server is compliant to standards (HTTP, SOAP)
58 if not conflicts with ISDS specification.
59 Otherwise server mimics real ISDS implementation
60 as much as possible. */
61 const struct service_configuration *services; /* Array of enabled
62 services. Last name must
63 be SERVICE_END. */
66 /* Do the server protocol with OTP authentication.
67 * @server_socket is listening TCP socket of the server
68 * @server_arguments is pointer to structure arguments_otp_authentication. It
69 * selects OTP method to enable.
70 * Never returns. Terminates by exit(). */
71 void server_otp_authentication(int server_socket,
72 const void *server_arguments);
74 /* Implementation of server that is out of order.
75 * It always sends back SOAP Fault with HTTP error 503.
76 * @server_socket is listening TCP socket of the server
77 * @server_arguments is ununsed pointer
78 * Never returns. Terminates by exit(). */
79 void server_out_of_order(int server_socket,
80 const void *server_arguments);
83 /* Start sever in separate process.
84 * @server_process is PID of forked server
85 * @server_address is automatically allocated TCP address of listening server
86 * @username sets required user name server has to require. Set NULL to
87 * disable HTTP authentication.
88 * @password sets required password server has to require
89 * socket.
90 * @isds_deviations is flag to set conformance level. If false, server is
91 * compliant to standards (HTTP, SOAP) if not conflicts with ISDS
92 * specification. Otherwise server mimics real ISDS implementation as much
93 * as possible.
94 * @return -1 in case of error. */
95 int start_server(pid_t *server_process, char **server_address,
96 void (*server_implementation)(int, const void *),
97 const void *server_arguments);
100 /* Kill the server process.
101 * Return -1 in case of error. */
102 int stop_server(pid_t server_process);
104 #endif