Community
Participate
Working Groups
I'd like to write an automated test for the file transfer service using a secure Agent Contoller, but I have found that you can't programmatically connect to a secure Agent Controller without going through TPTP Platform UI. I have tried specifying username and password in a ConnectionSpecifier, but that code doesn't appear to be hooked up properly yet. ConnectionSpecifier spec = new ConnectionSpecifier(null, null, HOST, 10002, null, "jtoomey_temp", "fake_password"); // Create a node pointing to local machine node = new NodeImpl(HOST); // Establish a session by connecting to the node try { session = node.connect(spec); } catch (Exception e) { e.printStackTrace(consolePrintStream); } However, I tried hard coding the username and password into the ConnectorService.java class (which, suspiciously is in the org.eclipse.hyades.ui plugin), and the code path still ended up calling into the ConnectUIUtil class and trying to pop up a username and password dialog. This dialog is also brought up via syncExec, which caused my test plugin to deadlock. But the root issue is that we should be able to programmatically connect to a secure agent controller if we specify a username and password, without drawing in a UI dependency. One obvious use case is in running tests from ant or command line, where the UI is not available. Feel free to change components if you think this is miscategorized. I see that some of this code was refactored in 4.2, and it looks like a step in the right direction.
Joe, this is a valid issue and I agree it should be done post 4.3 Assigning to Ali for further review
Ideally this code should be moved to org.eclipse.tptp.platform.common, which is not depedent on any UI plug-ins. I will take a look at this in 4.4. Setting priority to P2.
Target to future. Cannot be contained in 4.4 due to limitation of resource.
Eugene, This defect is blocking a critical test defect that needs to be fixed in 4.4. https://bugs.eclipse.org/bugs/show_bug.cgi?id=171840 Can we reconsider keeping it in 4.4?
Joanna, There is a need to fix this for test defect, can you reconsider this in the 4.4 list with the resource available?
Re-target to 4.4 base on a dependency of bug 171840.
Hi Joe, Have you try BaseConnectUtil connectUtil = new BaseConnectUtil(host, port, user,this); int result = connectUtil.connect(password, false); where BaseConnectUtil is org.eclipse.hyades.security.internal.util.BaseConnectUtil.
Hi Eugene, It looks like this code is closer to what we need, but it still doesn't work the way I'd like it to. I'm trying to connect to the agent controller securely from an ant script, so UI is not a possibility. I had to make a couple of changes in the ant adapter code to the username and password are passed along as they should be, but even now that they are, BaseConnectUtil.connect is trying to bring up UI to ask me if I want to accept a new certificate for this connection. I don't know if it would work if I had already done so or not. I will attach a screenshot of the stack trace of where we are hung waiting for the UI. Thanks.
Created attachment 65853 [details] stack trace showing where we try to bring up UI even when username & password are specified
Joe. I am not sure if you are using the latest version of ConnectorService, the latest version creates an instance of ConnectUtil. If it creates an instance of BaseConnectUtil instead, if will not prompt any UI as the call of openQuestionDialog will return org.eclipse.hyades.security.internal.util.NullConnectUtilUI.openQuestionDialog() which skip the UI and return value 0 all the time. Do you have to use ConnectorService? Could you try in your code make a direct call of BaseConnectUtil connectUtil = new BaseConnectUtil(host, port, user,this); int result = connectUtil.connect(password, false); instead?
It seems that if you want to skip UI, you cannot use org.eclipse.hyades.ui.services.ConnectorService, and it explains why it's under hyades.ui =) It doens't seem like there is a non-UI equivalent of ConnectorService API.
Thanks for looking into this further, Eugene. ConnectorService was designed to work headless, but when it was written, there was no BaseConnectUtil class (or even a org.eclipse.tptp.platform.common plugin at all). Scott originally put the service in the org.eclipse.hyades.test.core plugin, but he had to add a dependency on org.eclipse.hyades.ui to pick up ConnectUtil, and that was obviously wrong. So he ended up moving the service directly into org.eclipse.hyades.ui. Since then, it appears a lot of good work has happened here, especially the refactoring that Ali did under 134531. Based on your suggestion, I have modified the ConnectorService so that is uses BaseConnectUtil if we are running headless, but continues to use ConnectUtil if we are running in a workbench. // Use headless version if the PlatformUI workbench is not running. if (PlatformUI.isWorkbenchRunning()) connectUtil = new ConnectUtil(host, port, user, ConnectorService.this); else connectUtil = new BaseConnectUtil(host, port, user, ConnectorService.this); int result = connectUtil.connect(password, showErrors); I'm not certaın ıf thıs can be done easily, but it would be cool if ConnectUtil could make this determination on its own. As it stands today, the ConnectorService still needs to remain in a plugin with a direct dependency on a UI plugin (now org.eclipse.tptp.platform.common.ui.) I don't think this is a very big deal -- it may actually be a appropriate location for the service. In any case, we can now use secure AC from headless ASF services, so that is cool indeed. Thanks for your help.
Verified in 4.4. Closing.