alita-sdk 0.3.376__py3-none-any.whl → 0.3.423__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of alita-sdk might be problematic. Click here for more details.
- alita_sdk/configurations/bitbucket.py +95 -0
- alita_sdk/configurations/confluence.py +96 -1
- alita_sdk/configurations/gitlab.py +79 -0
- alita_sdk/configurations/jira.py +103 -0
- alita_sdk/configurations/testrail.py +88 -0
- alita_sdk/configurations/xray.py +93 -0
- alita_sdk/configurations/zephyr_enterprise.py +93 -0
- alita_sdk/configurations/zephyr_essential.py +75 -0
- alita_sdk/runtime/clients/client.py +3 -2
- alita_sdk/runtime/clients/sandbox_client.py +8 -0
- alita_sdk/runtime/langchain/assistant.py +41 -38
- alita_sdk/runtime/langchain/constants.py +4 -0
- alita_sdk/runtime/langchain/document_loaders/AlitaDocxMammothLoader.py +315 -3
- alita_sdk/runtime/langchain/document_loaders/AlitaJSONLoader.py +4 -1
- alita_sdk/runtime/langchain/document_loaders/constants.py +28 -12
- alita_sdk/runtime/langchain/langraph_agent.py +88 -27
- alita_sdk/runtime/langchain/utils.py +24 -4
- alita_sdk/runtime/toolkits/application.py +8 -1
- alita_sdk/runtime/toolkits/tools.py +80 -49
- alita_sdk/runtime/tools/__init__.py +7 -2
- alita_sdk/runtime/tools/application.py +7 -0
- alita_sdk/runtime/tools/function.py +20 -28
- alita_sdk/runtime/tools/graph.py +10 -4
- alita_sdk/runtime/tools/image_generation.py +104 -8
- alita_sdk/runtime/tools/llm.py +146 -114
- alita_sdk/runtime/tools/sandbox.py +166 -63
- alita_sdk/runtime/tools/vectorstore.py +3 -2
- alita_sdk/runtime/tools/vectorstore_base.py +4 -3
- alita_sdk/runtime/utils/utils.py +1 -0
- alita_sdk/tools/__init__.py +43 -31
- alita_sdk/tools/ado/work_item/ado_wrapper.py +17 -8
- alita_sdk/tools/base_indexer_toolkit.py +75 -66
- alita_sdk/tools/code_indexer_toolkit.py +13 -3
- alita_sdk/tools/confluence/api_wrapper.py +29 -7
- alita_sdk/tools/confluence/loader.py +10 -0
- alita_sdk/tools/elitea_base.py +7 -7
- alita_sdk/tools/gitlab/api_wrapper.py +8 -9
- alita_sdk/tools/jira/api_wrapper.py +1 -1
- alita_sdk/tools/openapi/__init__.py +10 -1
- alita_sdk/tools/qtest/api_wrapper.py +298 -51
- alita_sdk/tools/sharepoint/api_wrapper.py +104 -33
- alita_sdk/tools/sharepoint/authorization_helper.py +175 -1
- alita_sdk/tools/sharepoint/utils.py +8 -2
- alita_sdk/tools/utils/content_parser.py +27 -16
- alita_sdk/tools/vector_adapters/VectorStoreAdapter.py +19 -6
- {alita_sdk-0.3.376.dist-info → alita_sdk-0.3.423.dist-info}/METADATA +1 -1
- {alita_sdk-0.3.376.dist-info → alita_sdk-0.3.423.dist-info}/RECORD +50 -50
- {alita_sdk-0.3.376.dist-info → alita_sdk-0.3.423.dist-info}/WHEEL +0 -0
- {alita_sdk-0.3.376.dist-info → alita_sdk-0.3.423.dist-info}/licenses/LICENSE +0 -0
- {alita_sdk-0.3.376.dist-info → alita_sdk-0.3.423.dist-info}/top_level.txt +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from typing import Optional
|
|
2
2
|
|
|
3
|
+
from atlassian import Bitbucket
|
|
3
4
|
from pydantic import BaseModel, ConfigDict, Field, SecretStr
|
|
4
5
|
|
|
5
6
|
|
|
@@ -30,3 +31,97 @@ class BitbucketConfiguration(BaseModel):
|
|
|
30
31
|
url: str = Field(description="Bitbucket URL")
|
|
31
32
|
username: str = Field(description="Bitbucket Username")
|
|
32
33
|
password: SecretStr = Field(description="Bitbucket Password/App Password")
|
|
34
|
+
|
|
35
|
+
@staticmethod
|
|
36
|
+
def check_connection(settings: dict) -> str | None:
|
|
37
|
+
"""
|
|
38
|
+
Check the connection to Bitbucket.
|
|
39
|
+
|
|
40
|
+
Args:
|
|
41
|
+
settings: Dictionary containing Bitbucket configuration
|
|
42
|
+
- url: Bitbucket instance URL (required)
|
|
43
|
+
- username: Bitbucket username (required)
|
|
44
|
+
- password: Password or App Password (required)
|
|
45
|
+
|
|
46
|
+
Returns:
|
|
47
|
+
None if connection successful, error message string if failed
|
|
48
|
+
"""
|
|
49
|
+
import requests
|
|
50
|
+
from requests.auth import HTTPBasicAuth
|
|
51
|
+
|
|
52
|
+
# Validate url
|
|
53
|
+
url = settings.get("url", "").strip()
|
|
54
|
+
if not url:
|
|
55
|
+
return "Bitbucket URL is required"
|
|
56
|
+
|
|
57
|
+
# Normalize URL - remove trailing slashes
|
|
58
|
+
url = url.rstrip("/")
|
|
59
|
+
|
|
60
|
+
# Basic URL validation
|
|
61
|
+
if not url.startswith(("http://", "https://")):
|
|
62
|
+
return "Bitbucket URL must start with http:// or https://"
|
|
63
|
+
|
|
64
|
+
# Validate username
|
|
65
|
+
username = settings.get("username", "").strip()
|
|
66
|
+
if not username:
|
|
67
|
+
return "Bitbucket username is required"
|
|
68
|
+
|
|
69
|
+
# Validate password
|
|
70
|
+
password = settings.get("password")
|
|
71
|
+
if not password:
|
|
72
|
+
return "Bitbucket password is required"
|
|
73
|
+
|
|
74
|
+
# Extract password value if it's a SecretStr
|
|
75
|
+
password_value = password.get_secret_value() if hasattr(password, 'get_secret_value') else password
|
|
76
|
+
|
|
77
|
+
if not password_value or not str(password_value).strip():
|
|
78
|
+
return "Bitbucket password cannot be empty"
|
|
79
|
+
|
|
80
|
+
# Detect if this is Bitbucket Cloud or Server/Data Center
|
|
81
|
+
is_cloud = "bitbucket.org" in url.lower() or "api.bitbucket.org" in url.lower()
|
|
82
|
+
is_correct_bitbucket_domain = "bitbucket" in url.lower()
|
|
83
|
+
|
|
84
|
+
if is_cloud:
|
|
85
|
+
# Bitbucket Cloud: Use API v2.0
|
|
86
|
+
# Endpoint: /2.0/user - returns current authenticated user
|
|
87
|
+
test_url = f"{url}/2.0/user"
|
|
88
|
+
else:
|
|
89
|
+
# Bitbucket Server/Data Center: Use API v1.0
|
|
90
|
+
# Endpoint: /rest/api/1.0/users/{username}
|
|
91
|
+
test_url = f"{url}/rest/api/1.0/users/{username}"
|
|
92
|
+
|
|
93
|
+
try:
|
|
94
|
+
response = requests.get(
|
|
95
|
+
test_url,
|
|
96
|
+
auth=HTTPBasicAuth(username, str(password_value).strip()),
|
|
97
|
+
timeout=10
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
# Check response status
|
|
101
|
+
if response.status_code == 200:
|
|
102
|
+
# Successfully connected and authenticated
|
|
103
|
+
return None
|
|
104
|
+
elif response.status_code == 401:
|
|
105
|
+
return "Authentication failed: invalid username or password"
|
|
106
|
+
elif response.status_code == 403:
|
|
107
|
+
return "Access forbidden: check user permissions"
|
|
108
|
+
elif response.status_code == 404:
|
|
109
|
+
if not is_correct_bitbucket_domain:
|
|
110
|
+
return f"Url you provided is incorrect. Please provide correct server or cloud bitbucket url."
|
|
111
|
+
if is_cloud:
|
|
112
|
+
return "Bitbucket API endpoint not found: please provide the correct bitbucket cloud URL"
|
|
113
|
+
else:
|
|
114
|
+
return "Bitbucket API endpoint not found: please provide the correct bitbucket server URL"
|
|
115
|
+
else:
|
|
116
|
+
return f"Bitbucket API returned status code {response.status_code}"
|
|
117
|
+
|
|
118
|
+
except requests.exceptions.SSLError as e:
|
|
119
|
+
return f"SSL certificate verification failed: {str(e)}"
|
|
120
|
+
except requests.exceptions.ConnectionError:
|
|
121
|
+
return f"Cannot connect to Bitbucket at {url if not is_cloud else 'api.bitbucket.org'}: connection refused"
|
|
122
|
+
except requests.exceptions.Timeout:
|
|
123
|
+
return f"Connection to Bitbucket at {url if not is_cloud else 'api.bitbucket.org'} timed out"
|
|
124
|
+
except requests.exceptions.RequestException as e:
|
|
125
|
+
return f"Error connecting to Bitbucket: {str(e)}"
|
|
126
|
+
except Exception as e:
|
|
127
|
+
return f"Unexpected error: {str(e)}"
|
|
@@ -34,4 +34,99 @@ class ConfluenceConfiguration(BaseModel):
|
|
|
34
34
|
base_url: str = Field(description="Confluence URL")
|
|
35
35
|
username: Optional[str] = Field(description="Confluence Username", default=None)
|
|
36
36
|
api_key: Optional[SecretStr] = Field(description="Confluence API Key", default=None)
|
|
37
|
-
token: Optional[SecretStr] = Field(description="Confluence Token", default=None)
|
|
37
|
+
token: Optional[SecretStr] = Field(description="Confluence Token", default=None)
|
|
38
|
+
|
|
39
|
+
@staticmethod
|
|
40
|
+
def check_connection(settings: dict) -> str | None:
|
|
41
|
+
"""
|
|
42
|
+
Check the connection to Confluence.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
settings: Dictionary containing Confluence configuration
|
|
46
|
+
- base_url: Confluence instance URL (required)
|
|
47
|
+
- username: Username for Basic Auth (optional)
|
|
48
|
+
- api_key: API key/password for Basic Auth (optional)
|
|
49
|
+
- token: Bearer token for authentication (optional)
|
|
50
|
+
|
|
51
|
+
Returns:
|
|
52
|
+
None if connection successful, error message string if failed
|
|
53
|
+
"""
|
|
54
|
+
import requests
|
|
55
|
+
from requests.auth import HTTPBasicAuth
|
|
56
|
+
|
|
57
|
+
# Validate base_url
|
|
58
|
+
base_url = settings.get("base_url", "").strip()
|
|
59
|
+
if not base_url:
|
|
60
|
+
return "Confluence URL is required"
|
|
61
|
+
|
|
62
|
+
# Normalize URL - remove trailing slashes
|
|
63
|
+
base_url = base_url.rstrip("/")
|
|
64
|
+
|
|
65
|
+
# Basic URL validation
|
|
66
|
+
if not base_url.startswith(("http://", "https://")):
|
|
67
|
+
return "Confluence URL must start with http:// or https://"
|
|
68
|
+
|
|
69
|
+
# Check authentication credentials
|
|
70
|
+
username = settings.get("username")
|
|
71
|
+
api_key = settings.get("api_key")
|
|
72
|
+
token = settings.get("token")
|
|
73
|
+
|
|
74
|
+
# Validate authentication - at least one method must be provided
|
|
75
|
+
has_basic_auth = bool(username and api_key)
|
|
76
|
+
has_token = bool(token and str(token).strip())
|
|
77
|
+
|
|
78
|
+
# Determine authentication method
|
|
79
|
+
auth_headers = {}
|
|
80
|
+
auth = None
|
|
81
|
+
|
|
82
|
+
if has_token:
|
|
83
|
+
# Bearer token authentication
|
|
84
|
+
token_value = token.get_secret_value() if hasattr(token, 'get_secret_value') else token
|
|
85
|
+
auth_headers["Authorization"] = f"Bearer {token_value}"
|
|
86
|
+
elif has_basic_auth:
|
|
87
|
+
# Basic authentication
|
|
88
|
+
api_key_value = api_key.get_secret_value() if hasattr(api_key, 'get_secret_value') else api_key
|
|
89
|
+
auth = HTTPBasicAuth(username, api_key_value)
|
|
90
|
+
else:
|
|
91
|
+
return "Authentication required: provide either token or both username and api_key"
|
|
92
|
+
|
|
93
|
+
# Test connection using /rest/api/user/current endpoint
|
|
94
|
+
# This endpoint returns current user info and validates authentication
|
|
95
|
+
test_url = f"{base_url}/rest/api/user/current"
|
|
96
|
+
|
|
97
|
+
try:
|
|
98
|
+
response = requests.get(
|
|
99
|
+
test_url,
|
|
100
|
+
auth=auth,
|
|
101
|
+
headers=auth_headers,
|
|
102
|
+
timeout=10
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
# Check response status
|
|
106
|
+
if response.status_code == 200:
|
|
107
|
+
# Successfully connected and authenticated
|
|
108
|
+
return None
|
|
109
|
+
elif response.status_code == 401:
|
|
110
|
+
# Authentication failed
|
|
111
|
+
if has_token:
|
|
112
|
+
return "Authentication failed: Invalid token"
|
|
113
|
+
else:
|
|
114
|
+
return "Authentication failed: Invalid username or API key"
|
|
115
|
+
elif response.status_code == 403:
|
|
116
|
+
return """Access forbidden: check permissions and verify the credentials you provided.
|
|
117
|
+
Most probably you provided incorrect credentials (user name and api key or token)"""
|
|
118
|
+
elif response.status_code == 404:
|
|
119
|
+
return "Confluence API endpoint not found: verify the Confluence URL"
|
|
120
|
+
else:
|
|
121
|
+
return f"Confluence API returned status code {response.status_code}"
|
|
122
|
+
|
|
123
|
+
except requests.exceptions.SSLError as e:
|
|
124
|
+
return f"SSL certificate verification failed: {str(e)}"
|
|
125
|
+
except requests.exceptions.ConnectionError:
|
|
126
|
+
return f"Cannot connect to Confluence at {base_url}: connection refused"
|
|
127
|
+
except requests.exceptions.Timeout:
|
|
128
|
+
return f"Connection to Confluence at {base_url} timed out"
|
|
129
|
+
except requests.exceptions.RequestException as e:
|
|
130
|
+
return f"Error connecting to Confluence: {str(e)}"
|
|
131
|
+
except Exception as e:
|
|
132
|
+
return f"Unexpected error: {str(e)}"
|
|
@@ -29,3 +29,82 @@ class GitlabConfiguration(BaseModel):
|
|
|
29
29
|
)
|
|
30
30
|
url: str = Field(description="GitLab URL")
|
|
31
31
|
private_token: SecretStr = Field(description="GitLab private token")
|
|
32
|
+
|
|
33
|
+
@staticmethod
|
|
34
|
+
def check_connection(settings: dict) -> str | None:
|
|
35
|
+
"""
|
|
36
|
+
Check the connection to GitLab.
|
|
37
|
+
|
|
38
|
+
Args:
|
|
39
|
+
settings: Dictionary containing GitLab configuration
|
|
40
|
+
- url: GitLab instance URL (required)
|
|
41
|
+
- private_token: GitLab private token for authentication (required)
|
|
42
|
+
|
|
43
|
+
Returns:
|
|
44
|
+
None if connection successful, error message string if failed
|
|
45
|
+
"""
|
|
46
|
+
import requests
|
|
47
|
+
|
|
48
|
+
# Validate url
|
|
49
|
+
url = settings.get("url", "").strip()
|
|
50
|
+
if not url:
|
|
51
|
+
return "GitLab URL is required"
|
|
52
|
+
|
|
53
|
+
# Normalize URL - remove trailing slashes
|
|
54
|
+
url = url.rstrip("/")
|
|
55
|
+
|
|
56
|
+
# Basic URL validation
|
|
57
|
+
if not url.startswith(("http://", "https://")):
|
|
58
|
+
return "GitLab URL must start with http:// or https://"
|
|
59
|
+
|
|
60
|
+
# Validate private_token
|
|
61
|
+
private_token = settings.get("private_token")
|
|
62
|
+
if not private_token:
|
|
63
|
+
return "GitLab private token is required"
|
|
64
|
+
|
|
65
|
+
# Extract token value if it's a SecretStr
|
|
66
|
+
token_value = private_token.get_secret_value() if hasattr(private_token, 'get_secret_value') else private_token
|
|
67
|
+
|
|
68
|
+
if not token_value or not str(token_value).strip():
|
|
69
|
+
return "GitLab private token cannot be empty"
|
|
70
|
+
|
|
71
|
+
# Test connection using /api/v4/user endpoint
|
|
72
|
+
# This endpoint returns current authenticated user info
|
|
73
|
+
test_url = f"{url}/api/v4/user"
|
|
74
|
+
|
|
75
|
+
# GitLab supports both PRIVATE-TOKEN header and Authorization Bearer
|
|
76
|
+
# Using PRIVATE-TOKEN is GitLab-specific and more explicit
|
|
77
|
+
headers = {
|
|
78
|
+
"PRIVATE-TOKEN": str(token_value).strip()
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
try:
|
|
82
|
+
response = requests.get(
|
|
83
|
+
test_url,
|
|
84
|
+
headers=headers,
|
|
85
|
+
timeout=10
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
# Check response status
|
|
89
|
+
if response.status_code == 200:
|
|
90
|
+
# Successfully connected and authenticated
|
|
91
|
+
return None
|
|
92
|
+
elif response.status_code == 401:
|
|
93
|
+
return "Authentication failed: invalid private token"
|
|
94
|
+
elif response.status_code == 403:
|
|
95
|
+
return "Access forbidden: token lacks required permissions"
|
|
96
|
+
elif response.status_code == 404:
|
|
97
|
+
return "GitLab API endpoint not found: verify the GitLab URL"
|
|
98
|
+
else:
|
|
99
|
+
return f"GitLab API returned status code {response.status_code}"
|
|
100
|
+
|
|
101
|
+
except requests.exceptions.SSLError as e:
|
|
102
|
+
return f"SSL certificate verification failed: {str(e)}"
|
|
103
|
+
except requests.exceptions.ConnectionError:
|
|
104
|
+
return f"Cannot connect to GitLab at {url}: connection refused"
|
|
105
|
+
except requests.exceptions.Timeout:
|
|
106
|
+
return f"Connection to GitLab at {url} timed out"
|
|
107
|
+
except requests.exceptions.RequestException as e:
|
|
108
|
+
return f"Error connecting to GitLab: {str(e)}"
|
|
109
|
+
except Exception as e:
|
|
110
|
+
return f"Unexpected error: {str(e)}"
|
alita_sdk/configurations/jira.py
CHANGED
|
@@ -35,3 +35,106 @@ class JiraConfiguration(BaseModel):
|
|
|
35
35
|
username: Optional[str] = Field(description="Jira Username", default=None)
|
|
36
36
|
api_key: Optional[SecretStr] = Field(description="Jira API Key", default=None)
|
|
37
37
|
token: Optional[SecretStr] = Field(description="Jira Token", default=None)
|
|
38
|
+
|
|
39
|
+
@staticmethod
|
|
40
|
+
def check_connection(settings: dict) -> str | None:
|
|
41
|
+
"""
|
|
42
|
+
Check Jira connection using provided settings.
|
|
43
|
+
Returns None if connection is successful, error message otherwise.
|
|
44
|
+
|
|
45
|
+
Tests authentication by calling the /rest/api/latest/myself endpoint,
|
|
46
|
+
which returns information about the currently authenticated user.
|
|
47
|
+
"""
|
|
48
|
+
import requests
|
|
49
|
+
from requests.auth import HTTPBasicAuth
|
|
50
|
+
|
|
51
|
+
# Extract and validate settings
|
|
52
|
+
base_url = settings.get('base_url', '').rstrip('/')
|
|
53
|
+
username = settings.get('username')
|
|
54
|
+
api_key = settings.get('api_key')
|
|
55
|
+
token = settings.get('token')
|
|
56
|
+
|
|
57
|
+
# Validate base URL
|
|
58
|
+
if not base_url:
|
|
59
|
+
return "Base URL is required"
|
|
60
|
+
|
|
61
|
+
if not base_url.startswith(('http://', 'https://')):
|
|
62
|
+
return "Base URL must start with http:// or https://"
|
|
63
|
+
|
|
64
|
+
# Validate authentication - at least one method must be provided
|
|
65
|
+
has_basic_auth = bool(username and api_key)
|
|
66
|
+
has_token = bool(token and str(token).strip())
|
|
67
|
+
|
|
68
|
+
if not (has_basic_auth or has_token):
|
|
69
|
+
return "Authentication required: Provide either username + API key, or bearer token"
|
|
70
|
+
|
|
71
|
+
# Setup authentication headers
|
|
72
|
+
headers = {'Accept': 'application/json'}
|
|
73
|
+
auth = None
|
|
74
|
+
|
|
75
|
+
if has_token:
|
|
76
|
+
# Bearer token authentication
|
|
77
|
+
token_value = token.get_secret_value() if hasattr(token, 'get_secret_value') else token
|
|
78
|
+
headers['Authorization'] = f'Bearer {token_value}'
|
|
79
|
+
elif has_basic_auth:
|
|
80
|
+
# Basic authentication
|
|
81
|
+
api_key_value = api_key.get_secret_value() if hasattr(api_key, 'get_secret_value') else api_key
|
|
82
|
+
auth = HTTPBasicAuth(username, api_key_value)
|
|
83
|
+
|
|
84
|
+
# Build API endpoint - using 'latest' for version independence
|
|
85
|
+
api_endpoint = f"{base_url}/rest/api/latest/myself"
|
|
86
|
+
|
|
87
|
+
try:
|
|
88
|
+
# Make authenticated request to verify credentials
|
|
89
|
+
response = requests.get(
|
|
90
|
+
api_endpoint,
|
|
91
|
+
headers=headers,
|
|
92
|
+
auth=auth,
|
|
93
|
+
timeout=10
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
# Handle different response codes
|
|
97
|
+
if response.status_code == 200:
|
|
98
|
+
return None # Success - credentials are valid
|
|
99
|
+
|
|
100
|
+
elif response.status_code == 401:
|
|
101
|
+
# Authentication failed
|
|
102
|
+
if has_token:
|
|
103
|
+
return "Authentication failed: Invalid bearer token"
|
|
104
|
+
else:
|
|
105
|
+
return "Authentication failed: Invalid username or API key"
|
|
106
|
+
|
|
107
|
+
elif response.status_code == 403:
|
|
108
|
+
# Authenticated but insufficient permissions
|
|
109
|
+
return "Access forbidden: Your account has insufficient permissions to access Jira API"
|
|
110
|
+
|
|
111
|
+
elif response.status_code == 404:
|
|
112
|
+
# API endpoint not found - likely wrong URL
|
|
113
|
+
return "Jira API endpoint not found: Verify your base URL (e.g., 'https://yourinstance.atlassian.net')"
|
|
114
|
+
|
|
115
|
+
else:
|
|
116
|
+
# Other HTTP errors - try to extract Jira error messages
|
|
117
|
+
error_detail = ""
|
|
118
|
+
try:
|
|
119
|
+
error_json = response.json()
|
|
120
|
+
if 'errorMessages' in error_json and error_json['errorMessages']:
|
|
121
|
+
error_detail = ": " + ", ".join(error_json['errorMessages'])
|
|
122
|
+
elif 'message' in error_json:
|
|
123
|
+
error_detail = f": {error_json['message']}"
|
|
124
|
+
except:
|
|
125
|
+
pass
|
|
126
|
+
|
|
127
|
+
return f"Connection failed with status {response.status_code}{error_detail}"
|
|
128
|
+
|
|
129
|
+
except requests.exceptions.SSLError:
|
|
130
|
+
return "SSL certificate verification failed: Check your Jira URL or network settings"
|
|
131
|
+
except requests.exceptions.ConnectionError:
|
|
132
|
+
return "Connection error: Unable to reach Jira server - check URL and network connectivity"
|
|
133
|
+
except requests.exceptions.Timeout:
|
|
134
|
+
return "Connection timeout: Jira server did not respond within 10 seconds"
|
|
135
|
+
except requests.exceptions.MissingSchema:
|
|
136
|
+
return "Invalid URL format: URL must include protocol (http:// or https://)"
|
|
137
|
+
except requests.exceptions.InvalidURL:
|
|
138
|
+
return "Invalid URL format: Please check your Jira base URL"
|
|
139
|
+
except Exception as e:
|
|
140
|
+
return f"Unexpected error: {str(e)}"
|
|
@@ -19,3 +19,91 @@ class TestRailConfiguration(BaseModel):
|
|
|
19
19
|
url: str = Field(description="Testrail URL")
|
|
20
20
|
email: str = Field(description="TestRail Email")
|
|
21
21
|
password: SecretStr = Field(description="TestRail Password")
|
|
22
|
+
|
|
23
|
+
@staticmethod
|
|
24
|
+
def check_connection(settings: dict) -> str | None:
|
|
25
|
+
"""
|
|
26
|
+
Check the connection to TestRail.
|
|
27
|
+
|
|
28
|
+
Args:
|
|
29
|
+
settings: Dictionary containing TestRail configuration
|
|
30
|
+
- url: TestRail instance URL (required)
|
|
31
|
+
- email: User email for authentication (required)
|
|
32
|
+
- password: Password or API key for authentication (required)
|
|
33
|
+
|
|
34
|
+
Returns:
|
|
35
|
+
None if connection successful, error message string if failed
|
|
36
|
+
"""
|
|
37
|
+
import requests
|
|
38
|
+
from requests.auth import HTTPBasicAuth
|
|
39
|
+
|
|
40
|
+
# Validate url
|
|
41
|
+
url = settings.get("url", "").strip()
|
|
42
|
+
if not url:
|
|
43
|
+
return "TestRail URL is required"
|
|
44
|
+
|
|
45
|
+
# Normalize URL - remove trailing slashes
|
|
46
|
+
url = url.rstrip("/")
|
|
47
|
+
|
|
48
|
+
# Basic URL validation
|
|
49
|
+
if not url.startswith(("http://", "https://")):
|
|
50
|
+
return "TestRail URL must start with http:// or https://"
|
|
51
|
+
|
|
52
|
+
# Validate email
|
|
53
|
+
email = settings.get("email", "").strip()
|
|
54
|
+
if not email:
|
|
55
|
+
return "TestRail email is required"
|
|
56
|
+
|
|
57
|
+
# Validate password
|
|
58
|
+
password = settings.get("password")
|
|
59
|
+
if not password:
|
|
60
|
+
return "TestRail password is required"
|
|
61
|
+
|
|
62
|
+
# Extract password value if it's a SecretStr
|
|
63
|
+
password_value = password.get_secret_value() if hasattr(password, 'get_secret_value') else password
|
|
64
|
+
|
|
65
|
+
if not password_value or not password_value.strip():
|
|
66
|
+
return "TestRail password cannot be empty"
|
|
67
|
+
|
|
68
|
+
# Test connection using /index.php?/api/v2/get_user_by_email endpoint
|
|
69
|
+
# This endpoint returns user info and validates authentication
|
|
70
|
+
test_url = f"{url}/index.php?/api/v2/get_user_by_email&email={email}"
|
|
71
|
+
|
|
72
|
+
try:
|
|
73
|
+
response = requests.get(
|
|
74
|
+
test_url,
|
|
75
|
+
auth=HTTPBasicAuth(email, password_value),
|
|
76
|
+
timeout=10
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
# Check response status
|
|
80
|
+
if response.status_code == 200:
|
|
81
|
+
# Successfully connected and authenticated
|
|
82
|
+
return None
|
|
83
|
+
elif response.status_code == 401:
|
|
84
|
+
return "Authentication failed: invalid email or password"
|
|
85
|
+
elif response.status_code == 403:
|
|
86
|
+
return "Access forbidden: check user permissions"
|
|
87
|
+
elif response.status_code == 404:
|
|
88
|
+
return "TestRail API endpoint not found: verify the TestRail URL"
|
|
89
|
+
elif response.status_code == 400:
|
|
90
|
+
# Could be invalid email format or other bad request
|
|
91
|
+
try:
|
|
92
|
+
error_data = response.json()
|
|
93
|
+
error_msg = error_data.get("error", "Bad request")
|
|
94
|
+
return f"Bad request: {error_msg}"
|
|
95
|
+
except:
|
|
96
|
+
return "Bad request: check email format and URL"
|
|
97
|
+
else:
|
|
98
|
+
return f"TestRail API returned status code {response.status_code}"
|
|
99
|
+
|
|
100
|
+
except requests.exceptions.SSLError as e:
|
|
101
|
+
return f"SSL certificate verification failed: {str(e)}"
|
|
102
|
+
except requests.exceptions.ConnectionError:
|
|
103
|
+
return f"Cannot connect to TestRail at {url}: connection refused"
|
|
104
|
+
except requests.exceptions.Timeout:
|
|
105
|
+
return f"Connection to TestRail at {url} timed out"
|
|
106
|
+
except requests.exceptions.RequestException as e:
|
|
107
|
+
return f"Error connecting to TestRail: {str(e)}"
|
|
108
|
+
except Exception as e:
|
|
109
|
+
return f"Unexpected error: {str(e)}"
|
alita_sdk/configurations/xray.py
CHANGED
|
@@ -30,3 +30,96 @@ class XrayConfiguration(BaseModel):
|
|
|
30
30
|
base_url: str = Field(description="Xray URL")
|
|
31
31
|
client_id: Optional[str] = Field(description="Client ID")
|
|
32
32
|
client_secret: Optional[SecretStr] = Field(description="Client secret")
|
|
33
|
+
|
|
34
|
+
@staticmethod
|
|
35
|
+
def check_connection(settings: dict) -> str | None:
|
|
36
|
+
"""
|
|
37
|
+
Check the connection to Xray Cloud.
|
|
38
|
+
|
|
39
|
+
Args:
|
|
40
|
+
settings: Dictionary containing Xray configuration
|
|
41
|
+
- base_url: Xray Cloud URL (required)
|
|
42
|
+
- client_id: OAuth2 Client ID (required)
|
|
43
|
+
- client_secret: OAuth2 Client Secret (required)
|
|
44
|
+
|
|
45
|
+
Returns:
|
|
46
|
+
None if connection successful, error message string if failed
|
|
47
|
+
"""
|
|
48
|
+
import requests
|
|
49
|
+
|
|
50
|
+
# Validate base_url
|
|
51
|
+
base_url = settings.get("base_url", "").strip()
|
|
52
|
+
if not base_url:
|
|
53
|
+
return "Xray URL is required"
|
|
54
|
+
|
|
55
|
+
# Normalize URL - remove trailing slashes
|
|
56
|
+
base_url = base_url.rstrip("/")
|
|
57
|
+
|
|
58
|
+
# Basic URL validation
|
|
59
|
+
if not base_url.startswith(("http://", "https://")):
|
|
60
|
+
return "Xray URL must start with http:// or https://"
|
|
61
|
+
|
|
62
|
+
# Validate client_id
|
|
63
|
+
client_id = settings.get("client_id", "").strip() if settings.get("client_id") else ""
|
|
64
|
+
if not client_id:
|
|
65
|
+
return "Xray client ID is required"
|
|
66
|
+
|
|
67
|
+
# Validate client_secret
|
|
68
|
+
client_secret = settings.get("client_secret")
|
|
69
|
+
if not client_secret:
|
|
70
|
+
return "Xray client secret is required"
|
|
71
|
+
|
|
72
|
+
# Extract client_secret value if it's a SecretStr
|
|
73
|
+
client_secret_value = client_secret.get_secret_value() if hasattr(client_secret, 'get_secret_value') else client_secret
|
|
74
|
+
|
|
75
|
+
if not client_secret_value or not str(client_secret_value).strip():
|
|
76
|
+
return "Xray client secret cannot be empty"
|
|
77
|
+
|
|
78
|
+
# Test connection using /api/v2/authenticate endpoint
|
|
79
|
+
# This is the OAuth2 token generation endpoint for Xray Cloud
|
|
80
|
+
auth_url = f"{base_url}/api/v2/authenticate"
|
|
81
|
+
|
|
82
|
+
auth_payload = {
|
|
83
|
+
"client_id": client_id,
|
|
84
|
+
"client_secret": str(client_secret_value).strip()
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
try:
|
|
88
|
+
response = requests.post(
|
|
89
|
+
auth_url,
|
|
90
|
+
json=auth_payload,
|
|
91
|
+
headers={"Content-Type": "application/json"},
|
|
92
|
+
timeout=10
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
# Check response status
|
|
96
|
+
if response.status_code == 200:
|
|
97
|
+
# Successfully authenticated and got token
|
|
98
|
+
return None
|
|
99
|
+
elif response.status_code == 401:
|
|
100
|
+
return "Authentication failed: invalid client ID or secret"
|
|
101
|
+
elif response.status_code == 403:
|
|
102
|
+
return "Access forbidden: check client credentials"
|
|
103
|
+
elif response.status_code == 400:
|
|
104
|
+
# Bad request - could be invalid format
|
|
105
|
+
try:
|
|
106
|
+
error_data = response.json()
|
|
107
|
+
error_msg = error_data.get("error", "Bad request")
|
|
108
|
+
return f"Bad request: {error_msg}"
|
|
109
|
+
except:
|
|
110
|
+
return "Bad request: check client ID and secret format"
|
|
111
|
+
elif response.status_code == 404:
|
|
112
|
+
return "Xray API endpoint not found: verify the Xray URL"
|
|
113
|
+
else:
|
|
114
|
+
return f"Xray API returned status code {response.status_code}"
|
|
115
|
+
|
|
116
|
+
except requests.exceptions.SSLError as e:
|
|
117
|
+
return f"SSL certificate verification failed: {str(e)}"
|
|
118
|
+
except requests.exceptions.ConnectionError:
|
|
119
|
+
return f"Cannot connect to Xray at {base_url}: connection refused"
|
|
120
|
+
except requests.exceptions.Timeout:
|
|
121
|
+
return f"Connection to Xray at {base_url} timed out"
|
|
122
|
+
except requests.exceptions.RequestException as e:
|
|
123
|
+
return f"Error connecting to Xray: {str(e)}"
|
|
124
|
+
except Exception as e:
|
|
125
|
+
return f"Unexpected error: {str(e)}"
|
|
@@ -18,3 +18,96 @@ class ZephyrEnterpriseConfiguration(BaseModel):
|
|
|
18
18
|
)
|
|
19
19
|
base_url: str = Field(description="Zephyr base URL")
|
|
20
20
|
token: Optional[SecretStr] = Field(description="API token")
|
|
21
|
+
|
|
22
|
+
@staticmethod
|
|
23
|
+
def check_connection(settings: dict) -> str | None:
|
|
24
|
+
"""
|
|
25
|
+
Check the connection to Zephyr Enterprise.
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
settings: Dictionary containing Zephyr Enterprise configuration
|
|
29
|
+
- base_url: Zephyr Enterprise instance URL (required)
|
|
30
|
+
- token: API token for authentication (optional, anonymous access possible)
|
|
31
|
+
|
|
32
|
+
Returns:
|
|
33
|
+
None if connection successful, error message string if failed
|
|
34
|
+
"""
|
|
35
|
+
import requests
|
|
36
|
+
|
|
37
|
+
# Validate base_url
|
|
38
|
+
base_url = settings.get("base_url", "").strip()
|
|
39
|
+
if not base_url:
|
|
40
|
+
return "Zephyr Enterprise URL is required"
|
|
41
|
+
|
|
42
|
+
# Normalize URL - remove trailing slashes
|
|
43
|
+
base_url = base_url.rstrip("/")
|
|
44
|
+
|
|
45
|
+
# Basic URL validation
|
|
46
|
+
if not base_url.startswith(("http://", "https://")):
|
|
47
|
+
return "Zephyr Enterprise URL must start with http:// or https://"
|
|
48
|
+
|
|
49
|
+
# Get token (optional)
|
|
50
|
+
token = settings.get("token")
|
|
51
|
+
|
|
52
|
+
# Prepare headers
|
|
53
|
+
headers = {}
|
|
54
|
+
has_token = False
|
|
55
|
+
if token:
|
|
56
|
+
# Extract token value if it's a SecretStr
|
|
57
|
+
token_value = token.get_secret_value() if hasattr(token, 'get_secret_value') else token
|
|
58
|
+
if token_value and str(token_value).strip():
|
|
59
|
+
headers["Authorization"] = f"Bearer {str(token_value).strip()}"
|
|
60
|
+
has_token = True
|
|
61
|
+
|
|
62
|
+
# Use different endpoints based on whether authentication is provided
|
|
63
|
+
# Note: /healthcheck may allow anonymous access, so we use authenticated endpoints when token is provided
|
|
64
|
+
if has_token:
|
|
65
|
+
# Test with an endpoint that requires authentication: /flex/services/rest/latest/project
|
|
66
|
+
# This endpoint lists projects and requires proper authentication
|
|
67
|
+
test_url = f"{base_url}/flex/services/rest/latest/user/current"
|
|
68
|
+
else:
|
|
69
|
+
# Without token, test basic connectivity with healthcheck
|
|
70
|
+
test_url = f"{base_url}/flex/services/rest/latest/healthcheck"
|
|
71
|
+
|
|
72
|
+
try:
|
|
73
|
+
response = requests.get(
|
|
74
|
+
test_url,
|
|
75
|
+
headers=headers,
|
|
76
|
+
timeout=10
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
# Check response status
|
|
80
|
+
if response.status_code == 200:
|
|
81
|
+
# Successfully connected
|
|
82
|
+
return None
|
|
83
|
+
elif response.status_code == 401:
|
|
84
|
+
if has_token:
|
|
85
|
+
return "Authentication failed: invalid API token"
|
|
86
|
+
else:
|
|
87
|
+
return "Authentication required: provide API token"
|
|
88
|
+
elif response.status_code == 403:
|
|
89
|
+
return "Access forbidden: check token permissions"
|
|
90
|
+
elif response.status_code == 404:
|
|
91
|
+
# If user endpoint not found, try healthcheck as fallback
|
|
92
|
+
if has_token:
|
|
93
|
+
try:
|
|
94
|
+
fallback_url = f"{base_url}/flex/services/rest/latest/healthcheck"
|
|
95
|
+
fallback_response = requests.get(fallback_url, headers=headers, timeout=10)
|
|
96
|
+
if fallback_response.status_code == 200:
|
|
97
|
+
return None
|
|
98
|
+
except:
|
|
99
|
+
pass
|
|
100
|
+
return "Zephyr Enterprise API endpoint not found: verify the Zephyr URL"
|
|
101
|
+
else:
|
|
102
|
+
return f"Zephyr Enterprise API returned status code {response.status_code}"
|
|
103
|
+
|
|
104
|
+
except requests.exceptions.SSLError as e:
|
|
105
|
+
return f"SSL certificate verification failed: {str(e)}"
|
|
106
|
+
except requests.exceptions.ConnectionError:
|
|
107
|
+
return f"Cannot connect to Zephyr Enterprise at {base_url}: connection refused"
|
|
108
|
+
except requests.exceptions.Timeout:
|
|
109
|
+
return f"Connection to Zephyr Enterprise at {base_url} timed out"
|
|
110
|
+
except requests.exceptions.RequestException as e:
|
|
111
|
+
return f"Error connecting to Zephyr Enterprise: {str(e)}"
|
|
112
|
+
except Exception as e:
|
|
113
|
+
return f"Unexpected error: {str(e)}"
|