BasicAuthorizer implements Authorizer<UserConfiguration> { @Override public boolean authorize(UserConfiguration userConfiguration, String s) { return userConfiguration.getName().equals(this.userConfiguration.getName()) && s.equals(AUTHENTICATED_ROLE); } BasicAuthorizer(UserConfiguration userConfiguration); @Override boolean authorize(UserConfiguration userConfiguration, String s); static final String AUTHENTICATED_ROLE; }
@Test public void correctRoleAndName() throws Exception { assertTrue(authorizer.authorize(new UserConfiguration(correctUser, ""), BasicAuthorizer.AUTHENTICATED_ROLE)); }
@Test public void incorrectRole() throws Exception { assertFalse(authorizer.authorize(new UserConfiguration(correctUser, ""), "derp")); }
@Test public void incorrectUser() throws Exception { assertFalse(authorizer.authorize(new UserConfiguration("derp", ""), BasicAuthorizer.AUTHENTICATED_ROLE)); }