Skip to content

Commit

Permalink
Merge pull request #38 from auth0/feature/DXCDT-104
Browse files Browse the repository at this point in the history
[DXCDT-104] Add Filters to LogStream
  • Loading branch information
sergiught authored Apr 7, 2022
2 parents 9ac8228 + 825358f commit 3850d38
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 18 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Change Log

<a name="v0.6.2"></a>
## [v0.6.2](https://github.com/auth0/go-auth0/tree/v0.6.2) (2022-04-07)

[Full Changelog](https://github.com/auth0/go-auth0/compare/v0.6.1...v0.6.2)

### Added

- Added a method to `Unlink` a `User`'s identity ([#35](https://github.com/auth0/go-auth0/pull/35))
- Added fields required to support self-managed certificates ([#37](https://github.com/auth0/go-auth0/pull/37))
- Added `profileData` key to `UserIdentity` ([#33](https://github.com/auth0/go-auth0/pull/33))
- [DXCDT-104] Added `Filters` to `LogStream` ([#38](https://github.com/auth0/go-auth0/pull/38))


<a name="v0.6.1"></a>
## [v0.6.1](https://github.com/auth0/go-auth0/tree/v0.6.1) (2022-03-03)

Expand Down
8 changes: 7 additions & 1 deletion management/log_stream.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package management

import "encoding/json"
import (
"encoding/json"
)

const (
// LogStreamTypeAmazonEventBridge constant.
Expand Down Expand Up @@ -36,6 +38,10 @@ type LogStream struct {
// The status of the log-stream. Can be one of "active", "paused", or "suspended".
Status *string `json:"status,omitempty"`

// Only logs events matching these filters will be delivered by the stream.
// If omitted or empty, all events will be delivered.
Filters []interface{} `json:"filters,omitempty"`

// Sink for validation.
Sink interface{} `json:"-"`
}
Expand Down
40 changes: 23 additions & 17 deletions management/log_stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@ import (
)

func TestLogStream(t *testing.T) {
l := &LogStream{
logStream := &LogStream{
Name: auth0.Stringf("Test-LogStream-%d", time.Now().Unix()),
Type: auth0.String(LogStreamTypeDatadog),
Filters: []interface{}{
map[string]string{
"type": "category",
"name": "auth.login.fail",
},
},
Sink: &LogStreamSinkDatadog{
APIKey: auth0.String("12334567876543"),
Region: auth0.String("eu"),
Expand All @@ -21,25 +27,25 @@ func TestLogStream(t *testing.T) {
var err error

t.Run("Create", func(t *testing.T) {
err = m.LogStream.Create(l)
err = m.LogStream.Create(logStream)
if err != nil {
t.Fatal(err)
}
if _, ok := l.Sink.(*LogStreamSinkDatadog); !ok {
t.Errorf("unexpected options type %T", l.Sink)
if _, ok := logStream.Sink.(*LogStreamSinkDatadog); !ok {
t.Errorf("unexpected options type %T", logStream.Sink)
}
t.Logf("%v\n", l)
t.Logf("%v\n", logStream)
})

t.Run("Read", func(t *testing.T) {
l, err = m.LogStream.Read(l.GetID())
logStream, err = m.LogStream.Read(logStream.GetID())
if err != nil {
t.Error(err)
}
if _, ok := l.Sink.(*LogStreamSinkDatadog); !ok {
t.Errorf("unexpected options type %T", l.Sink)
if _, ok := logStream.Sink.(*LogStreamSinkDatadog); !ok {
t.Errorf("unexpected options type %T", logStream.Sink)
}
t.Logf("%v\n", l)
t.Logf("%v\n", logStream)
})

t.Run("List", func(t *testing.T) {
Expand Down Expand Up @@ -76,27 +82,27 @@ func TestLogStream(t *testing.T) {
})

t.Run("Update", func(t *testing.T) {
id := l.GetID()
id := logStream.GetID()

l.ID = nil // read-only
l.Name = nil // read-only
l.Type = nil // read-only
logStream.ID = nil // read-only
logStream.Name = nil // read-only
logStream.Type = nil // read-only

l.Sink = &LogStreamSinkDatadog{
logStream.Sink = &LogStreamSinkDatadog{
APIKey: auth0.String("12334567876543"),
Region: auth0.String("us"),
}

err = m.LogStream.Update(id, l)
err = m.LogStream.Update(id, logStream)
if err != nil {
t.Error(err)
}

t.Logf("%v\n", l)
t.Logf("%v\n", logStream)
})

t.Run("Delete", func(t *testing.T) {
err = m.LogStream.Delete(l.GetID())
err = m.LogStream.Delete(logStream.GetID())
if err != nil {
t.Error(err)
}
Expand Down

0 comments on commit 3850d38

Please sign in to comment.