@@ -2074,16 +2074,16 @@ public Object run() throws Exception {
20742074 USER_GROUP_WRITE , USER_GROUP_CREATE );
20752075
20762076 verifyAllowed (cloneAction , SUPERUSER , USER_ADMIN , USER_GROUP_ADMIN );
2077- verifyDenied (deleteAction , USER_CREATE , USER_RW , USER_RO , USER_NONE , USER_OWNER ,
2078- USER_GROUP_READ , USER_GROUP_WRITE , USER_GROUP_CREATE );
2077+ verifyDenied (cloneAction , USER_CREATE , USER_RW , USER_RO , USER_NONE , USER_OWNER , USER_GROUP_READ ,
2078+ USER_GROUP_WRITE , USER_GROUP_CREATE );
20792079
20802080 verifyAllowed (restoreAction , SUPERUSER , USER_ADMIN , USER_GROUP_ADMIN );
20812081 verifyDenied (restoreAction , USER_CREATE , USER_RW , USER_RO , USER_NONE , USER_OWNER ,
20822082 USER_GROUP_READ , USER_GROUP_WRITE , USER_GROUP_CREATE );
20832083
20842084 verifyAllowed (deleteAction , SUPERUSER , USER_ADMIN , USER_GROUP_ADMIN );
2085- verifyDenied (cloneAction , USER_CREATE , USER_RW , USER_RO , USER_NONE , USER_OWNER , USER_GROUP_READ ,
2086- USER_GROUP_WRITE , USER_GROUP_CREATE );
2085+ verifyDenied (deleteAction , USER_CREATE , USER_RW , USER_RO , USER_NONE , USER_OWNER ,
2086+ USER_GROUP_READ , USER_GROUP_WRITE , USER_GROUP_CREATE );
20872087 }
20882088
20892089 @ Test
@@ -2126,18 +2126,65 @@ public Object run() throws Exception {
21262126 verifyAllowed (restoreAction , SUPERUSER , USER_ADMIN , USER_OWNER , USER_GROUP_ADMIN );
21272127 verifyDenied (restoreAction , USER_CREATE , USER_RW , USER_RO , USER_NONE , USER_GROUP_READ ,
21282128 USER_GROUP_WRITE , USER_GROUP_CREATE );
2129+ }
21292130
2130- AccessTestAction cloneAction = new AccessTestAction () {
2131+ @ Test
2132+ public void testCloneSnapshotWithOwner () throws Exception {
2133+ Admin admin = TEST_UTIL .getAdmin ();
2134+ final TableDescriptor originalTd = admin .getDescriptor (TEST_TABLE );
2135+ final SnapshotDescription snapshot = new SnapshotDescription (
2136+ TEST_TABLE .getNameAsString () + "-snapshot" , TEST_TABLE , null , USER_OWNER .getName ());
2137+ String namespace = "testCloneSnapshot" ;
2138+ NamespaceDescriptor desc = NamespaceDescriptor .create (namespace ).build ();
2139+ createNamespace (TEST_UTIL , desc );
2140+
2141+ String differentTableString = "testtable2" ;
2142+ TableName differentTable = TableName .valueOf (namespace , differentTableString );
2143+ TableDescriptor diffrentTd = TableDescriptorBuilder .newBuilder (differentTable )
2144+ .setColumnFamily (ColumnFamilyDescriptorBuilder .of (TEST_FAMILY )).build ();
2145+
2146+ // recreating the original table
2147+ AccessTestAction cloneOriginalAction = new AccessTestAction () {
21312148 @ Override
21322149 public Object run () throws Exception {
21332150 ACCESS_CONTROLLER .preCloneSnapshot (ObserverContextImpl .createAndPrepare (CP_ENV ), snapshot ,
2134- htd );
2151+ originalTd );
21352152 return null ;
21362153 }
21372154 };
2138- verifyAllowed (cloneAction , SUPERUSER , USER_ADMIN , USER_GROUP_ADMIN , USER_OWNER );
2139- verifyDenied (cloneAction , USER_CREATE , USER_RW , USER_RO , USER_NONE , USER_GROUP_READ ,
2155+ verifyAllowed (cloneOriginalAction , SUPERUSER , USER_ADMIN , USER_GROUP_ADMIN , USER_OWNER );
2156+ verifyDenied (cloneOriginalAction , USER_CREATE , USER_RW , USER_RO , USER_NONE , USER_GROUP_READ ,
21402157 USER_GROUP_WRITE , USER_GROUP_CREATE );
2158+
2159+ // cloning to a different table
2160+ AccessTestAction cloneDifferentAction = new AccessTestAction () {
2161+ @ Override
2162+ public Object run () throws Exception {
2163+ ACCESS_CONTROLLER .preCloneSnapshot (ObserverContextImpl .createAndPrepare (CP_ENV ), snapshot ,
2164+ diffrentTd );
2165+ return null ;
2166+ }
2167+ };
2168+ verifyAllowed (cloneDifferentAction , SUPERUSER , USER_ADMIN , USER_GROUP_ADMIN );
2169+ verifyDenied (cloneDifferentAction , USER_CREATE , USER_RW , USER_RO , USER_NONE , USER_GROUP_READ ,
2170+ USER_GROUP_WRITE , USER_GROUP_CREATE , USER_OWNER );
2171+
2172+ // cloning to a different table where user is namespace admin
2173+ grantOnNamespace (TEST_UTIL , USER_OWNER .getShortName (), namespace , Action .ADMIN );
2174+
2175+ AccessTestAction cloneNamespaceAdminAction = new AccessTestAction () {
2176+ @ Override
2177+ public Object run () throws Exception {
2178+ ACCESS_CONTROLLER .preCloneSnapshot (ObserverContextImpl .createAndPrepare (CP_ENV ), snapshot ,
2179+ diffrentTd );
2180+ return null ;
2181+ }
2182+ };
2183+ verifyAllowed (cloneNamespaceAdminAction , SUPERUSER , USER_ADMIN , USER_GROUP_ADMIN , USER_OWNER );
2184+ verifyDenied (cloneNamespaceAdminAction , USER_CREATE , USER_RW , USER_RO , USER_NONE ,
2185+ USER_GROUP_READ , USER_GROUP_WRITE , USER_GROUP_CREATE );
2186+
2187+ deleteNamespace (TEST_UTIL , namespace );
21412188 }
21422189
21432190 @ Test
0 commit comments