Skip to content

Commit 9529726

Browse files
committed
Add permission tests for get and scan with index
1 parent 7ecb75a commit 9529726

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

integration-test/src/main/java/com/scalar/db/api/DistributedStoragePermissionIntegrationTestBase.java

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public abstract class DistributedStoragePermissionIntegrationTestBase {
3333
private static final String COL_NAME1 = "c1";
3434
private static final String COL_NAME2 = "c2";
3535
private static final String COL_NAME3 = "c3";
36+
private static final String COL_NAME4 = "c4";
3637
private static final int PARTITION_KEY_VALUE = 1;
3738
private static final String CLUSTERING_KEY_VALUE1 = "value1";
3839
private static final String CLUSTERING_KEY_VALUE2 = "value2";
@@ -115,6 +116,19 @@ public void get_WithSufficientPermission_ShouldSucceed() {
115116
assertThatCode(() -> storageForNormalUser.get(get)).doesNotThrowAnyException();
116117
}
117118

119+
@Test
120+
public void get_WithIndexKey_WithSufficientPermission_ShouldSucceed() {
121+
// Arrange
122+
Get get =
123+
Get.newBuilder()
124+
.namespace(namespace)
125+
.table(TABLE)
126+
.indexKey(Key.ofInt("c3", INT_COLUMN_VALUE1))
127+
.build();
128+
// Act Assert
129+
assertThatCode(() -> storageForNormalUser.get(get)).doesNotThrowAnyException();
130+
}
131+
118132
@Test
119133
public void scan_WithSufficientPermission_ShouldSucceed() {
120134
// Arrange
@@ -128,6 +142,19 @@ public void scan_WithSufficientPermission_ShouldSucceed() {
128142
assertThatCode(() -> storageForNormalUser.scan(scan).close()).doesNotThrowAnyException();
129143
}
130144

145+
@Test
146+
public void scan_WithIndexKey_WithSufficientPermission_ShouldSucceed() {
147+
// Arrange
148+
Scan scan =
149+
Scan.newBuilder()
150+
.namespace(namespace)
151+
.table(TABLE)
152+
.indexKey(Key.ofInt("c3", INT_COLUMN_VALUE1))
153+
.build();
154+
// Act Assert
155+
assertThatCode(() -> storageForNormalUser.scan(scan).close()).doesNotThrowAnyException();
156+
}
157+
131158
@Test
132159
public void scanAll_WithSufficientPermission_ShouldSucceed() {
133160
// Arrange
@@ -278,8 +305,10 @@ private void createTable() throws ExecutionException {
278305
.addColumn(COL_NAME1, DataType.INT)
279306
.addColumn(COL_NAME2, DataType.TEXT)
280307
.addColumn(COL_NAME3, DataType.INT)
308+
.addColumn(COL_NAME4, DataType.INT)
281309
.addPartitionKey(COL_NAME1)
282310
.addClusteringKey(COL_NAME2)
311+
.addSecondaryIndex(COL_NAME3)
283312
.build(),
284313
true,
285314
options);
@@ -303,7 +332,8 @@ private Put createPut(String clusteringKey, int intColumnValue, MutationConditio
303332
Key.ofInt(
304333
COL_NAME1, DistributedStoragePermissionIntegrationTestBase.PARTITION_KEY_VALUE))
305334
.clusteringKey(Key.ofText(COL_NAME2, clusteringKey))
306-
.intValue(COL_NAME3, intColumnValue);
335+
.intValue(COL_NAME3, intColumnValue)
336+
.intValue(COL_NAME4, intColumnValue);
307337
if (condition != null) {
308338
buildable.condition(condition);
309339
}

0 commit comments

Comments
 (0)