diff --git a/src/main/java/com/stephensugden/guacamole/net/hmac/HmacAuthenticationProvider.java b/src/main/java/com/stephensugden/guacamole/net/hmac/HmacAuthenticationProvider.java index 70c758c..75c03c4 100644 --- a/src/main/java/com/stephensugden/guacamole/net/hmac/HmacAuthenticationProvider.java +++ b/src/main/java/com/stephensugden/guacamole/net/hmac/HmacAuthenticationProvider.java @@ -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(); diff --git a/src/test/java/com/stephensugden/guacamole/net/hmac/HmacAuthenticationProviderTest.java b/src/test/java/com/stephensugden/guacamole/net/hmac/HmacAuthenticationProviderTest.java index fe76768..027760c 100644 --- a/src/test/java/com/stephensugden/guacamole/net/hmac/HmacAuthenticationProviderTest.java +++ b/src/test/java/com/stephensugden/guacamole/net/hmac/HmacAuthenticationProviderTest.java @@ -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; @@ -101,10 +103,16 @@ public void testTimestampStale() throws Exception { HmacAuthenticationProvider authProvider = new HmacAuthenticationProvider(timeProvider); Map configs = authProvider.getAuthorizedConfigurations(credentials); - assertNull(configs); + + // test that updateUserContext also returns null when the timestamp is stale + Map dummyConfigs = new HashMap(); + dummyConfigs.put("dummy", new GuacamoleConfiguration()); + SimpleUserContext context = new SimpleUserContext(dummyConfigs); + UserContext updatedUserContext = authProvider.updateUserContext(context, credentials); + assertNull(updatedUserContext); } - + private HttpServletRequest getHttpServletRequest() { return getHttpServletRequest(connectionId); }