configuration UPDATE headers reorganized

config_new now made an internal header, server_config added to installed
ones. Includes reworked.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0758aa7..e20d290 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -139,8 +139,7 @@
     src/session_client_ch.h
     src/session_server.h
     src/session_server_ch.h
-    src/server_config.h
-    src/config_new.h)
+    src/server_config.h)
 
 # files to generate doxygen from
 set(doxy_files
@@ -153,7 +152,8 @@
     src/session_client.h
     src/session_client_ch.h
     src/session_server.h
-    src/session_server_ch.h)
+    src/session_server_ch.h
+    src/server_config.h)
 
 # source files to be covered by the 'format' target
 set(format_sources
diff --git a/src/config_new.h b/src/config_new.h
index cccda4d..bbaab14 100644
--- a/src/config_new.h
+++ b/src/config_new.h
@@ -18,6 +18,8 @@
 
 #include <libyang/libyang.h>
 
+#include "session_p.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -30,181 +32,17 @@
 } NC_ALG_TYPE;
 
 /**
- * @brief Creates new YANG configuration data nodes for a hostkey.
+ * @brief Configures the listen subtree in the ietf-netconf-server module.
  *
- * @param[in] privkey_path Path to a file containing a private key.
- * The private key has to be in a PEM format. Only RSA and ECDSA keys are supported.
- * @param[in] pubkey_path Path to a file containing a public key. If NULL, public key will be
- * generated from the private key.
- * @param[in] ctx libyang context.
- * @param[in] endpt_name Arbitrary identifier of the endpoint.
- * If an endpoint with this identifier already exists, it's hostkey might be changed.
- * @param[in] hostkey_name Arbitrary identifier of the hostkey.
- * If a hostkey with this identifier already exists, it's contents will be changed.
- * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
- * Otherwise the new YANG data will be added to the previous data and may override it.
- * @return 0 on success, non-zero otherwise.
+ * @param[in] op Operation to be done on the subtree. Only does something if the operation is NC_OP_DELETE.
+ * @return 0 on success, 1 on error.
  */
-int nc_server_config_ssh_new_hostkey(const char *privkey_path, const char *pubkey_path, const struct ly_ctx *ctx,
-        const char *endpt_name, const char *hostkey_name, struct lyd_node **config);
+int nc_server_config_listen(NC_OPERATION op);
 
 /**
- * @brief Creates new YANG configuration data nodes for a local-address and local-port.
- *
- * @param[in] address New listening address.
- * @param[in] port New listening port.
- * @param[in] ctx libyang context.
- * @param[in] endpt_name Arbitrary identifier of the endpoint.
- * If an endpoint with this identifier already exists, it's address and port will be overriden.
- * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
- * Otherwise the new YANG data will be added to the previous data and may override it.
- * @return 0 on success, non-zero otherwise.
+ * @brief Deletes every key stored in the keystore.
  */
-int nc_server_config_ssh_new_address_port(const char *address, const char *port, const struct ly_ctx *ctx,
-        const char *endpt_name, struct lyd_node **config);
-
-/**
- * @brief Creates new YANG configuration data nodes for host-key algorithms replacing any previous ones.
- *
- * Supported algorithms are: ssh-ed25519, ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, ecdsa-sha2-nistp521,
- * rsa-sha2-512, rsa-sha2-256, ssh-rsa and ssh-dss.
- *
- * @param[in] ctx libyang context
- * @param[in] endpt_name Arbitrary identifier of the endpoint.
- * If an endpoint with this identifier already exists, it's host-key algorithms will be replaced.
- * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
- * Otherwise the new YANG data will be added to the previous data and may override it.
- * @param[in] alg_count Number of following algorithms.
- * @param[in] ... String literals of host-key algorithms in a decreasing order of preference.
- * @return 0 on success, non-zero otherwise.
- */
-int nc_server_config_ssh_new_host_key_algs(const struct ly_ctx *ctx, const char *endpt_name,
-        struct lyd_node **config, int alg_count, ...);
-
-/**
- * @brief Creates new YANG configuration data nodes for key exchange algorithms replacing any previous ones.
- *
- * Supported algorithms are: diffie-hellman-group-exchange-sha1, curve25519-sha256, ecdh-sha2-nistp256,
- * ecdh-sha2-nistp384, ecdh-sha2-nistp521, diffie-hellman-group18-sha512, diffie-hellman-group16-sha512,
- * diffie-hellman-group-exchange-sha256 and diffie-hellman-group14-sha256.
- *
- * @param[in] ctx libyang context
- * @param[in] endpt_name Arbitrary identifier of the endpoint.
- * If an endpoint with this identifier already exists, it's key exchange algorithms will be replaced.
- * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
- * Otherwise the new YANG data will be added to the previous data and may override it.
- * @param[in] alg_count Number of following algorithms.
- * @param[in] ... String literals of key exchange algorithms in a decreasing order of preference.
- * @return 0 on success, non-zero otherwise.
- */
-int nc_server_config_ssh_new_key_exchange_algs(const struct ly_ctx *ctx, const char *endpt_name, struct lyd_node **config,
-        int alg_count, ...);
-
-/**
- * @brief Creates new YANG configuration data nodes for encryption algorithms replacing any previous ones.
- *
- * Supported algorithms are: aes256-ctr, aes192-ctr, aes128-ctr, aes256-cbc, aes192-cbc, aes128-cbc, blowfish-cbc
- * triple-des-cbc and none.
- *
- * @param[in] ctx libyang context
- * @param[in] endpt_name Arbitrary identifier of the endpoint.
- * If an endpoint with this identifier already exists, it's encryption algorithms will be replaced.
- * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
- * Otherwise the new YANG data will be added to the previous data and may override it.
- * @param[in] alg_count Number of following algorithms.
- * @param[in] ... String literals of encryption algorithms in a decreasing order of preference.
- * @return 0 on success, non-zero otherwise.
- */
-int nc_server_config_ssh_new_encryption_algs(const struct ly_ctx *ctx, const char *endpt_name, struct lyd_node **config,
-        int alg_count, ...);
-
-/**
- * @brief Creates new YANG configuration data nodes for mac algorithms replacing any previous ones.
- *
- * Supported algorithms are: hmac-sha2-256, hmac-sha2-512 and hmac-sha1.
- *
- * @param[in] ctx libyang context
- * @param[in] endpt_name Arbitrary identifier of the endpoint.
- * If an endpoint with this identifier already exists, it's mac algorithms will be replaced.
- * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
- * Otherwise the new YANG data will be added to the previous data and may override it.
- * @param[in] alg_count Number of following algorithms.
- * @param[in] ... String literals of mac algorithms in a decreasing order of preference.
- * @return 0 on success, non-zero otherwise.
- */
-int nc_server_config_ssh_new_mac_algs(const struct ly_ctx *ctx, const char *endpt_name, struct lyd_node **config,
-        int alg_count, ...);
-
-/**
- * @brief Creates new YANG configuration data nodes for a client, which supports the public key authentication method.
- *
- * @param[in] pubkey_path Path to a file containing the user's public key.
- * @param[in] ctx libyang context.
- * @param[in] endpt_name Arbitrary identifier of the endpoint.
- * If an endpoint with this identifier already exists, it's user might be changed.
- * @param[in] user_name Arbitrary identifier of the user.
- * If an user with this identifier already exists, it's contents will be changed.
- * @param[in] pubkey_name Arbitrary identifier of the user's public key.
- * If a public key with this identifier already exists for this user, it's contents will be changed.
- * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
- * Otherwise the new YANG data will be added to the previous data and may override it.
- * @return 0 on success, non-zero otherwise.
- */
-int nc_server_config_ssh_new_client_auth_pubkey(const char *pubkey_path, const struct ly_ctx *ctx, const char *endpt_name,
-        const char *user_name, const char *pubkey_name, struct lyd_node **config);
-
-/**
- * @brief Creates new YANG configuration data nodes for a client, which supports the password authentication method.
- *
- * This function sets the password for the given user.
- *
- * @param[in] password Cleartext user's password.
- * @param[in] ctx libyang context.
- * @param[in] endpt_name Arbitrary identifier of the endpoint.
- * If an endpoint with this identifier already exists, it's user might be changed.
- * @param[in] user_name Arbitrary identifier of the user.
- * If an user with this identifier already exists, it's contents will be changed.
- * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
- * Otherwise the new YANG data will be added to the previous data and may override it.
- * @return 0 on success, non-zero otherwise.
- */
-int nc_server_config_ssh_new_client_auth_password(const char *password, const struct ly_ctx *ctx, const char *endpt_name,
-        const char *user_name, struct lyd_node **config);
-
-/**
- * @brief Creates new YANG configuration data nodes for a client, which supports the none authentication method.
- *
- * @param[in] ctx libyang context.
- * @param[in] endpt_name Arbitrary identifier of the endpoint.
- * If an endpoint with this identifier already exists, it's user might be changed.
- * @param[in] user_name Arbitrary identifier of the user.
- * If an user with this identifier already exists, it's contents will be changed.
- * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
- * Otherwise the new YANG data will be added to the previous data and may override it.
- * @return 0 on success, non-zero otherwise.
- */
-int nc_server_config_ssh_new_client_auth_none(const struct ly_ctx *ctx, const char *endpt_name,
-        const char *user_name, struct lyd_node **config);
-
-/**
- * @brief Creates new YANG configuration data nodes for a client, which supports the interactive authentication method.
- *
- * @param[in] pam_config_name Name of the PAM configuration file.
- * @param[in] pam_config_name Optional. The absolute path to the directory in which the configuration file
- * with the name conf_name is located. A newer version (>= 1.4) of PAM library is required to be able to specify
- * the path. If NULL is passed, then the PAM's system directories will be searched (usually /etc/pam.d/).
- * @param[in] ctx libyang context.
- * @param[in] endpt_name Arbitrary identifier of the endpoint.
- * If an endpoint with this identifier already exists, it's user might be changed.
- * @param[in] user_name Arbitrary identifier of the user.
- * If an user with this identifier already exists, it's contents will be changed.
- * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
- * Otherwise the new YANG data will be added to the previous data and may override it.
- * @return 0 on success, non-zero otherwise.
- */
-int nc_server_config_ssh_new_client_auth_interactive(const char *pam_config_name, const char *pam_config_dir,
-        const struct ly_ctx *ctx, const char *endpt_name,
-        const char *user_name, struct lyd_node **config);
+void nc_server_config_del_keystore(void);
 
 #ifdef __cplusplus
 }
diff --git a/src/server_config.h b/src/server_config.h
index 189431b..3af4772 100644
--- a/src/server_config.h
+++ b/src/server_config.h
@@ -69,17 +69,181 @@
 int nc_server_config_load_modules(struct ly_ctx **ctx);
 
 /**
- * @brief Configures the listen subtree in the ietf-netconf-server module.
+ * @brief Creates new YANG configuration data nodes for a hostkey.
  *
- * @param[in] op Operation to be done on the subtree. Only does something if the operation is NC_OP_DELETE.
- * @return 0 on success, 1 on error.
+ * @param[in] privkey_path Path to a file containing a private key.
+ * The private key has to be in a PEM format. Only RSA and ECDSA keys are supported.
+ * @param[in] pubkey_path Path to a file containing a public key. If NULL, public key will be
+ * generated from the private key.
+ * @param[in] ctx libyang context.
+ * @param[in] endpt_name Arbitrary identifier of the endpoint.
+ * If an endpoint with this identifier already exists, it's hostkey might be changed.
+ * @param[in] hostkey_name Arbitrary identifier of the hostkey.
+ * If a hostkey with this identifier already exists, it's contents will be changed.
+ * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
+ * Otherwise the new YANG data will be added to the previous data and may override it.
+ * @return 0 on success, non-zero otherwise.
  */
-int nc_server_config_listen(NC_OPERATION op);
+int nc_server_config_ssh_new_hostkey(const char *privkey_path, const char *pubkey_path, const struct ly_ctx *ctx,
+        const char *endpt_name, const char *hostkey_name, struct lyd_node **config);
 
 /**
- * @brief Deletes every key stored in the keystore.
+ * @brief Creates new YANG configuration data nodes for a local-address and local-port.
+ *
+ * @param[in] address New listening address.
+ * @param[in] port New listening port.
+ * @param[in] ctx libyang context.
+ * @param[in] endpt_name Arbitrary identifier of the endpoint.
+ * If an endpoint with this identifier already exists, it's address and port will be overriden.
+ * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
+ * Otherwise the new YANG data will be added to the previous data and may override it.
+ * @return 0 on success, non-zero otherwise.
  */
-void nc_server_config_del_keystore(void);
+int nc_server_config_ssh_new_address_port(const char *address, const char *port, const struct ly_ctx *ctx,
+        const char *endpt_name, struct lyd_node **config);
+
+/**
+ * @brief Creates new YANG configuration data nodes for host-key algorithms replacing any previous ones.
+ *
+ * Supported algorithms are: ssh-ed25519, ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, ecdsa-sha2-nistp521,
+ * rsa-sha2-512, rsa-sha2-256, ssh-rsa and ssh-dss.
+ *
+ * @param[in] ctx libyang context
+ * @param[in] endpt_name Arbitrary identifier of the endpoint.
+ * If an endpoint with this identifier already exists, it's host-key algorithms will be replaced.
+ * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
+ * Otherwise the new YANG data will be added to the previous data and may override it.
+ * @param[in] alg_count Number of following algorithms.
+ * @param[in] ... String literals of host-key algorithms in a decreasing order of preference.
+ * @return 0 on success, non-zero otherwise.
+ */
+int nc_server_config_ssh_new_host_key_algs(const struct ly_ctx *ctx, const char *endpt_name,
+        struct lyd_node **config, int alg_count, ...);
+
+/**
+ * @brief Creates new YANG configuration data nodes for key exchange algorithms replacing any previous ones.
+ *
+ * Supported algorithms are: diffie-hellman-group-exchange-sha1, curve25519-sha256, ecdh-sha2-nistp256,
+ * ecdh-sha2-nistp384, ecdh-sha2-nistp521, diffie-hellman-group18-sha512, diffie-hellman-group16-sha512,
+ * diffie-hellman-group-exchange-sha256 and diffie-hellman-group14-sha256.
+ *
+ * @param[in] ctx libyang context
+ * @param[in] endpt_name Arbitrary identifier of the endpoint.
+ * If an endpoint with this identifier already exists, it's key exchange algorithms will be replaced.
+ * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
+ * Otherwise the new YANG data will be added to the previous data and may override it.
+ * @param[in] alg_count Number of following algorithms.
+ * @param[in] ... String literals of key exchange algorithms in a decreasing order of preference.
+ * @return 0 on success, non-zero otherwise.
+ */
+int nc_server_config_ssh_new_key_exchange_algs(const struct ly_ctx *ctx, const char *endpt_name, struct lyd_node **config,
+        int alg_count, ...);
+
+/**
+ * @brief Creates new YANG configuration data nodes for encryption algorithms replacing any previous ones.
+ *
+ * Supported algorithms are: aes256-ctr, aes192-ctr, aes128-ctr, aes256-cbc, aes192-cbc, aes128-cbc, blowfish-cbc
+ * triple-des-cbc and none.
+ *
+ * @param[in] ctx libyang context
+ * @param[in] endpt_name Arbitrary identifier of the endpoint.
+ * If an endpoint with this identifier already exists, it's encryption algorithms will be replaced.
+ * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
+ * Otherwise the new YANG data will be added to the previous data and may override it.
+ * @param[in] alg_count Number of following algorithms.
+ * @param[in] ... String literals of encryption algorithms in a decreasing order of preference.
+ * @return 0 on success, non-zero otherwise.
+ */
+int nc_server_config_ssh_new_encryption_algs(const struct ly_ctx *ctx, const char *endpt_name, struct lyd_node **config,
+        int alg_count, ...);
+
+/**
+ * @brief Creates new YANG configuration data nodes for mac algorithms replacing any previous ones.
+ *
+ * Supported algorithms are: hmac-sha2-256, hmac-sha2-512 and hmac-sha1.
+ *
+ * @param[in] ctx libyang context
+ * @param[in] endpt_name Arbitrary identifier of the endpoint.
+ * If an endpoint with this identifier already exists, it's mac algorithms will be replaced.
+ * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
+ * Otherwise the new YANG data will be added to the previous data and may override it.
+ * @param[in] alg_count Number of following algorithms.
+ * @param[in] ... String literals of mac algorithms in a decreasing order of preference.
+ * @return 0 on success, non-zero otherwise.
+ */
+int nc_server_config_ssh_new_mac_algs(const struct ly_ctx *ctx, const char *endpt_name, struct lyd_node **config,
+        int alg_count, ...);
+
+/**
+ * @brief Creates new YANG configuration data nodes for a client, which supports the public key authentication method.
+ *
+ * @param[in] pubkey_path Path to a file containing the user's public key.
+ * @param[in] ctx libyang context.
+ * @param[in] endpt_name Arbitrary identifier of the endpoint.
+ * If an endpoint with this identifier already exists, it's user might be changed.
+ * @param[in] user_name Arbitrary identifier of the user.
+ * If an user with this identifier already exists, it's contents will be changed.
+ * @param[in] pubkey_name Arbitrary identifier of the user's public key.
+ * If a public key with this identifier already exists for this user, it's contents will be changed.
+ * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
+ * Otherwise the new YANG data will be added to the previous data and may override it.
+ * @return 0 on success, non-zero otherwise.
+ */
+int nc_server_config_ssh_new_client_auth_pubkey(const char *pubkey_path, const struct ly_ctx *ctx, const char *endpt_name,
+        const char *user_name, const char *pubkey_name, struct lyd_node **config);
+
+/**
+ * @brief Creates new YANG configuration data nodes for a client, which supports the password authentication method.
+ *
+ * This function sets the password for the given user.
+ *
+ * @param[in] password Cleartext user's password.
+ * @param[in] ctx libyang context.
+ * @param[in] endpt_name Arbitrary identifier of the endpoint.
+ * If an endpoint with this identifier already exists, it's user might be changed.
+ * @param[in] user_name Arbitrary identifier of the user.
+ * If an user with this identifier already exists, it's contents will be changed.
+ * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
+ * Otherwise the new YANG data will be added to the previous data and may override it.
+ * @return 0 on success, non-zero otherwise.
+ */
+int nc_server_config_ssh_new_client_auth_password(const char *password, const struct ly_ctx *ctx, const char *endpt_name,
+        const char *user_name, struct lyd_node **config);
+
+/**
+ * @brief Creates new YANG configuration data nodes for a client, which supports the none authentication method.
+ *
+ * @param[in] ctx libyang context.
+ * @param[in] endpt_name Arbitrary identifier of the endpoint.
+ * If an endpoint with this identifier already exists, it's user might be changed.
+ * @param[in] user_name Arbitrary identifier of the user.
+ * If an user with this identifier already exists, it's contents will be changed.
+ * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
+ * Otherwise the new YANG data will be added to the previous data and may override it.
+ * @return 0 on success, non-zero otherwise.
+ */
+int nc_server_config_ssh_new_client_auth_none(const struct ly_ctx *ctx, const char *endpt_name,
+        const char *user_name, struct lyd_node **config);
+
+/**
+ * @brief Creates new YANG configuration data nodes for a client, which supports the interactive authentication method.
+ *
+ * @param[in] pam_config_name Name of the PAM configuration file.
+ * @param[in] pam_config_name Optional. The absolute path to the directory in which the configuration file
+ * with the name conf_name is located. A newer version (>= 1.4) of PAM library is required to be able to specify
+ * the path. If NULL is passed, then the PAM's system directories will be searched (usually /etc/pam.d/).
+ * @param[in] ctx libyang context.
+ * @param[in] endpt_name Arbitrary identifier of the endpoint.
+ * If an endpoint with this identifier already exists, it's user might be changed.
+ * @param[in] user_name Arbitrary identifier of the user.
+ * If an user with this identifier already exists, it's contents will be changed.
+ * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
+ * Otherwise the new YANG data will be added to the previous data and may override it.
+ * @return 0 on success, non-zero otherwise.
+ */
+int nc_server_config_ssh_new_client_auth_interactive(const char *pam_config_name, const char *pam_config_dir,
+        const struct ly_ctx *ctx, const char *endpt_name,
+        const char *user_name, struct lyd_node **config);
 
 #ifdef __cplusplus
 }
diff --git a/src/session_server.c b/src/session_server.c
index e0514e6..cd583cd 100644
--- a/src/session_server.c
+++ b/src/session_server.c
@@ -35,6 +35,7 @@
 #include <unistd.h>
 
 #include "compat.h"
+#include "config_new.h"
 #include "libnetconf.h"
 #include "session_server.h"
 #include "session_server_ch.h"
diff --git a/tests/config.h.in b/tests/config.h.in
index cf58c40..79b5f57 100644
--- a/tests/config.h.in
+++ b/tests/config.h.in
@@ -24,3 +24,16 @@
 
 @SSH_MACRO@
 @TLS_MACRO@
+
+/* nc_server.h local includes (not to use the installed ones) */
+#include "netconf.h"
+#include "log.h"
+#include "messages_server.h"
+#include "server_config.h"
+#include "session_server.h"
+#include "session_server_ch.h"
+
+/* nc_client.h local includes (not to use the installed ones) */
+#include "messages_client.h"
+#include "session_client.h"
+#include "session_client_ch.h"
diff --git a/tests/test_auth.c b/tests/test_auth.c
index c6bfae9..63d7547 100644
--- a/tests/test_auth.c
+++ b/tests/test_auth.c
@@ -13,22 +13,18 @@
  *     https://opensource.org/licenses/BSD-3-Clause
  */
 
+#define _GNU_SOURCE
+
 #include <errno.h>
 #include <pthread.h>
 #include <setjmp.h>
+#include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
 #include <cmocka.h>
 
-#include <libnetconf.h>
-#include <libyang/libyang.h>
-#include <log.h>
-#include <server_config.h>
-#include <session_client.h>
-#include <session_server.h>
-
 #include "tests/config.h"
 
 #define NC_ACCEPT_TIMEOUT 2000
@@ -231,7 +227,7 @@
     (void) hostname;
     (void) priv;
 
-    /* send the replies to keyboard-interactive authentication */
+    /* set the reply to password authentication */
     if (!strcmp(username, "test_pw")) {
         return strdup("testpw");
     } else {
diff --git a/tests/test_config_new.c b/tests/test_config_new.c
index 03c6098..42e8ded 100644
--- a/tests/test_config_new.c
+++ b/tests/test_config_new.c
@@ -13,7 +13,8 @@
  *     https://opensource.org/licenses/BSD-3-Clause
  */
 
-#include <errno.h>
+#define _GNU_SOURCE
+
 #include <pthread.h>
 #include <setjmp.h>
 #include <stdio.h>
@@ -22,14 +23,6 @@
 
 #include <cmocka.h>
 
-#include <libnetconf.h>
-#include <libyang/libyang.h>
-#include <log.h>
-#include <server_config.h>
-#include <session_client.h>
-#include <session_server.h>
-#include "config_new.h"
-
 #include "tests/config.h"
 
 #define NC_ACCEPT_TIMEOUT 2000
@@ -83,8 +76,19 @@
     return 0;
 }
 
+static char *
+auth_password(const char *username, const char *hostname, void *priv)
+{
+    (void) username;
+    (void) hostname;
+    (void) priv;
+
+    /* set the reply to password authentication */
+    return strdup("testpassword123");
+}
+
 static void *
-client_thread_pubkey(void *arg)
+client_thread(void *arg)
 {
     int ret;
     struct nc_session *session = NULL;
@@ -93,13 +97,10 @@
     ret = nc_client_set_schema_searchpath(MODULES_DIR);
     assert_int_equal(ret, 0);
 
-    ret = nc_client_ssh_set_username("test");
+    ret = nc_client_ssh_set_username("client");
     assert_int_equal(ret, 0);
 
-    nc_client_ssh_set_auth_pref(NC_SSH_AUTH_PUBLICKEY, 1);
-
-    ret = nc_client_ssh_add_keypair(TESTS_DIR "/data/key_rsa.pub", TESTS_DIR "/data/key_rsa");
-    assert_int_equal(ret, 0);
+    nc_client_ssh_set_auth_password_clb(auth_password, NULL);
 
     pthread_barrier_wait(&state->barrier);
     session = nc_connect_ssh("127.0.0.1", 10005, NULL);
@@ -111,14 +112,14 @@
 }
 
 static void
-test_nc_auth_pubkey(void **state)
+test_nc_config_new(void **state)
 {
     int ret, i;
     pthread_t tids[2];
 
     assert_non_null(state);
 
-    ret = pthread_create(&tids[0], NULL, client_thread_pubkey, *state);
+    ret = pthread_create(&tids[0], NULL, client_thread, *state);
     assert_int_equal(ret, 0);
     ret = pthread_create(&tids[1], NULL, server_thread, *state);
     assert_int_equal(ret, 0);
@@ -146,25 +147,32 @@
 
     *state = test_state;
 
+    /* new context */
     ret = ly_ctx_new(MODULES_DIR, 0, &ctx);
     assert_int_equal(ret, 0);
 
+    /* initialize the context by loading default modules */
     ret = nc_server_init_ctx(&ctx);
     assert_int_equal(ret, 0);
 
+    /* load ietf-netconf-server module and it's imports */
     ret = nc_server_config_load_modules(&ctx);
     assert_int_equal(ret, 0);
 
+    /* create new hostkey data */
     ret = nc_server_config_ssh_new_hostkey(TESTS_DIR "/data/server.key", NULL, ctx, "endpt", "hostkey", &tree);
     assert_int_equal(ret, 0);
 
+    /* create new address and port data */
     ret = nc_server_config_ssh_new_address_port("127.0.0.1", "10005", ctx, "endpt", &tree);
     assert_int_equal(ret, 0);
 
+    /* create the host-key algorithms data */
     ret = nc_server_config_ssh_new_host_key_algs(ctx, "endpt", &tree, 1, "rsa-sha2-512");
     assert_int_equal(ret, 0);
 
-    ret = nc_server_config_ssh_new_client_auth_pubkey(TESTS_DIR "/data/key_rsa.pub", ctx, "endpt", "test", "pubkey", &tree);
+    /* create the client authentication data, password only */
+    ret = nc_server_config_ssh_new_client_auth_password("testpassword123", ctx, "endpt", "client", &tree);
     assert_int_equal(ret, 0);
 
     /* configure the server based on the data */
@@ -209,7 +217,7 @@
 main(void)
 {
     const struct CMUnitTest tests[] = {
-        cmocka_unit_test_setup_teardown(test_nc_auth_pubkey, setup_f, teardown_f),
+        cmocka_unit_test_setup_teardown(test_nc_config_new, setup_f, teardown_f),
     };
 
     setenv("CMOCKA_TEST_ABORT", "1", 1);
diff --git a/tests/test_keystore.c b/tests/test_keystore.c
index 7c20577..8b966b0 100644
--- a/tests/test_keystore.c
+++ b/tests/test_keystore.c
@@ -13,22 +13,18 @@
  *     https://opensource.org/licenses/BSD-3-Clause
  */
 
+#define _GNU_SOURCE
+
 #include <errno.h>
 #include <pthread.h>
 #include <setjmp.h>
+#include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
 #include <cmocka.h>
 
-#include <libnetconf.h>
-#include <libyang/libyang.h>
-#include <log.h>
-#include <server_config.h>
-#include <session_client.h>
-#include <session_server.h>
-
 #include "tests/config.h"
 
 #define NC_ACCEPT_TIMEOUT 2000
diff --git a/tests/test_two_channels.c b/tests/test_two_channels.c
index fb85bbf..8c24a69 100644
--- a/tests/test_two_channels.c
+++ b/tests/test_two_channels.c
@@ -12,24 +12,19 @@
  *
  *     https://opensource.org/licenses/BSD-3-Clause
  */
+#define _GNU_SOURCE
 
 #include <errno.h>
 #include <pthread.h>
-#include <semaphore.h>
 #include <setjmp.h>
+#include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
 
 #include <cmocka.h>
 
-#include <libnetconf.h>
-#include <libyang/libyang.h>
-#include <log.h>
-#include <server_config.h>
-#include <session_client.h>
-#include <session_server.h>
-
 #include "tests/config.h"
 
 #define NC_ACCEPT_TIMEOUT 2000
diff --git a/tests/test_unix_socket.c b/tests/test_unix_socket.c
index e698e7b..e106982 100644
--- a/tests/test_unix_socket.c
+++ b/tests/test_unix_socket.c
@@ -13,22 +13,18 @@
  *     https://opensource.org/licenses/BSD-3-Clause
  */
 
+#define _GNU_SOURCE
+
 #include <errno.h>
 #include <pthread.h>
 #include <setjmp.h>
+#include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
 #include <cmocka.h>
 
-#include <libnetconf.h>
-#include <libyang/libyang.h>
-#include <log.h>
-#include <server_config.h>
-#include <session_client.h>
-#include <session_server.h>
-
 #include "tests/config.h"
 
 #define NC_ACCEPT_TIMEOUT 2000