-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Forward-port] Update audit events with additional fields. (#2655)
- Loading branch information
Showing
36 changed files
with
556 additions
and
105 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
Submodule e
updated
from 91be21 to dfb02d
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
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 |
---|---|---|
|
@@ -16,15 +16,20 @@ limitations under the License. | |
|
||
package events | ||
|
||
import "gopkg.in/check.v1" | ||
import "time" | ||
import ( | ||
"time" | ||
|
||
type AuditApiTestSuite struct { | ||
} | ||
"github.com/gravitational/teleport/lib/fixtures" | ||
"github.com/gravitational/teleport/lib/utils" | ||
"github.com/jonboulle/clockwork" | ||
"gopkg.in/check.v1" | ||
) | ||
|
||
type AuditAPITestSuite struct{} | ||
|
||
var _ = check.Suite(&AuditApiTestSuite{}) | ||
var _ = check.Suite(&AuditAPITestSuite{}) | ||
|
||
func (a *AuditApiTestSuite) TestFields(c *check.C) { | ||
func (a *AuditAPITestSuite) TestFields(c *check.C) { | ||
now := time.Now().Round(time.Minute) | ||
|
||
f := EventFields{ | ||
|
@@ -48,3 +53,29 @@ func (a *AuditApiTestSuite) TestFields(c *check.C) { | |
t := f.GetTime("time") | ||
c.Assert(t, check.Equals, now) | ||
} | ||
|
||
func (a *AuditAPITestSuite) TestUpdateFields(c *check.C) { | ||
event := Event{ | ||
Name: "test.event", | ||
Code: "TEST0001I", | ||
Severity: SeverityInfo, | ||
Message: "User {{.user}} logged in via {{.method}}", | ||
} | ||
fields := EventFields{ | ||
EventUser: "[email protected]", | ||
LoginMethod: LoginMethodOIDC, | ||
} | ||
c.Assert(UpdateEventFields(event, fields, clockwork.NewFakeClock(), utils.NewFakeUID()), check.IsNil) | ||
|
||
// Check the fields have been updated appropriately. | ||
c.Assert(fields, check.DeepEquals, EventFields{ | ||
EventType: event.Name, | ||
EventID: fixtures.UUID, | ||
EventCode: event.Code, | ||
EventTime: time.Date(1984, time.April, 4, 0, 0, 0, 0, time.UTC), | ||
EventSeverity: SeverityInfo, | ||
EventUser: "[email protected]", | ||
EventMessage: "User [email protected] logged in via oidc", | ||
LoginMethod: LoginMethodOIDC, | ||
}) | ||
} |
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
Oops, something went wrong.