@Test(groups = {LDAP, LDAP_CLI, PROFILE_SPECIFIC_TESTS}, timeOut = TIMEOUT) public void shouldFailQueryForLdapUserInChildGroup() throws IOException { ldapUserName = CHILD_GROUP_USER.getAttributes().get("cn"); launchPrestoCliWithServerArgument("--catalog", "hive", "--schema", "default", "--execute", "select * from nation;"); assertThat(trimLines(presto.readRemainingErrorLines())).anySatisfy(line -> assertThat(line).contains(format("User [%s] not a member of the authorized group", ldapUserName))); }
@Test(groups = {LDAP, LDAP_CLI, PROFILE_SPECIFIC_TESTS}, timeOut = TIMEOUT) public void shouldFailQueryForWrongLdapPassword() throws IOException { ldapUserPassword = "wrong_password"; launchPrestoCliWithServerArgument("--execute", "select * from hive.default.nation;"); assertThat(trimLines(presto.readRemainingErrorLines())).anySatisfy(line -> assertThat(line).contains("Invalid credentials")); }
@Test(groups = {LDAP, LDAP_CLI, PROFILE_SPECIFIC_TESTS}, timeOut = TIMEOUT) public void shouldFailQueryForWrongLdapUser() throws IOException { ldapUserName = "invalid_user"; launchPrestoCliWithServerArgument("--execute", "select * from hive.default.nation;"); assertThat(trimLines(presto.readRemainingErrorLines())).anySatisfy(line -> assertThat(line).contains("Invalid credentials")); }
@Test(groups = {LDAP, LDAP_CLI, PROFILE_SPECIFIC_TESTS}, timeOut = TIMEOUT) public void shouldFailQueryForLdapWithoutPassword() throws IOException { launchPrestoCli("--server", ldapServerAddress, "--truststore-path", ldapTruststorePath, "--truststore-password", ldapTruststorePassword, "--user", ldapUserName, "--execute", "select * from hive.default.nation;"); assertThat(trimLines(presto.readRemainingErrorLines())).anySatisfy(line -> assertThat(line).contains("Authentication failed: Unauthorized")); }
@Test(groups = {LDAP, LDAP_CLI, PROFILE_SPECIFIC_TESTS}, timeOut = TIMEOUT) public void shouldFailQueryForEmptyUser() throws IOException { ldapUserName = ""; launchPrestoCliWithServerArgument("--execute", "select * from hive.default.nation;"); assertThat(trimLines(presto.readRemainingErrorLines())).anySatisfy(line -> assertThat(line).contains("Malformed decoded credentials")); }
@Test(groups = {LDAP, LDAP_CLI, PROFILE_SPECIFIC_TESTS}, timeOut = TIMEOUT) public void shouldFailQueryForLdapUserInParentGroup() throws IOException { ldapUserName = PARENT_GROUP_USER.getAttributes().get("cn"); launchPrestoCliWithServerArgument("--catalog", "hive", "--schema", "default", "--execute", "select * from nation;"); assertThat(trimLines(presto.readRemainingErrorLines())).anySatisfy(line -> assertThat(line).contains(format("User [%s] not a member of the authorized group", ldapUserName))); }
@Test(groups = {LDAP, LDAP_CLI, PROFILE_SPECIFIC_TESTS}, timeOut = TIMEOUT) public void shouldFailQueryForOrphanLdapUser() throws IOException { ldapUserName = ORPHAN_USER.getAttributes().get("cn"); launchPrestoCliWithServerArgument("--catalog", "hive", "--schema", "default", "--execute", "select * from nation;"); assertThat(trimLines(presto.readRemainingErrorLines())).anySatisfy(line -> assertThat(line).contains(format("User [%s] not a member of the authorized group", ldapUserName))); }
@Test(groups = {LDAP, LDAP_CLI, PROFILE_SPECIFIC_TESTS}, timeOut = TIMEOUT) public void shouldFailForIncorrectTrustStore() throws IOException { ldapTruststorePassword = "wrong_password"; launchPrestoCliWithServerArgument("--execute", "select * from hive.default.nation;"); assertThat(trimLines(presto.readRemainingErrorLines())).anySatisfy(line -> assertThat(line).contains("Keystore was tampered with, or password was incorrect")); skipAfterTestWithContext(); }
@Test(groups = {LDAP, LDAP_CLI, PROFILE_SPECIFIC_TESTS}, timeOut = TIMEOUT) public void shouldFailQueryForLdapWithoutHttps() throws IOException { ldapServerAddress = format("http://%s:8443", serverHost); launchPrestoCliWithServerArgument("--execute", "select * from hive.default.nation;"); assertThat(trimLines(presto.readRemainingErrorLines())).anySatisfy(line -> assertThat(line).contains("Authentication using username/password requires HTTPS to be enabled")); skipAfterTestWithContext(); }
@Test(groups = {LDAP, LDAP_CLI, PROFILE_SPECIFIC_TESTS}, timeOut = TIMEOUT) public void shouldFailForUserWithColon() throws IOException { ldapUserName = "UserWith:Colon"; launchPrestoCliWithServerArgument("--execute", "select * from hive.default.nation;"); assertThat(trimLines(presto.readRemainingErrorLines())).anySatisfy(line -> assertThat(line).contains("Illegal character ':' found in username")); skipAfterTestWithContext(); }
public void sometimesFails() { log.warn("This is a warning."); log.info("This is purely informational."); List<LoggingEvent> logs = (List<LoggingEvent>) TestNGLogCollector.getRawLogs(); assertThat(logs) .hasSize(2) .anySatisfy(e -> assertThat(e.getLevel()).isEqualTo(Level.WARN)) .anySatisfy(e -> assertThat(e.getLevel()).isEqualTo(Level.INFO)); invocationCount++; if (invocationCount > 8) { Assert.fail(); } } }
@Test public void processorShouldWorkOnValidRights() throws Exception { GetQuotaRootRequest getQuotaRootRequest = new GetQuotaRootRequest("A004", ImapCommand.anyStateCommand("Name"), "INBOX"); when(mockedImapSession.getState()).thenReturn(ImapSessionState.AUTHENTICATED); when(mockedImapSession.getAttribute(ImapSessionUtils.MAILBOX_SESSION_ATTRIBUTE_SESSION_KEY)).thenReturn(mailboxSession); when(mockedQuotaRootResolver.getQuotaRoot(MAILBOX_PATH)).thenReturn(QUOTA_ROOT); when(mockedMailboxManager.hasRight(MAILBOX_PATH, MailboxACL.Right.Read, mailboxSession)).thenReturn(true); when(mockedQuotaManager.getMessageQuota(QUOTA_ROOT)).thenReturn(MESSAGE_QUOTA); when(mockedQuotaManager.getStorageQuota(QUOTA_ROOT)).thenReturn(STORAGE_QUOTA); final QuotaResponse storageQuotaResponse = new QuotaResponse("STORAGE", "plop", STORAGE_QUOTA); final QuotaResponse messageQuotaResponse = new QuotaResponse("MESSAGE", "plop", MESSAGE_QUOTA); final QuotaRootResponse quotaRootResponse = new QuotaRootResponse("INBOX", "plop"); testee.doProcess(getQuotaRootRequest, mockedResponder, mockedImapSession); verify(mockedMailboxManager, times(1)).startProcessingRequest(mailboxSession); verify(mockedMailboxManager, times(1)).endProcessingRequest(mailboxSession); ArgumentCaptor<ImapResponseMessage> responseCaptor = ArgumentCaptor.forClass(ImapResponseMessage.class); verify(mockedResponder, times(4)).respond(responseCaptor.capture()); List<ImapResponseMessage> captorValues = responseCaptor.getAllValues(); assertThat(captorValues).contains(quotaRootResponse, storageQuotaResponse, messageQuotaResponse); assertThat(captorValues).anySatisfy(response -> assertThat(response).isInstanceOfSatisfying( StatusResponse.class, st -> assertThat(st.getServerResponseType()).isEqualTo(OK))); }