tests: ssl: Move min/max TLS version setting to endpoint init

Move min/max TLS version setting to endpoint init
where it fits better: before the call to
mbedtls_ssl_setup() and available for all tests
not only those calling perform_handshake().

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
diff --git a/tests/src/test_helpers/ssl_helpers.c b/tests/src/test_helpers/ssl_helpers.c
index b130edd..beccbb5 100644
--- a/tests/src/test_helpers/ssl_helpers.c
+++ b/tests/src/test_helpers/ssl_helpers.c
@@ -804,6 +804,28 @@
                                       MBEDTLS_SSL_PRESET_DEFAULT);
     TEST_ASSERT(ret == 0);
 
+    if (MBEDTLS_SSL_IS_CLIENT == endpoint_type) {
+        if (options->client_min_version != MBEDTLS_SSL_VERSION_UNKNOWN) {
+            mbedtls_ssl_conf_min_tls_version(&(ep->conf),
+                                             options->client_min_version);
+        }
+
+        if (options->client_max_version != MBEDTLS_SSL_VERSION_UNKNOWN) {
+            mbedtls_ssl_conf_max_tls_version(&(ep->conf),
+                                             options->client_max_version);
+        }
+    } else {
+        if (options->server_min_version != MBEDTLS_SSL_VERSION_UNKNOWN) {
+            mbedtls_ssl_conf_min_tls_version(&(ep->conf),
+                                             options->server_min_version);
+        }
+
+        if (options->server_max_version != MBEDTLS_SSL_VERSION_UNKNOWN) {
+            mbedtls_ssl_conf_max_tls_version(&(ep->conf),
+                                             options->server_max_version);
+        }
+    }
+
     if (group_list != NULL) {
         mbedtls_ssl_conf_groups(&(ep->conf), group_list);
     }
@@ -1784,16 +1806,6 @@
                                                    NULL, NULL) == 0);
     }
 
-    if (options->client_min_version != MBEDTLS_SSL_VERSION_UNKNOWN) {
-        mbedtls_ssl_conf_min_tls_version(&client.conf,
-                                         options->client_min_version);
-    }
-
-    if (options->client_max_version != MBEDTLS_SSL_VERSION_UNKNOWN) {
-        mbedtls_ssl_conf_max_tls_version(&client.conf,
-                                         options->client_max_version);
-    }
-
     if (strlen(options->cipher) > 0) {
         set_ciphersuite(&client.conf, options->cipher, forced_ciphersuite);
     }
@@ -1827,16 +1839,6 @@
 
     mbedtls_ssl_conf_authmode(&server.conf, options->srv_auth_mode);
 
-    if (options->server_min_version != MBEDTLS_SSL_VERSION_UNKNOWN) {
-        mbedtls_ssl_conf_min_tls_version(&server.conf,
-                                         options->server_min_version);
-    }
-
-    if (options->server_max_version != MBEDTLS_SSL_VERSION_UNKNOWN) {
-        mbedtls_ssl_conf_max_tls_version(&server.conf,
-                                         options->server_max_version);
-    }
-
 #if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH)
     TEST_ASSERT(mbedtls_ssl_conf_max_frag_len(&(server.conf),
                                               (unsigned char) options->mfl)