Skip to content

Commit

Permalink
Restore #27286 and add missing corresponding test update (#27399)
Browse files Browse the repository at this point in the history
**Description:**
Restore #27286 (see PR #27397) and add missing test update.

**Link to tracking Issue:**
N/A

**Testing:**
Ran test locally.

**Documentation:**
N/A

cc @djaglowski @songy23
  • Loading branch information
pjanotti authored Oct 3, 2023
1 parent 28bce8a commit 9f95743
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pkg/stanza/operator/input/windows/publisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ func (p *Publisher) Open(provider string) error {

utf16, err := syscall.UTF16PtrFromString(provider)
if err != nil {
return fmt.Errorf("failed to convert provider to utf16: %w", err)
return fmt.Errorf("failed to convert the provider name %q to utf16: %w", provider, err)
}

handle, err := evtOpenPublisherMetadata(0, utf16, nil, 0, 0)
if err != nil {
return fmt.Errorf("failed to open publisher handle: %w", err)
return fmt.Errorf("failed to open the metadata for the %q provider: %w", provider, err)
}

p.handle = handle
Expand Down
4 changes: 2 additions & 2 deletions pkg/stanza/operator/input/windows/publisher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestPublisherOpenInvalidUTF8(t *testing.T) {
invalidUTF8 := "\u0000"
err := publisher.Open(invalidUTF8)
require.Error(t, err)
require.Contains(t, err.Error(), "failed to convert provider to utf16")
require.Contains(t, err.Error(), "failed to convert the provider name \"\\x00\" to utf16: invalid argument")
}

func TestPublisherOpenSyscallFailure(t *testing.T) {
Expand All @@ -33,7 +33,7 @@ func TestPublisherOpenSyscallFailure(t *testing.T) {
openPublisherMetadataProc = SimpleMockProc(0, 0, ErrorNotSupported)
err := publisher.Open(provider)
require.Error(t, err)
require.Contains(t, err.Error(), "failed to open publisher handle")
require.Contains(t, err.Error(), "failed to open the metadata for the \"provider\" provider: The request is not supported.")
}

func TestPublisherOpenSuccess(t *testing.T) {
Expand Down

0 comments on commit 9f95743

Please sign in to comment.