forked from PegaSysEng/pantheon
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PAN-2313] Fix authentication header (PegaSysEng#891)
- Loading branch information
1 parent
597b511
commit 706e319
Showing
8 changed files
with
75 additions
and
9 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 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 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
56 changes: 56 additions & 0 deletions
56
...t/java/tech/pegasys/pantheon/ethereum/jsonrpc/authentication/AuthenticationUtilsTest.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,56 @@ | ||
/* | ||
* Copyright 2019 ConsenSys AG. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
package tech.pegasys.pantheon.ethereum.jsonrpc.authentication; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import org.junit.Test; | ||
|
||
public class AuthenticationUtilsTest { | ||
|
||
@Test | ||
public void getJwtTokenFromNullStringShouldReturnNull() { | ||
final String headerValue = null; | ||
|
||
final String token = AuthenticationUtils.getJwtTokenFromAuthorizationHeaderValue(headerValue); | ||
|
||
assertThat(token).isNull(); | ||
} | ||
|
||
@Test | ||
public void getJwtTokenFromEmptyStringShouldReturnNull() { | ||
final String headerValue = ""; | ||
|
||
final String token = AuthenticationUtils.getJwtTokenFromAuthorizationHeaderValue(headerValue); | ||
|
||
assertThat(token).isNull(); | ||
} | ||
|
||
@Test | ||
public void getJwtTokenFromInvalidAuthorizationHeaderValueShouldReturnNull() { | ||
final String headerValue = "Foo eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9"; | ||
|
||
final String token = AuthenticationUtils.getJwtTokenFromAuthorizationHeaderValue(headerValue); | ||
|
||
assertThat(token).isNull(); | ||
} | ||
|
||
@Test | ||
public void getJwtTokenFromValidAuthorizationHeaderValueShouldReturnToken() { | ||
final String headerValue = "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9"; | ||
|
||
final String token = AuthenticationUtils.getJwtTokenFromAuthorizationHeaderValue(headerValue); | ||
|
||
assertThat(token).isEqualTo("eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9"); | ||
} | ||
} |
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