Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xds: E2E Test for Audit Logging #6377

Merged
merged 9 commits into from
Jun 29, 2023
Merged

Conversation

gtcooke94
Copy link
Contributor

This PR adds testing for audit logging logic to the existing RBAC tests. It very closely matches the tests for the authz path - #6304

I've currently only added a very basic test of the audit logger - the purpose here is to make sure that we can construct an audit logger through the xds path and it works.
I'm open to adding test cases for the various combinations of audit logging and authorization policies, but I think that's not really what we are testing here, and it's a pretty explosive combination and pollutes the test (if it's not necessary). All these cases should be covered in other tests like the unit tests and the authz path tests. @dfawley @easwars what do you think? I see compelling reasons for either choice.

RELEASE NOTES: N/A

@gtcooke94 gtcooke94 added this to the 1.57 Release milestone Jun 15, 2023
@@ -605,6 +630,12 @@ func (s) TestRBACHTTPFilter(t *testing.T) {
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
func() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not new but do you know why such a anonymous func is needed here?

Copy link
Contributor Author

@gtcooke94 gtcooke94 Jun 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No clue, I'm just working into the existing test - at a glance it does seem unnecessary

test/xds/xds_server_rbac_test.go Outdated Show resolved Hide resolved
test/xds/xds_server_rbac_test.go Outdated Show resolved Hide resolved
test/xds/xds_server_rbac_test.go Outdated Show resolved Hide resolved
test/xds/xds_server_rbac_test.go Show resolved Hide resolved
@gtcooke94 gtcooke94 requested a review from rockspore June 20, 2023 21:08
Copy link
Contributor

@rockspore rockspore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly LGTM. I'm also open to adding more test cases but I'll leave it to you and other reviewers.

test/xds/xds_server_rbac_test.go Outdated Show resolved Hide resolved
@@ -660,6 +693,17 @@ func (s) TestRBACHTTPFilter(t *testing.T) {
}
// Toggle RBAC back on for next iterations.
envconfig.XDSRBAC = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's worth considering adding some check to verify audit logging is not active till RBAC is toggled back.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it ends up being somewhat implicit in the test - it makes 2 calls with RBAC on, then 2 calls with RBAC off, and the expected outcome for logging is allowed: 2, denied: 0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree that this isn't the best as it requires holding some test state in your head as you look at it, but I hesitate to make large changes to this existing test

test/xds/xds_server_rbac_test.go Outdated Show resolved Hide resolved
Copy link
Member

@arvindbr8 arvindbr8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one minor comment about the recoverable assertion check. LGTM otherwise.

test/xds/xds_server_rbac_test.go Outdated Show resolved Hide resolved
test/xds/xds_server_rbac_test.go Outdated Show resolved Hide resolved
@arvindbr8 arvindbr8 assigned gtcooke94 and unassigned arvindbr8 Jun 27, 2023
@gtcooke94 gtcooke94 requested a review from arvindbr8 June 29, 2023 18:23
@gtcooke94 gtcooke94 merged commit 67e881c into grpc:master Jun 29, 2023
1 check passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants