Skip to content

Commit 2387ebe

Browse files
committed
refactor: add more errors and reset authentication state on authentication error
While trying to get the MPT tests for managesieve running, I realized that a client is trapped in the state "AuthenticationInProgress" when using continuation. This made longer test scripts impossible. To consistently reset the session, I introduced more errors that are handled in one place instead of returning a "NO" answer directly during authentication. Those changes also required some small changes to the MPT and the normal tests. Additionally, there were a parsing bug when sending space-separated username and password in the authentication continuation which is fixed now.
1 parent 63932d6 commit 2387ebe

File tree

21 files changed

+137
-108
lines changed

21 files changed

+137
-108
lines changed

mpt/impl/managesieve/core/src/main/resources/org/apache/james/managesieve/scripts/authenticate.test

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,25 @@
1818
################################################################
1919

2020
C: AUTHENTICATE
21-
S: NO ManageSieve syntax is incorrect : You must specify a SASL mechanism as an argument of AUTHENTICATE command
21+
S: NO "ManageSieve syntax is incorrect: quoted SASL mechanism must be supplied"
2222

2323
C: AUTHENTICATE "UNKNOWN"
24-
S: NO Unknown SASL mechanism UNKNOWN
24+
S: NO "Unknown SASL mechanism UNKNOWN"
2525

2626
C: AUTHENTICATE "PLAIN"
27-
S: \+ ""
27+
S: ""
28+
S: OK
2829
C: GETSCRIPT toto.sieve
29-
S: NO ManageSieve syntax is incorrect : You must supply a password for the authentication mechanism. Formal syntax : <NULL>username<NULL>password
30+
S: NO "ManageSieve syntax is incorrect: quoted authentication data must be supplied"
3031

31-
C: tin password
32-
S: NO authentication failed
32+
C: AUTHENTICATE "PLAIN"
33+
S: ""
34+
S: OK
35+
C: "tin password"
36+
S: NO "Authentication failed with: Verification of credentials failed"
3337

3438
C: AUTHENTICATE "PLAIN"
35-
S: \+ ""
36-
C: user password
37-
S: OK
39+
S: ""
40+
S: OK
41+
C: "user password"
42+
S: OK

mpt/impl/managesieve/core/src/main/resources/org/apache/james/managesieve/scripts/authenticateBase64.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818
################################################################
1919

2020
C: AUTHENTICATE "PLAIN" "AHVzZXIAcGFzc3dvcmQ="
21-
S: OK
21+
S: OK

mpt/impl/managesieve/core/src/main/resources/org/apache/james/managesieve/scripts/capability.test

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ S: "VERSION" "1.0"
3838
S: OK
3939

4040
C: AUTHENTICATE "PLAIN"
41-
S: \+ ""
42-
C: user password
41+
S: ""
42+
S: OK
43+
C: "user password"
4344
S: OK
4445

4546
C: CAPABILITY
@@ -51,4 +52,4 @@ S: "STARTTLS"
5152
S: "IMPLEMENTATION" "Apache ManageSieve v1.0"
5253
S: "VERSION" "1.0"
5354
}
54-
S: OK
55+
S: OK

mpt/impl/managesieve/core/src/main/resources/org/apache/james/managesieve/scripts/checkscript.test

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ C:
3434
S: NO
3535

3636
C: AUTHENTICATE "PLAIN"
37-
S: \+ ""
38-
C: user password
37+
S: ""
38+
S: OK
39+
C: "user password"
3940
S: OK
4041

4142
C: CHECKSCRIPT {99+}
@@ -51,4 +52,3 @@ C: #comment
5152
C: InvalidSieveCommand
5253
C:
5354
S: NO "Syntax Error: org.apache.jsieve.parser.generated.ParseException: Encountered "<EOF>" at line 2, column 21.
54-

mpt/impl/managesieve/core/src/main/resources/org/apache/james/managesieve/scripts/deletescript.test

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ C: DELETESCRIPT "foo"
2424
S: NO
2525

2626
C: AUTHENTICATE "PLAIN"
27-
S: \+ ""
28-
C: user password
27+
S: ""
28+
S: OK
29+
C: "user password"
2930
S: OK
3031

3132
C: DELETESCRIPT "foo"
@@ -77,4 +78,4 @@ C: SETACTIVE "mysievescript"
7778
S: OK
7879

7980
C: DELETESCRIPT "mysievescript"
80-
S: NO \(ACTIVE\) "You may not delete an active script"
81+
S: NO \(ACTIVE\) "You may not delete an active script"

mpt/impl/managesieve/core/src/main/resources/org/apache/james/managesieve/scripts/getscript.test

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ C: GETSCRIPT "foo"
2424
S: NO
2525

2626
C: AUTHENTICATE "PLAIN"
27-
S: \+ ""
28-
C: user password
27+
S: ""
28+
S: OK
29+
C: "user password"
2930
S: OK
3031

3132
C: GETSCRIPT "foo"
@@ -48,5 +49,3 @@ S: fileinto "INBOX.sent";
4849
S: \}
4950
S:
5051
S: OK
51-
52-

mpt/impl/managesieve/core/src/main/resources/org/apache/james/managesieve/scripts/havespace.test

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,13 @@ C: HAVESPACE "scriptname" 49
2727
S: NO
2828

2929
C: AUTHENTICATE "PLAIN"
30-
S: \+ ""
31-
C: user password
30+
S: ""
31+
S: OK
32+
C: "user password"
3233
S: OK
3334

3435
C: HAVESPACE "scriptname" 49
3536
S: OK
3637

3738
C: HAVESPACE "scriptname" 51
38-
S: NO \(QUOTA/MAXSIZE\) "Quota exceeded"
39+
S: NO \(QUOTA/MAXSIZE\) "Quota exceeded"

mpt/impl/managesieve/core/src/main/resources/org/apache/james/managesieve/scripts/listscripts.test

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ C: LISTSCRIPTS
2121
S: NO
2222

2323
C: AUTHENTICATE "PLAIN"
24-
S: \+ ""
25-
C: user password
24+
S: ""
25+
S: OK
26+
C: "user password"
2627
S: OK
2728

2829
C: LISTSCRIPTS

mpt/impl/managesieve/core/src/main/resources/org/apache/james/managesieve/scripts/logout.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818
################################################################
1919

2020
C: LOGOUT
21-
S: OK channel is closing
21+
S: OK channel is closing

mpt/impl/managesieve/core/src/main/resources/org/apache/james/managesieve/scripts/noop.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ S: OK \(TAG \{16\}
2525
S: STARTTLS-SYNC-42\) "DONE"
2626

2727
C: NooP
28-
S: OK "NOOP completed"
28+
S: OK "NOOP completed"

0 commit comments

Comments
 (0)