-
Notifications
You must be signed in to change notification settings - Fork 88
/
Copy pathconfig_nofips_test.go
42 lines (33 loc) · 1.27 KB
/
config_nofips_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.
//go:build !integration && !requirefips
package config
import (
"crypto/tls"
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/elastic/elastic-agent-libs/transport/tlscommon"
)
func TestTLSDefaults(t *testing.T) {
c, err := LoadFile(filepath.Join("testdata", "tls.yml"))
require.NoError(t, err)
require.NotNil(t, c.Output.Elasticsearch.TLS)
common, err := tlscommon.LoadTLSConfig(c.Output.Elasticsearch.TLS)
require.NoError(t, err)
cfg := common.ToConfig()
assert.Equal(t, uint16(tls.VersionTLS11), cfg.MinVersion)
assert.Equal(t, uint16(tls.VersionTLS13), cfg.MaxVersion)
}
func TestTLS10(t *testing.T) {
c, err := LoadFile(filepath.Join("testdata", "tls10.yml"))
require.NoError(t, err)
require.NotNil(t, c.Output.Elasticsearch.TLS)
common, err := tlscommon.LoadTLSConfig(c.Output.Elasticsearch.TLS)
require.NoError(t, err)
cfg := common.ToConfig()
assert.Equal(t, uint16(tls.VersionTLS10), cfg.MinVersion)
assert.Equal(t, uint16(tls.VersionTLS10), cfg.MaxVersion)
}