BVB Source Codes

spring-security-oauth Show JwtHeaderConverterTest.java Source code

Return Download spring-security-oauth: download JwtHeaderConverterTest.java Source code - Download spring-security-oauth Source code - Type:.java
  1. /*
  2.  * Copyright 2012-2017 the original author or authors.
  3.  *
  4.  * Licensed under the Apache License, Version 2.0 (the "License");
  5.  * you may not use this file except in compliance with the License.
  6.  * You may obtain a copy of the License at
  7.  *
  8.  *      http://www.apache.org/licenses/LICENSE-2.0
  9.  *
  10.  * Unless required by applicable law or agreed to in writing, software
  11.  * distributed under the License is distributed on an "AS IS" BASIS,
  12.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13.  * See the License for the specific language governing permissions and
  14.  * limitations under the License.
  15.  */
  16. package org.springframework.security.oauth2.provider.token.store.jwk;
  17.  
  18.  
  19. import org.junit.Rule;
  20. import org.junit.Test;
  21. import org.junit.rules.ExpectedException;
  22. import org.springframework.security.oauth2.common.exceptions.InvalidTokenException;
  23.  
  24. import java.util.Map;
  25.  
  26. import static org.junit.Assert.assertEquals;
  27. import static org.springframework.security.oauth2.provider.token.store.jwk.JwtTestUtil.createJwt;
  28.  
  29. /**
  30.  * @author Joe Grandja
  31.  */
  32. public class JwtHeaderConverterTest {
  33.         private final JwtHeaderConverter converter = new JwtHeaderConverter();
  34.  
  35.         @Rule
  36.         public ExpectedException thrown = ExpectedException.none();
  37.  
  38.  
  39.         @Test
  40.         public void convertWhenJwtTokenIsNullThenThrowNullPointerException() throws Exception {
  41.                 this.thrown.expect(NullPointerException.class);
  42.                 this.converter.convert(null);
  43.         }
  44.  
  45.         @Test
  46.         public void convertWhenJwtTokenInvalidThenThrowJwkException() throws Exception {
  47.                 this.thrown.expect(InvalidTokenException.class);
  48.                 this.thrown.expectMessage("Invalid JWT. Missing JOSE Header.");
  49.                 this.converter.convert("");
  50.         }
  51.  
  52.         @Test
  53.         public void convertWhenJwtTokenValidThenReturnJwtHeaders() throws Exception {
  54.                 Map<String, String> jwtHeaders = this.converter.convert(createJwt());
  55.                 assertEquals("key-id-1", jwtHeaders.get(JwkAttributes.KEY_ID));
  56.                 assertEquals(JwkDefinition.CryptoAlgorithm.RS256.headerParamValue(), jwtHeaders.get(JwkAttributes.ALGORITHM));
  57.         }
  58. }
downloadJwtHeaderConverterTest.java Source code - Download spring-security-oauth Source code
Related Source Codes/Software:
Toucan - Fabulous Image Processing in Swift 2017-04-23
CoffeeScriptRedux - 2017-04-23
breakpoint - Really simple media queries in Sa 2017-04-23
libsvm - 2017-04-22
grr - GRR Rapid Response: remote live forensics for inci... 2017-04-22
rouge - A pure-ruby code highlighter that is compatible wi... 2017-04-23
sphinx_rtd_theme - Sphinx theme for readthedocs.org 2017-04-23
BlurEffectForAndroidDesign - Sample to show how to implement blur graphical tri... 2017-04-23
mama2 - Mother plan - all firewood high flame 2017-04-23
JKeyboardPanelSwitch - For resolve the layout conflict when keybord & amp... 2017-04-23
react-music - Make beats with React! http... 2017-04-30
java-code-styles - IntelliJ IDEA code style settings for Square's Jav... 2017-04-30
swing - A swipeable cards interface. The swipe-left/swipe-... 2017-04-30
qTip2 - qTip2 - Pretty powerful tooltips ... 2017-04-30
jo - JSON output from a shell 2017-04-30
Fluidbox - Replicating and improving the lightbox module seen... 2017-04-30
boto3 - AWS SDK for Python http://a... 2017-04-30
PreloadJS - PreloadJS makes preloading assets & getting ag... 2017-04-29
gotraining - Go Training Class Material : ... 2017-04-29
eigen - The Art World in Your Pocket or Your Trendy Tech C... 2017-04-29

 Back to top