From bde209c3bf11df007b15a782366e4c025424366a Mon Sep 17 00:00:00 2001 From: Lennart Kats Date: Sun, 22 Sep 2024 16:07:35 +0200 Subject: [PATCH] Process PR feedback --- bundle/permissions/permission_diagnostics.go | 2 +- bundle/permissions/permission_diagnostics_test.go | 12 ++---------- bundle/permissions/permission_report_test.go | 10 +++++----- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/bundle/permissions/permission_diagnostics.go b/bundle/permissions/permission_diagnostics.go index 43b8acaa3..72c5dd1a3 100644 --- a/bundle/permissions/permission_diagnostics.go +++ b/bundle/permissions/permission_diagnostics.go @@ -59,7 +59,7 @@ func analyzeBundlePermissions(b *bundle.Bundle) (bool, string) { currentUser := b.Config.Workspace.CurrentUser.UserName targetPermissions := b.Config.Permissions for _, p := range targetPermissions { - if p.Level != CAN_MANAGE && p.Level != IS_OWNER { + if p.Level != CAN_MANAGE { continue } diff --git a/bundle/permissions/permission_diagnostics_test.go b/bundle/permissions/permission_diagnostics_test.go index a13ae1710..7b0afefa0 100644 --- a/bundle/permissions/permission_diagnostics_test.go +++ b/bundle/permissions/permission_diagnostics_test.go @@ -32,22 +32,14 @@ func TestPermissionDiagnosticsApplyFail(t *testing.T) { require.Contains(t, diags[0].Summary, "permissions section should include testuser@databricks.com or one of their groups with CAN_MANAGE permissions") } -func TestPermissionDiagnosticsApplySuccessWithOwner(t *testing.T) { - b := mockBundle([]resources.Permission{ - {Level: "IS_OWNER", UserName: "testuser@databricks.com"}, - }) - - diags := permissions.PermissionDiagnostics().Apply(context.Background(), b) - require.Empty(t, diags) -} - func mockBundle(permissions []resources.Permission) *bundle.Bundle { return &bundle.Bundle{ Config: config.Root{ Workspace: config.Workspace{ CurrentUser: &config.User{ User: &iam.User{ - UserName: "testuser@databricks.com", + UserName: "testuser@databricks.com", + DisplayName: "Test User", Groups: []iam.ComplexValue{ {Display: "testgroup"}, }, diff --git a/bundle/permissions/permission_report_test.go b/bundle/permissions/permission_report_test.go index 61592f7e5..b92637bc7 100644 --- a/bundle/permissions/permission_report_test.go +++ b/bundle/permissions/permission_report_test.go @@ -15,7 +15,7 @@ func TestPermissionsReportPermissionDeniedWithGroup(t *testing.T) { }) diags := permissions.ReportPossiblePermissionDenied(context.Background(), b, "testpath") - expected := "EPERM3: unable to deploy to testpath as testuser@databricks.com. Cannot apply local deployment permissions.\n" + + expected := "EPERM3: unable to deploy to testpath as Test User. Cannot apply local deployment permissions.\n" + "For assistance, contact the owners of this project.\n" + "They can redeploy the project to apply the latest set of permissions.\n" + "Please refer to https://docs.databricks.com/dev-tools/bundles/permissions.html for more on managing permissions." @@ -28,7 +28,7 @@ func TestPermissionsReportPermissionDeniedWithOtherGroup(t *testing.T) { }) diags := permissions.ReportPossiblePermissionDenied(context.Background(), b, "testpath") - expected := "EPERM1: unable to deploy to testpath as testuser@databricks.com.\n" + + expected := "EPERM1: unable to deploy to testpath as Test User.\n" + "Please make sure the current user or one of their groups is listed under the permissions of this bundle.\n" + "For assistance, users or groups with appropriate permissions may include: othergroup.\n" + "They may need to redeploy the bundle to apply the new permissions.\n" + @@ -42,7 +42,7 @@ func TestPermissionsReportPermissionDeniedWithoutPermission(t *testing.T) { }) diags := permissions.ReportPossiblePermissionDenied(context.Background(), b, "testpath") - expected := "EPERM1: unable to deploy to testpath as testuser@databricks.com.\n" + + expected := "EPERM1: unable to deploy to testpath as Test User.\n" + "Please make sure the current user or one of their groups is listed under the permissions of this bundle.\n" + "For assistance, contact the owners of this project.\n" + "They may need to redeploy the bundle to apply the new permissions.\n" + @@ -54,7 +54,7 @@ func TestPermissionsReportPermissionDeniedNilPermission(t *testing.T) { b := mockBundle(nil) diags := permissions.ReportPossiblePermissionDenied(context.Background(), b, "testpath") - expected := "EPERM1: unable to deploy to testpath as testuser@databricks.com.\n" + + expected := "EPERM1: unable to deploy to testpath as Test User.\n" + "Please make sure the current user or one of their groups is listed under the permissions of this bundle.\n" + "For assistance, contact the owners of this project.\n" + "They may need to redeploy the bundle to apply the new permissions.\n" + @@ -69,7 +69,7 @@ func TestPermissionsReportFindOtherOwners(t *testing.T) { }) diags := permissions.ReportPossiblePermissionDenied(context.Background(), b, "testpath") - require.ErrorContains(t, diags.Error(), "EPERM3: unable to deploy to testpath as testuser@databricks.com. Cannot apply local deployment permissions.\n"+ + require.ErrorContains(t, diags.Error(), "EPERM3: unable to deploy to testpath as Test User. Cannot apply local deployment permissions.\n"+ "For assistance, users or groups with appropriate permissions may include: alice@databricks.com.\n"+ "They can redeploy the project to apply the latest set of permissions.\n"+ "Please refer to https://docs.databricks.com/dev-tools/bundles/permissions.html for more on managing permissions.")