mirror of https://github.com/databricks/cli.git
add integration test for grant on volume
This commit is contained in:
parent
3e3ddfd0cb
commit
d241c2b39c
|
@ -24,3 +24,8 @@ resources:
|
||||||
schema_name: ${var.schema_name}
|
schema_name: ${var.schema_name}
|
||||||
volume_type: MANAGED
|
volume_type: MANAGED
|
||||||
comment: This volume was created from DABs.
|
comment: This volume was created from DABs.
|
||||||
|
|
||||||
|
grants:
|
||||||
|
- principal: account users
|
||||||
|
privileges:
|
||||||
|
- WRITE_VOLUME
|
||||||
|
|
|
@ -265,12 +265,20 @@ func TestAccDeployUcVolume(t *testing.T) {
|
||||||
catalogName := "main"
|
catalogName := "main"
|
||||||
schemaName := "schema1-" + uniqueId
|
schemaName := "schema1-" + uniqueId
|
||||||
volumeName := "my_volume"
|
volumeName := "my_volume"
|
||||||
volume, err := w.Volumes.ReadByName(ctx, fmt.Sprintf("%s.%s.%s", catalogName, schemaName, volumeName))
|
fullName := fmt.Sprintf("%s.%s.%s", catalogName, schemaName, volumeName)
|
||||||
|
volume, err := w.Volumes.ReadByName(ctx, fullName)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, volume.Name, volumeName)
|
require.Equal(t, volume.Name, volumeName)
|
||||||
require.Equal(t, catalogName, volume.CatalogName)
|
require.Equal(t, catalogName, volume.CatalogName)
|
||||||
require.Equal(t, schemaName, volume.SchemaName)
|
require.Equal(t, schemaName, volume.SchemaName)
|
||||||
|
|
||||||
|
// Assert that the grants were successfully applied.
|
||||||
|
grants, err := w.Grants.GetBySecurableTypeAndFullName(ctx, catalog.SecurableTypeVolume, fullName)
|
||||||
|
require.NoError(t, err)
|
||||||
|
assert.Len(t, grants.PrivilegeAssignments, 1)
|
||||||
|
assert.Equal(t, "account users", grants.PrivilegeAssignments[0].Principal)
|
||||||
|
assert.Equal(t, []catalog.Privilege{catalog.PrivilegeWriteVolume}, grants.PrivilegeAssignments[0].Privileges)
|
||||||
|
|
||||||
// Recreation of the volume without --auto-approve should fail since prompting is not possible
|
// Recreation of the volume without --auto-approve should fail since prompting is not possible
|
||||||
t.Setenv("TERM", "dumb")
|
t.Setenv("TERM", "dumb")
|
||||||
t.Setenv("BUNDLE_ROOT", bundleRoot)
|
t.Setenv("BUNDLE_ROOT", bundleRoot)
|
||||||
|
@ -290,9 +298,17 @@ volumes the upstream data in the cloud tenant is not affected:
|
||||||
|
|
||||||
// Assert the volume is updated successfully
|
// Assert the volume is updated successfully
|
||||||
schemaName = "schema2-" + uniqueId
|
schemaName = "schema2-" + uniqueId
|
||||||
volume, err = w.Volumes.ReadByName(ctx, fmt.Sprintf("%s.%s.%s", catalogName, schemaName, volumeName))
|
fullName = fmt.Sprintf("%s.%s.%s", catalogName, schemaName, volumeName)
|
||||||
|
volume, err = w.Volumes.ReadByName(ctx, fullName)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, volume.Name, volumeName)
|
require.Equal(t, volume.Name, volumeName)
|
||||||
require.Equal(t, catalogName, volume.CatalogName)
|
require.Equal(t, catalogName, volume.CatalogName)
|
||||||
require.Equal(t, schemaName, volume.SchemaName)
|
require.Equal(t, schemaName, volume.SchemaName)
|
||||||
|
|
||||||
|
// assert that the grants were applied / retained on recreate.
|
||||||
|
grants, err = w.Grants.GetBySecurableTypeAndFullName(ctx, catalog.SecurableTypeVolume, fullName)
|
||||||
|
require.NoError(t, err)
|
||||||
|
assert.Len(t, grants.PrivilegeAssignments, 1)
|
||||||
|
assert.Equal(t, "account users", grants.PrivilegeAssignments[0].Principal)
|
||||||
|
assert.Equal(t, []catalog.Privilege{catalog.PrivilegeWriteVolume}, grants.PrivilegeAssignments[0].Privileges)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue