Skip to content

Commit

Permalink
Merge pull request cyverse#9 from krambmal/master
Browse files Browse the repository at this point in the history
Improve handling of stale timestamps
  • Loading branch information
grncdr committed Nov 5, 2014
2 parents ffe39cb + a0bdef7 commit 9dc2e0c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public UserContext updateUserContext(UserContext context, Credentials credential
HttpServletRequest request = credentials.getRequest();
GuacamoleConfiguration config = getGuacamoleConfiguration(request);
if (config == null) {
return context;
return null;
}
String id = config.getParameter("id");
SimpleConnectionDirectory connections = (SimpleConnectionDirectory) context.getRootConnectionGroup().getConnectionDirectory();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import junit.framework.TestCase;
import org.glyptodon.guacamole.GuacamoleException;
import org.glyptodon.guacamole.net.auth.Credentials;
import org.glyptodon.guacamole.net.auth.UserContext;
import org.glyptodon.guacamole.net.auth.simple.SimpleUserContext;
import org.glyptodon.guacamole.properties.GuacamoleProperties;
import org.glyptodon.guacamole.protocol.GuacamoleConfiguration;
import org.mockito.invocation.InvocationOnMock;
Expand Down Expand Up @@ -101,10 +103,16 @@ public void testTimestampStale() throws Exception {
HmacAuthenticationProvider authProvider = new HmacAuthenticationProvider(timeProvider);

Map<String, GuacamoleConfiguration> configs = authProvider.getAuthorizedConfigurations(credentials);

assertNull(configs);

// test that updateUserContext also returns null when the timestamp is stale
Map<String, GuacamoleConfiguration> dummyConfigs = new HashMap<String, GuacamoleConfiguration>();
dummyConfigs.put("dummy", new GuacamoleConfiguration());
SimpleUserContext context = new SimpleUserContext(dummyConfigs);
UserContext updatedUserContext = authProvider.updateUserContext(context, credentials);
assertNull(updatedUserContext);
}

private HttpServletRequest getHttpServletRequest() {
return getHttpServletRequest(connectionId);
}
Expand Down

0 comments on commit 9dc2e0c

Please sign in to comment.