Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void testBasicAuthenticationEmptyChallenge() throws Exception {

@Test
public void testBasicAuthentication() throws Exception {
final AuthChallenge authChallenge = parse("Basic realm=\"test\"");
final AuthChallenge authChallenge = parse(StandardAuthScheme.BASIC + " realm=\"test\"");

final BasicScheme authscheme = new BasicScheme();
authscheme.processChallenge(authChallenge, null);
Expand All @@ -90,7 +90,7 @@ public void testBasicAuthentication() throws Exception {
Assertions.assertTrue(authscheme.isResponseReady(host, credentialsProvider, null));
final String authResponse = authscheme.generateAuthResponse(host, request, null);

final String expected = "Basic " + new String(
final String expected = StandardAuthScheme.BASIC + " "+ new String(
Base64.encodeBase64("testuser:testpass".getBytes(StandardCharsets.US_ASCII)),
StandardCharsets.US_ASCII);
Assertions.assertEquals(expected, authResponse);
Expand All @@ -109,7 +109,7 @@ public void testBasicAuthenticationDefaultCharsetASCII() throws Exception {
final HttpRequest request = new BasicHttpRequest("GET", "/");
authscheme.initPreemptive(creds);
final String authResponse = authscheme.generateAuthResponse(host, request, null);
Assertions.assertEquals("Basic dGVzdDoxMjM/", authResponse);
Assertions.assertEquals(StandardAuthScheme.BASIC + " dGVzdDoxMjM/", authResponse);
}

@Test
Expand All @@ -120,7 +120,7 @@ public void testBasicAuthenticationDefaultCharsetISO88591() throws Exception {
final HttpRequest request = new BasicHttpRequest("GET", "/");
authscheme.initPreemptive(creds);
final String authResponse = authscheme.generateAuthResponse(host, request, null);
Assertions.assertEquals("Basic dGVzdDoxMjOj", authResponse);
Assertions.assertEquals(StandardAuthScheme.BASIC + " dGVzdDoxMjOj", authResponse);
}

@Test
Expand All @@ -131,12 +131,12 @@ public void testBasicAuthenticationDefaultCharsetUTF8() throws Exception {
final HttpRequest request = new BasicHttpRequest("GET", "/");
authscheme.initPreemptive(creds);
final String authResponse = authscheme.generateAuthResponse(host, request, null);
Assertions.assertEquals("Basic dGVzdDoxMjPCow==", authResponse);
Assertions.assertEquals(StandardAuthScheme.BASIC + " dGVzdDoxMjPCow==", authResponse);
}

@Test
public void testBasicAuthenticationWithCharset() throws Exception {
final AuthChallenge authChallenge = parse("Basic realm=\"test\", charset=\"utf-8\"");
final AuthChallenge authChallenge = parse(StandardAuthScheme.BASIC + " realm=\"test\", charset=\"utf-8\"");

final BasicScheme authscheme = new BasicScheme();
authscheme.processChallenge(authChallenge, null);
Expand All @@ -149,15 +149,15 @@ public void testBasicAuthenticationWithCharset() throws Exception {
final HttpRequest request = new BasicHttpRequest("GET", "/");
Assertions.assertTrue(authscheme.isResponseReady(host, credentialsProvider, null));
final String authResponse = authscheme.generateAuthResponse(host, request, null);
Assertions.assertEquals("Basic dGVzdDoxMjPCow==", authResponse);
Assertions.assertEquals(StandardAuthScheme.BASIC + " dGVzdDoxMjPCow==", authResponse);
Assertions.assertEquals("test", authscheme.getRealm());
Assertions.assertTrue(authscheme.isChallengeComplete());
Assertions.assertFalse(authscheme.isConnectionBased());
}

@Test
public void testSerialization() throws Exception {
final AuthChallenge authChallenge = parse("Basic realm=\"test\"");
final AuthChallenge authChallenge = parse(StandardAuthScheme.BASIC + " realm=\"test\"");

final BasicScheme basicScheme = new BasicScheme();
basicScheme.processChallenge(authChallenge, null);
Expand Down