use of org.apache.hadoop.ozone.om.TenantOp in project ozone by apache.
the class TestS3GetSecretRequest method setUp.
@Before
public void setUp() throws Exception {
KerberosName.setRuleMechanism(DEFAULT_MECHANISM);
KerberosName.setRules("RULE:[2:$1@$0](.*@EXAMPLE.COM)s/@.*//\n" + "RULE:[1:$1@$0](.*@EXAMPLE.COM)s/@.*//\n" + "DEFAULT");
ugiAlice = UserGroupInformation.createRemoteUser(USER_ALICE);
Assert.assertEquals("alice", ugiAlice.getShortUserName());
ozoneManager = mock(OzoneManager.class);
Call call = spy(new Call(1, 1, null, null, RPC.RpcKind.RPC_BUILTIN, new byte[] { 1, 2, 3 }));
// Run as alice, so that Server.getRemoteUser() won't return null.
when(call.getRemoteUser()).thenReturn(ugiAlice);
Server.getCurCall().set(call);
omMetrics = OMMetrics.create();
OzoneConfiguration conf = new OzoneConfiguration();
conf.set(OMConfigKeys.OZONE_OM_DB_DIRS, folder.newFolder().getAbsolutePath());
// No need to conf.set(OzoneConfigKeys.OZONE_ADMINISTRATORS, ...) here
// as we did the trick earlier with mockito.
omMetadataManager = new OmMetadataManagerImpl(conf);
when(ozoneManager.getMetrics()).thenReturn(omMetrics);
when(ozoneManager.getMetadataManager()).thenReturn(omMetadataManager);
when(ozoneManager.isRatisEnabled()).thenReturn(true);
auditLogger = mock(AuditLogger.class);
when(ozoneManager.getAuditLogger()).thenReturn(auditLogger);
doNothing().when(auditLogger).logWrite(any(AuditMessage.class));
// Multi-tenant related initializations
omMultiTenantManager = mock(OMMultiTenantManager.class);
tenant = mock(Tenant.class);
when(ozoneManager.getMultiTenantManager()).thenReturn(omMultiTenantManager);
when(tenant.getTenantAccessPolicies()).thenReturn(new ArrayList<>());
when(omMultiTenantManager.getAuthorizerLock()).thenReturn(new AuthorizerLockImpl());
TenantOp authorizerOp = mock(TenantOp.class);
TenantOp cacheOp = mock(TenantOp.class);
when(omMultiTenantManager.getAuthorizerOp()).thenReturn(authorizerOp);
when(omMultiTenantManager.getCacheOp()).thenReturn(cacheOp);
}
Aggregations