forked from smartcontractkit/chainlink
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move audit logger config (smartcontractkit#9468)
- Loading branch information
1 parent
f567d60
commit aee738f
Showing
12 changed files
with
213 additions
and
207 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,13 @@ | ||
package config | ||
|
||
import ( | ||
"github.com/smartcontractkit/chainlink/v2/core/store/models" | ||
) | ||
|
||
type AuditLogger interface { | ||
Enabled() bool | ||
ForwardToUrl() (models.URL, error) | ||
Environment() string | ||
JsonWrapperKey() string | ||
Headers() (models.ServiceHeaders, error) | ||
} |
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
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,33 @@ | ||
package chainlink | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestAuditLoggerConfig(t *testing.T) { | ||
opts := GeneralConfigOpts{ | ||
ConfigStrings: []string{fullTOML}, | ||
} | ||
cfg, err := opts.New() | ||
require.NoError(t, err) | ||
|
||
auditConfig := cfg.AuditLogger() | ||
|
||
require.Equal(t, true, auditConfig.Enabled()) | ||
require.Equal(t, "event", auditConfig.JsonWrapperKey()) | ||
|
||
fUrl, err := auditConfig.ForwardToUrl() | ||
require.NoError(t, err) | ||
require.Equal(t, "http", fUrl.Scheme) | ||
require.Equal(t, "localhost:9898", fUrl.Host) | ||
|
||
headers, err := auditConfig.Headers() | ||
require.NoError(t, err) | ||
require.Len(t, headers, 2) | ||
require.Equal(t, "Authorization", headers[0].Header) | ||
require.Equal(t, "token", headers[0].Value) | ||
require.Equal(t, "X-SomeOther-Header", headers[1].Header) | ||
require.Equal(t, "value with spaces | and a bar+*", headers[1].Value) | ||
} |
Oops, something went wrong.