@@ -46,13 +46,12 @@ public void testGoodCredentials() throws Exception {
4646 Assert .assertEquals (PASSWORD , credentials .getPassword ());
4747 }
4848
49- @ Test
50- public void testGoodCredentialsNoPassword () throws Exception {
49+ @ Test ( expected = IllegalArgumentException . class )
50+ public void testBadCredentialsNoPassword () throws Exception {
5151 final BasicAuthHeader AUTH_HEADER = new BasicAuthHeader (NICE_METHOD , USER_NAME , null );
52+ @ SuppressWarnings ("unused" )
5253 BasicAuthenticator .BasicCredentials credentials =
5354 new BasicAuthenticator .BasicCredentials (AUTH_HEADER .getHeader (), StandardCharsets .UTF_8 );
54- Assert .assertEquals (USER_NAME , credentials .getUsername ());
55- Assert .assertNull (credentials .getPassword ());
5655 }
5756
5857 @ Test
@@ -65,14 +64,13 @@ public void testGoodCrib() throws Exception {
6564 Assert .assertEquals (PASSWORD , credentials .getPassword ());
6665 }
6766
68- @ Test
69- public void testGoodCribUserOnly () throws Exception {
67+ @ Test ( expected = IllegalArgumentException . class )
68+ public void testBadCribUserOnly () throws Exception {
7069 final String BASE64_CRIB = "dXNlcmlk" ;
7170 final BasicAuthHeader AUTH_HEADER = new BasicAuthHeader (NICE_METHOD , BASE64_CRIB );
71+ @ SuppressWarnings ("unused" )
7272 BasicAuthenticator .BasicCredentials credentials =
7373 new BasicAuthenticator .BasicCredentials (AUTH_HEADER .getHeader (), StandardCharsets .UTF_8 );
74- Assert .assertEquals (USER_NAME , credentials .getUsername ());
75- Assert .assertNull (credentials .getPassword ());
7674 }
7775
7876 @ Test
@@ -108,8 +106,8 @@ public void testGoodCribBase64Big() throws Exception {
108106 // Our decoder accepts a long token without complaint.
109107 // 80 characters
110108 final String USER_LONG = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/AAAABBBBCCCCDDDD" ;
111- final String BASE64_CRIB = "QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0 " +
112- "NTY3ODkrL0FBQUFCQkJCQ0NDQ0REREQ= " ; // no new line
109+ final String BASE64_CRIB = "QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5e " +
110+ "jAxMjM0NTY3ODkrL0FBQUFCQkJCQ0NDQ0REREQ6 " ; // no new line
113111 final BasicAuthHeader AUTH_HEADER = new BasicAuthHeader (NICE_METHOD , BASE64_CRIB );
114112 BasicAuthenticator .BasicCredentials credentials =
115113 new BasicAuthenticator .BasicCredentials (AUTH_HEADER .getHeader (), StandardCharsets .UTF_8 );
0 commit comments