forked from DolphFlynn/jwt-editor
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request DolphFlynn#31 from DolphFlynn/resign_state_bug
Select first signing key and first algorithm if signing keys present,…
- Loading branch information
Showing
4 changed files
with
48 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
37 changes: 37 additions & 0 deletions
37
src/test/java/com/blackberry/jwteditor/view/config/IntruderConfigModelFromJsonTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.blackberry.jwteditor.view.config; | ||
|
||
import burp.intruder.IntruderConfig; | ||
import com.blackberry.jwteditor.model.keys.KeysModel; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static com.nimbusds.jose.JWSAlgorithm.ES256; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
class IntruderConfigModelFromJsonTest { | ||
private static final String KEYS_JSON = """ | ||
[ | ||
{"kty":"EC","d":"R7xUBrtHikGBXsJkDekdUxWWC2YhYMKTDXILREc4_7s","crv":"P-256","kid":"1","x":"Kxyedi_DE6wZdC1shMeYVx9IvSXl14RRp_Z5tZjBodo","y":"UXtt70JCve0c_puZsjyTHtLD6xfBvoI3fVoh9WzhH-M"}, | ||
{"kty":"EC","crv":"P-256","kid":"2","x":"Kxyedi_DE6wZdC1shMeYVx9IvSXl14RRp_Z5tZjBodo","y":"UXtt70JCve0c_puZsjyTHtLD6xfBvoI3fVoh9WzhH-M"} | ||
]"""; | ||
|
||
@Test | ||
void givenKeysLoadedJson_butNoSelectedKey_whenGetSigningKeyId_thenFirstKeyIdReturned() throws Exception { | ||
IntruderConfigModel model = new IntruderConfigModel(KeysModel.parse(KEYS_JSON), new IntruderConfig()); | ||
|
||
assertThat(model.signingKeyId()).isEqualTo("1"); | ||
} | ||
|
||
@Test | ||
void givenKeysLoadedJson_butNoSelectedKey_whenGetSigningAlgorithms_thenFirstKeysAlgorithmsReturned() throws Exception { | ||
IntruderConfigModel model = new IntruderConfigModel(KeysModel.parse(KEYS_JSON), new IntruderConfig()); | ||
|
||
assertThat(model.signingAlgorithms()).containsExactly(ES256); | ||
} | ||
|
||
@Test | ||
void givenKeysLoadedJson_butNoSelectedKey_whenGetSigningAlgorithm_thenFirstAlgorithmReturned() throws Exception { | ||
IntruderConfigModel model = new IntruderConfigModel(KeysModel.parse(KEYS_JSON), new IntruderConfig()); | ||
|
||
assertThat(model.signingAlgorithm()).isEqualTo(ES256); | ||
} | ||
} |