Skip to content

Commit

Permalink
JAMES-1618 Remove non RFC-5804 compliant GETACTIVE command
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/james/project/trunk@1720593 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
chibenwa committed Dec 17, 2015
1 parent d2379a0 commit eae6a04
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 103 deletions.
Expand Up @@ -28,7 +28,7 @@
* @see <a href=http://tools.ietf.org/html/rfc5804#section-2>RFC 5804 Commands</a>
*/
public interface CoreCommands extends Capability, CheckScript, DeleteScript, GetScript, HaveSpace,
ListScripts, PutScript, RenameScript, SetActive, GetActive, Noop, Unauthenticate, Logout, Authenticate, StartTLS,
ListScripts, PutScript, RenameScript, SetActive, Noop, Unauthenticate, Logout, Authenticate, StartTLS,
CapabilityAdvertiser {

}

This file was deleted.

Expand Up @@ -269,24 +269,6 @@ public String setActive(Session session, String name) {
return "OK";
}

@Override
public String getActive(Session session) {
try {
authenticationCheck(session);
return IOUtils.toString(sieveRepository.getActive(session.getUser())) + "\r\nOK";
} catch (AuthenticationRequiredException ex) {
return "NO";
} catch (ScriptNotFoundException ex) {
return "NO (NONEXISTENT) \"" + ex.getMessage() + "\"";
} catch (StorageException ex) {
return "NO \"" + ex.getMessage() + "\"";
} catch (UserNotFoundException e) {
return "NO : User not found";
} catch (IOException e) {
return "NO \"" + e.getMessage() + "\"";
}
}

@Override
public String noop(String tag) {
if(Strings.isNullOrEmpty(tag)) {
Expand Down
Expand Up @@ -92,8 +92,6 @@ private String matchCommandWithImplementation(Session session, String arguments,
return argumentParser.checkScript(session, arguments);
} else if (command.equals(DELETESCRIPT)) {
return argumentParser.deleteScript(session, arguments);
} else if (command.equals(GETACTIVE)) {
return argumentParser.getActive(session, arguments);
} else if (command.equals(GETSCRIPT)) {
return argumentParser.getScript(session, arguments);
} else if (command.equals(HAVESPACE)) {
Expand Down
Expand Up @@ -459,50 +459,6 @@ public final void testSetActiveNoScriptName() throws Exception {
ensureResponse("Re: SETACTIVE", "NO \"Missing argument: script name\"");
}

@Test
public final void testGetActiveUnauthorized() throws Exception {
MimeMessage message = prepareMimeMessage("GETACTIVE", USER, SIEVE_LOCALHOST);
Mail mail = new FakeMail();
mail.setMessage(message);
mailet.service(mail);
ensureResponse("Re: GETACTIVE", message.getSender(), "NO");
}

@Test
public final void testGetActive() throws Exception {
when(sieveRepository.getActive(USER)).thenAnswer(new Answer<String>() {
public String answer(InvocationOnMock invocationOnMock) throws Throwable {
return SCRIPT_CONTENT;
}
});
MimeMessage message = prepareMimeMessage("GETACTIVE", USER, SIEVE_LOCALHOST);
Mail mail = new FakeMail();
mail.setMessage(message);
mail.setAttribute(ManageSieveMailet.SMTP_AUTH_USER_ATTRIBUTE_NAME, USER);
mailet.service(mail);
ensureResponse("Re: GETACTIVE", message.getSender(), SCRIPT_CONTENT + "\r\n" + "OK");
}

@Test
public final void testGetActiveExtraArgs() throws Exception {
MimeMessage message = prepareMimeMessage("GETACTIVE extra", USER, SIEVE_LOCALHOST);
Mail mail = new FakeMail();
mail.setMessage(message);
message.setSubject("GETACTIVE extra");
message.saveChanges();
mailet.service(mail);
ensureResponse("Re: GETACTIVE extra", message.getSender(), "NO \"Too many arguments: extra\"");
}

@Test
public final void testGetActiveDesactivated() throws Exception {
MimeMessage message = prepareMimeMessage("GETACTIVE", USER, SIEVE_LOCALHOST);
Mail mail = new FakeMail();
mail.setMessage(message);
mailet.service(mail);
ensureResponse("Re: GETACTIVE", message.getSender(), "NO");
}

private void initializeMailet() throws MessagingException {
mailet = new ManageSieveMailet();
mailet.setSieveParser(sieveParser);
Expand Down

0 comments on commit eae6a04

Please sign in to comment.