Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 747c759

Browse filesBrowse files
author
Marcos.Cela
committed
fix code violations again
1 parent e0a7096 commit 747c759
Copy full SHA for 747c759

File tree

Expand file treeCollapse file tree

1 file changed

+19
-20
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+19
-20
lines changed

‎src/test/java/org/kohsuke/github/extras/auth/JWTTokenProviderTest.java

Copy file name to clipboardExpand all lines: src/test/java/org/kohsuke/github/extras/auth/JWTTokenProviderTest.java
+19-20Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,30 @@
77
import java.io.File;
88
import java.io.IOException;
99
import java.security.GeneralSecurityException;
10-
10+
/*
11+
* This test will request an application ensuring that the header for the "Authorization" matches a valid JWT token.
12+
* A JWT token in the Authorization header will always start with "ey" which is always the start of the base64
13+
* encoding of the JWT Header , so a valid header will look like this:
14+
*
15+
* <pre>
16+
* Authorization: Bearer ey{rest of the header}.{payload}.{signature}
17+
* </pre>
18+
*
19+
* Matched by the regular expression:
20+
*
21+
* <pre>
22+
* ^Bearer (?<JWTHeader>ey\S*)\.(?<JWTPayload>\S*)\.(?<JWTSignature>\S*)$
23+
* </pre>
24+
*
25+
* Which is present in the wiremock matcher. Note that we need to use a matcher because the JWT token is encoded
26+
* with a private key and a random nonce, so it will never be the same (under normal conditions). For more
27+
* information on the format of a JWT token, see: https://jwt.io/introduction/
28+
*/
1129
public class JWTTokenProviderTest extends AbstractGitHubWireMockTest {
1230

1331
private static String TEST_APP_ID_2 = "83009";
1432
private static String PRIVATE_KEY_FILE_APP_2 = "/ghapi-test-app-2.private-key.pem";
1533

16-
/**
17-
* This test will request an application ensuring that the header for the "Authorization" matches a valid JWT token.
18-
* A JWT token in the Authorization header will always start with "ey" which is always the start of the base64
19-
* encoding of the JWT Header , so a valid header will look like this:
20-
*
21-
* <pre>
22-
* Authorization: Bearer ey{rest of the header}.{payload}.{signature}
23-
* </pre>
24-
*
25-
* Matched by the regular expression:
26-
*
27-
* <pre>
28-
* ^Bearer (?<JWTHeader>ey\S*)\.(?<JWTPayload>\S*)\.(?<JWTSignature>\S*)$
29-
* </pre>
30-
*
31-
* Which is present in the wiremock matcher. Note that we need to use a matcher because the JWT token is encoded
32-
* with a private key and a random nonce, so it will never be the same (under normal conditions). For more
33-
* information on the format of a JWT token, see: https://jwt.io/introduction/
34-
*/
3534
@Test
3635
public void testAuthorizationHeaderPattern() throws GeneralSecurityException, IOException {
3736
JWTTokenProvider jwtTokenProvider = new JWTTokenProvider(TEST_APP_ID_2,

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.