public async Task <string> TestConnection() { try { AuthenticationStrategy authenticationStrategy = null; if (credentialLogin) { authenticationStrategy = new LwssoAuthenticationStrategy(new UserPassConnectionInfo(OctaneConfiguration.Username, OctaneConfiguration.Password)); } else if (ssologin) { authenticationStrategy = new SsoAuthenticationStrategy(); } await authenticationStrategy.TestConnection(url); // Don't do advanced test connection with sso login, will cause deadlock if (credentialLogin) { // reset and thus require a new octane service obj Run(async() => { return(await OctaneServices.Reset()); }).Wait(); // hotfix for first time installing the plugin and clicking test connection if (OctaneConfiguration.CredentialLogin == false) { OctaneConfiguration.CredentialLogin = true; } // create a new service object OctaneServices.Create(OctaneConfiguration.Url, OctaneConfiguration.SharedSpaceId, OctaneConfiguration.WorkSpaceId); await OctaneServices.GetInstance().Connect(); // try to get the work item root await OctaneServices.GetInstance().GetAsyncWorkItemRoot(); } return(ConnectionSuccessful); } catch (Exception ex) { return(ex.Message); } }
public static void InitConnection(TestContext context) { if (!restConnector.IsConnected()) { string ignoreServerCertificateValidation = ConfigurationManager.AppSettings["ignoreServerCertificateValidation"]; if (ignoreServerCertificateValidation != null && ignoreServerCertificateValidation.ToLower().Equals("true")) { NetworkSettings.IgnoreServerCertificateValidation(); } NetworkSettings.EnableAllSecurityProtocols(); host = ConfigurationManager.AppSettings["webAppUrl"]; // If webAppUrl is empty we do not try to connect. if (string.IsNullOrWhiteSpace(host)) { return; } ConnectionInfo connectionInfo; string clientId = ConfigurationManager.AppSettings["clientId"]; if (clientId != null) { userName = clientId; connectionInfo = new APIKeyConnectionInfo(clientId, ConfigurationManager.AppSettings["clientSecret"]); } else { userName = ConfigurationManager.AppSettings["userName"]; password = ConfigurationManager.AppSettings["password"]; connectionInfo = new UserPassConnectionInfo(userName, password); } lwssoAuthenticationStrategy = new LwssoAuthenticationStrategy(connectionInfo); restConnector.Connect(host, lwssoAuthenticationStrategy); var sharedSpaceId = int.Parse(ConfigurationManager.AppSettings["sharedSpaceId"]); var workspaceId = int.Parse(ConfigurationManager.AppSettings["workspaceId"]); workspaceContext = new WorkspaceContext(sharedSpaceId, workspaceId); sharedSpaceContext = new SharedSpaceContext(sharedSpaceId); } }
public ALMOctaneConnection(string host, string userName, string password, string sharedSpaceId, string workspaceId) { RestConnector = new RestConnector(); EntityService = new EntityService(RestConnector); SharedspaceId = sharedSpaceId; WorkspaceId = workspaceId; LwssoAuthenticationStrategy lwssoAuthenticationStrategy; //WorkspaceContext workspaceContext; //SharedSpaceContext sharedSpaceContext; NetworkSettings.IgnoreServerCertificateValidation(); NetworkSettings.EnableAllSecurityProtocols(); ConnectionInfo connectionInfo; connectionInfo = new UserPassConnectionInfo(userName, password); lwssoAuthenticationStrategy = new LwssoAuthenticationStrategy(connectionInfo); RestConnector.Connect(host, lwssoAuthenticationStrategy); //workspaceContext = new WorkspaceContext(sharedSpaceId, workspaceId); //sharedSpaceContext = new SharedSpaceContext(sharedSpaceId); }