-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathTokenAuthSchemeTest.java
More file actions
29 lines (22 loc) · 1004 Bytes
/
TokenAuthSchemeTest.java
File metadata and controls
29 lines (22 loc) · 1004 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package biz.neustar.pagerduty.util;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import org.apache.http.Header;
import org.apache.http.HttpRequest;
import org.apache.http.auth.AuthenticationException;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.protocol.HttpContext;
import org.junit.Test;
public class TokenAuthSchemeTest {
@Test
public void testAuthenticateCredentialsHttpRequestHttpContext() throws AuthenticationException {
TokenAuthScheme scheme = new TokenAuthScheme();
TokenAuthCredentials creds = new TokenAuthCredentials("token_here");
HttpRequest request = new HttpGet();
HttpContext context = new BasicHttpContext();
Header header = scheme.authenticate(creds, request, context);
assertNotNull(header);
assertEquals("Authorization: Token token=token_here", header.toString());
}
}