@Test @LocalTachyonClusterResource.Config( tachyonConfParams = { Constants.SECURITY_AUTHENTICATION_TYPE, "CUSTOM", Constants.SECURITY_AUTHENTICATION_CUSTOM_PROVIDER, NameMatchAuthenticationProvider.FULL_CLASS_NAME, Constants.SECURITY_LOGIN_USERNAME, "tachyon" }) public void customAuthenticationDenyConnectTest() throws Exception { mThrown.expect(ConnectionFailedException.class); FileSystemMasterClient masterClient = new FileSystemMasterClient( mLocalTachyonClusterResource.get().getMaster().getAddress(), ClientContext.getConf()); try { Assert.assertFalse(masterClient.isConnected()); // Using no-tachyon as loginUser to connect to Master, the IOException will be thrown LoginUserTestUtils.resetLoginUser(ClientContext.getConf(), "no-tachyon"); masterClient.connect(); } finally { masterClient.close(); } }
@Test @LocalTachyonClusterResource.Config( tachyonConfParams = { Constants.SECURITY_AUTHENTICATION_TYPE, "CUSTOM", Constants.SECURITY_AUTHENTICATION_CUSTOM_PROVIDER, NameMatchAuthenticationProvider.FULL_CLASS_NAME }, startCluster = false) public void customAuthenticationDenyConnectTest() throws Exception { /** * Using tachyon as loginUser for unit testing, only tachyon user is allowed to connect to * Tachyon Master. */ System.setProperty(Constants.SECURITY_LOGIN_USERNAME, "tachyon"); mLocalTachyonClusterResource.start(); // Using no-tachyon as loginUser to connect to Master, the IOException will be thrown clearLoginUser(); mThrown.expect(ConnectionFailedException.class); System.setProperty(Constants.SECURITY_LOGIN_USERNAME, "no-tachyon"); FileSystemMasterClient masterClient = new FileSystemMasterClient( mLocalTachyonClusterResource.get().getMaster().getAddress(), mLocalTachyonClusterResource.get().getMasterTachyonConf()); try { Assert.assertFalse(masterClient.isConnected()); masterClient.connect(); } finally { masterClient.close(); } }
/** * Test Tachyon client connects or disconnects to the Master. When the client connects * successfully to the Master, it can successfully create file or not. * * @param filename * @throws Exception */ private void authenticationOperationTest(String filename) throws Exception { FileSystemMasterClient masterClient = new FileSystemMasterClient( mLocalTachyonClusterResource.get().getMaster().getAddress(), mLocalTachyonClusterResource.get().getMasterTachyonConf()); Assert.assertFalse(masterClient.isConnected()); masterClient.connect(); Assert.assertTrue(masterClient.isConnected()); masterClient.createFile(new TachyonURI(filename), CreateFileOptions.defaults()); Assert.assertNotNull(masterClient.getStatus(new TachyonURI(filename))); masterClient.disconnect(); masterClient.close(); }