View Javadoc

1   package com.atlassian.asap.core.server.springsecurity;
2   
3   import org.junit.Test;
4   import org.springframework.security.core.Authentication;
5   
6   import static org.springframework.util.Assert.notNull;
7   
8   public class UnverifiedBearerTokenTest {
9       @Test
10      public void shouldAllowSetAuthenticatedFalse() { // as per the Javadoc
11          new UnverifiedBearerToken("TOKEN").setAuthenticated(false);
12      }
13  
14      @Test(expected = IllegalArgumentException.class)
15      public void shouldRejectSetAuthenticatedTrue() {
16          new UnverifiedBearerToken("TOKEN").setAuthenticated(true);
17      }
18  
19      /**
20       * Spring Security logs authentication failures and requires the Authentication object not to have a null name.
21       */
22      @Test
23      public void mustHaveNonNullName() {
24          Authentication auth = new UnverifiedBearerToken("monkey trousers");
25          notNull(auth.getName());
26      }
27  }