2 * Copyright 2018 TechMahindra
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
24 //Unit test to varify GetTLSconfig func and varify the tls config min version to be 771
\r
25 //Assuming cert file name as auth_test.cert
\r
26 func TestGetTLSConfig(t *testing.T) {
\r
27 _, err := GetTLSConfig("filedoesnotexist.cert", "filedoesnotexist.cert", "filedoesnotexist.cert")
\r
29 t.Errorf("Test failed, expected error but got none")
\r
31 tlsConfig, err := GetTLSConfig("../../../tests/certs/auth_test_certificate.pem",
\r
32 "../../../tests/certs/auth_test_certificate.pem",
\r
33 "../../../tests/certs/auth_test_key.pem")
\r
35 t.Fatal("Test Failed as GetTLSConfig returned error: " + err.Error())
\r
37 expected := tls.VersionTLS12
\r
38 actual := tlsConfig.MinVersion
\r
39 if tlsConfig != nil {
\r
40 if int(actual) != expected {
\r
41 t.Errorf("Test Failed due to version mismatch")
\r
43 if tlsConfig == nil {
\r
44 t.Errorf("Test Failed due to GetTLSConfig returned nil")
\r