Repository navigation
Add an access control test to verify that user can't claim staging table created by other users. - #1138
Conversation
6d3004b to
eff7c18
Compare
3263ae4 to
1a9a21a
Compare
9b9c090 to
15598c6
Compare
| * <li>Automatic cleanup of created users and granted permissions | ||
| * </ul> | ||
| */ | ||
| public abstract class SdkAccessControlBaseCRUDTest extends BaseAccessControlCRUDTest { |
There was a problem hiding this comment.
Previously the access control tests are only done via CLI. They are based on CliAccessControlBaseCrudTest which uses CLI to setup users and permissions. That won't allow us to do fine grain test between staging table and actual table because CLI can only do a table creation as a whole.
This new base class is just based on SDK and supports the user/permission setup.
| new SdkSchemaOperations(TestUtils.createApiClient(adminConfig)); | ||
|
|
||
| CreateCatalog createCatalog = | ||
| new CreateCatalog().name(TestUtils.CATALOG_NAME).comment(TestUtils.COMMENT); |
There was a problem hiding this comment.
The catalog, along with everything under it, is cleaned up by BaseCRUDTest
8b88de6 to
47d3157
Compare
e5473cd to
1bce207
Compare
1bce207 to
3b7be70
Compare
| // Server and control models are added as provided to avoid them being added as maven dependencies | ||
| // This is because the server and control models are included in the server jar | ||
| .dependsOn(serverModels % "provided", controlModels % "provided") | ||
| .dependsOn(controlApi % "test->compile") |
There was a problem hiding this comment.
why is this needed? which class?
There was a problem hiding this comment.
The access control test base class SdkAccessControlBaseCRUDTest.java needs the following imports in order to create test users:
io.unitycatalog.control.api.UsersApi;
io.unitycatalog.control.ApiClient
io.unitycatalog.control.ApiException
…ble created by other users. Signed-off-by: Yi Li <[email protected]>
3b7be70 to
003b10d
Compare
Signed-off-by: Yi Li <[email protected]>
Signed-off-by: Yi Li <[email protected]>
| * functionality for SDK-based access control tests, including user management, permission | ||
| * management, and resource setup. | ||
| */ | ||
| public class SdkStagingTableAccessControlCRUDTest extends SdkAccessControlBaseCRUDTest { |
There was a problem hiding this comment.
technically this test is not testing CRUD (create, read, update, delete) as staging table cannot be updated or deleted.
| private final List<PermissionGrant> grantedPermissions = new ArrayList<>(); | ||
|
|
||
| /** Helper class to track granted permissions for cleanup. */ | ||
| private record PermissionGrant( |
There was a problem hiding this comment.
Seems like it's JDK 16+ language syntax , right ?
There was a problem hiding this comment.
I just checked. It's from Java 14. We are using Java 17. So it should be fine?
|
|
||
| @Override | ||
| protected CatalogOperations createCatalogOperations(ServerConfig config) { | ||
| return new SdkCatalogOperations(TestUtils.createApiClient(config)); |
There was a problem hiding this comment.
Could you please file an issue to track that we need to reuse the ApiClient construction that we've already used in ApiClientFactory . Also @timothyw553 is helping to build the retry policy for it.
| * @param config Server configuration including URL and auth token | ||
| * @return A TableOperations instance | ||
| */ | ||
| protected TableOperations createTableOperations(ServerConfig config) { |
There was a problem hiding this comment.
nit: no usage for this method, could you please remove it ?
| java.net.URI uri = java.net.URI.create(config.getServerUrl()); | ||
| int port = uri.getPort(); | ||
| controlApiClient.setHost(uri.getHost()); | ||
| controlApiClient.setPort(port); | ||
| controlApiClient.setScheme(uri.getScheme()); | ||
| if (config.getAuthToken() != null && !config.getAuthToken().isEmpty()) { | ||
| controlApiClient.setRequestInterceptor( | ||
| request -> request.header("Authorization", "Bearer " + config.getAuthToken())); | ||
| } |
There was a problem hiding this comment.
I've seen lots of places are trying to constrcut the api client by themselves. Actually we need to unify them into one place, because:
- Retry policy.
- need to care about this issue: Allow providing base path for UC API Client #1130
There was a problem hiding this comment.
This is the control api client. It looks similar to io.unitycatalog.client.ApiClient but it's actually a different class generated by openapi with no common base class.
Signed-off-by: Yi Li <[email protected]>
…ble created by other users. (unitycatalog#1138) ## 🥞 Stacked PR Use this [link](https://github.com/unitycatalog/unitycatalog/pull/1138/files) to review incremental changes. - [**staging_table_access_test**](unitycatalog#1138) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/1138/files)] --------- **PR Checklist** - [x] A description of the changes is added to the description of this PR. - [x] If there is a related issue, make sure it is linked to this PR. - [ ] If you've fixed a bug or added code that should be tested, add tests! - [ ] If you've added or modified a feature, documentation in `docs` is updated Add an access control test to verify that user can't claim staging table created by other users. <!-- Please state what you've changed and how it might affect the users. --> Related issue is: unitycatalog#1143 --------- Signed-off-by: Yi Li <[email protected]>
🥞 Stacked PR
Use this link to review incremental changes.
PR Checklist
docsis updatedAdd an access control test to verify that user can't claim staging table created by other users.
Related issue is: #1143