-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Correctly unmarshal Protocol (#17843)
The Protocol (https/http) was not correctly unmarshaly and assigned to the value of the struct. Because of this the checking was trying to use a plain text connection or a TLS enabled endpoint. Fixes: #17841
- Loading branch information
Showing
3 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// 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. | ||
|
||
package kibana | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
"time" | ||
|
||
"gopkg.in/yaml.v2" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestPackUnpack(t *testing.T) { | ||
c := Config{ | ||
Protocol: Protocol("https"), | ||
SpaceID: "123", | ||
Username: "foo", | ||
Password: "bar", | ||
Path: "/ok", | ||
Timeout: 10 * time.Second, | ||
} | ||
|
||
b, err := yaml.Marshal(&c) | ||
require.NoError(t, err) | ||
|
||
c2 := Config{} | ||
|
||
err = yaml.Unmarshal(b, &c2) | ||
require.NoError(t, err) | ||
|
||
assert.True(t, reflect.DeepEqual(c, c2)) | ||
} |