Reputation: 40
I am trying to stop a selenium hub registering a node by implementing a custom proxy. I have some code that works for a custom proxy. However, the client can get round this by not specifying the custom proxy in its configuration. Is there a way we can force the node to use the custom proxy and not to use DefaultRemoteProxy.
Or is there something I can implement within the Selenium Project to authenticate a node with the selenium hub?
Upvotes: 0
Views: 542
Reputation: 14746
There's no elegant way of doing this. Here's a dirty hack using which you can get this done.
Registrable
)org.openqa.grid.selenium.proxy.DefaultRemoteProxy
(I like to call this approach as CLASSPATH overriding but am sure there's a much more elegant name for this ) such that this new class also is called DefaultRemoteProxy
and it resides in the same package org.openqa.grid.selenium.proxy
but in your test project.Here's how Registrable
would look like
public interface Registrable {}
Here's how the modified constructor of DefaultRemoteProxy
would look like :
public DefaultRemoteProxy(RegistrationRequest request, Registry registry) {
super(request, registry);
if (!(this instanceof Registrable)) {
throw new UnsupportedOperationException("Cannot proceed further");
}
pollingInterval = config.nodePolling != null ? config.nodePolling : DEFAULT_POLLING_INTERVAL;
unregisterDelay = config.unregisterIfStillDownAfter != null ? config.unregisterIfStillDownAfter : DEFAULT_UNREGISTER_DELAY;
downPollingLimit = config.downPollingLimit != null ? config.downPollingLimit : DEFAULT_DOWN_POLLING_LIMIT;
}
Now you can tweak your custom proxy such that it implements the Registrable
interface. So anyone trying to register their node using DefaultRemoteProxy
would constantly fail because DefaultRemoteProxy
doesn't implement Registrable
interface.
Would this work for you ?
Upvotes: 1