leantesting 1.0.1 → 1.0.2
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.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/leantesting.gemspec +1 -1
- data/lib/BaseClass/APIRequest.rb +154 -151
- data/lib/BaseClass/Entity.rb +25 -24
- data/lib/BaseClass/EntityHandler.rb +151 -149
- data/lib/BaseClass/EntityList.rb +163 -161
- data/lib/Entity/Bug/Bug.rb +10 -8
- data/lib/Entity/Bug/BugAttachment.rb +7 -5
- data/lib/Entity/Bug/BugComment.rb +7 -5
- data/lib/Entity/Platform/PlatformBrowser.rb +9 -7
- data/lib/Entity/Platform/PlatformBrowserVersion.rb +7 -5
- data/lib/Entity/Platform/PlatformDevice.rb +7 -5
- data/lib/Entity/Platform/PlatformOS.rb +9 -7
- data/lib/Entity/Platform/PlatformOSVersion.rb +7 -5
- data/lib/Entity/Platform/PlatformType.rb +9 -7
- data/lib/Entity/Project/Project.rb +24 -22
- data/lib/Entity/Project/ProjectBugScheme.rb +7 -5
- data/lib/Entity/Project/ProjectSection.rb +7 -5
- data/lib/Entity/Project/ProjectUser.rb +7 -5
- data/lib/Entity/Project/ProjectVersion.rb +7 -5
- data/lib/Entity/User/UserOrganization.rb +7 -5
- data/lib/Exception/BaseException/SDKException.rb +15 -13
- data/lib/Exception/SDKBadJSONResponseException.rb +13 -11
- data/lib/Exception/SDKDuplicateRequestException.rb +15 -13
- data/lib/Exception/SDKErrorResponseException.rb +12 -10
- data/lib/Exception/SDKIncompleteRequestException.rb +15 -13
- data/lib/Exception/SDKInvalidArgException.rb +13 -11
- data/lib/Exception/SDKMissingArgException.rb +13 -11
- data/lib/Exception/SDKUnexpectedResponseException.rb +13 -11
- data/lib/Exception/SDKUnsupportedRequestException.rb +15 -13
- data/lib/Handler/Attachment/AttachmentsHandler.rb +14 -12
- data/lib/Handler/Auth/OAuth2Handler.rb +102 -100
- data/lib/Handler/Bug/BugAttachmentsHandler.rb +44 -42
- data/lib/Handler/Bug/BugCommentsHandler.rb +16 -14
- data/lib/Handler/Bug/BugsHandler.rb +53 -51
- data/lib/Handler/Platform/PlatformBrowserVersionsHandler.rb +16 -14
- data/lib/Handler/Platform/PlatformBrowsersHandler.rb +18 -16
- data/lib/Handler/Platform/PlatformDevicesHandler.rb +9 -7
- data/lib/Handler/Platform/PlatformHandler.rb +20 -18
- data/lib/Handler/Platform/PlatformOSHandler.rb +18 -16
- data/lib/Handler/Platform/PlatformOSVersionsHandler.rb +16 -14
- data/lib/Handler/Platform/PlatformTypeDevicesHandler.rb +16 -14
- data/lib/Handler/Platform/PlatformTypesHandler.rb +17 -15
- data/lib/Handler/Project/ProjectBugReproducibilitySchemeHandler.rb +16 -14
- data/lib/Handler/Project/ProjectBugSeveritySchemeHandler.rb +16 -14
- data/lib/Handler/Project/ProjectBugStatusSchemeHandler.rb +16 -14
- data/lib/Handler/Project/ProjectBugTypeSchemeHandler.rb +16 -14
- data/lib/Handler/Project/ProjectBugsHandler.rb +55 -53
- data/lib/Handler/Project/ProjectSectionsHandler.rb +30 -28
- data/lib/Handler/Project/ProjectUsersHandler.rb +16 -14
- data/lib/Handler/Project/ProjectVersionsHandler.rb +30 -28
- data/lib/Handler/Project/ProjectsHandler.rb +34 -32
- data/lib/Handler/User/UserHandler.rb +12 -10
- data/lib/Handler/User/UserOrganizationsHandler.rb +12 -10
- data/tests/APIRequestTest.rb +33 -33
- data/tests/BaseClassesTest.rb +28 -28
- data/tests/ClientTest.rb +7 -7
- data/tests/EntitiesTest.rb +31 -31
- data/tests/EntityListTest.rb +13 -13
- data/tests/ExceptionsTest.rb +15 -15
- data/tests/HandlersRequestsTest.rb +37 -37
- data/tests/MockRequestsTest.rb +48 -48
- data/tests/OAuth2HandlerTest.rb +19 -19
- metadata +2 -1
@@ -1,17 +1,19 @@
|
|
1
|
-
|
1
|
+
module LeanTesting
|
2
|
+
class AttachmentsHandler < LeanTesting::EntityHandler
|
2
3
|
|
3
|
-
|
4
|
-
|
4
|
+
def find(id)
|
5
|
+
super
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
7
|
+
req = APIRequest.new(@origin, '/v1/attachments/' + id.to_s(), 'GET')
|
8
|
+
BugAttachment.new(@origin, req.exec)
|
9
|
+
end
|
9
10
|
|
10
|
-
|
11
|
-
|
11
|
+
def delete(id)
|
12
|
+
super
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
14
|
+
req = APIRequest.new(@origin, '/v1/attachments/' + id.to_s(), 'DELETE')
|
15
|
+
req.exec
|
16
|
+
end
|
16
17
|
|
17
|
-
end
|
18
|
+
end
|
19
|
+
end
|
@@ -3,116 +3,118 @@
|
|
3
3
|
#
|
4
4
|
# leantesting.com/en/api-docs#oauth-flow
|
5
5
|
#
|
6
|
-
|
6
|
+
module LeanTesting
|
7
|
+
class OAuth2Handler
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
|
-
#
|
19
|
-
# Function that generates link for user to follow in order to request authorization code
|
20
|
-
#
|
21
|
-
# Arguments:
|
22
|
-
# clientID String -- client ID given at application registration
|
23
|
-
# redirectURI String -- URL to be redirected to after authorization
|
24
|
-
# scope String -- (optional) comma-separated list of requested scopes (default: 'read')
|
25
|
-
# state String -- (optional) random string for MITM attack prevention
|
26
|
-
#
|
27
|
-
# Exceptions:
|
28
|
-
# SDKInvalidArgException if provided clientID param is not a string
|
29
|
-
# SDKInvalidArgException if provided redirectURI param is not a string
|
30
|
-
# SDKInvalidArgException if provided scope param is not a string
|
31
|
-
# SDKInvalidArgException if provided state param is not a string
|
32
|
-
#
|
33
|
-
# Returns:
|
34
|
-
# String -- returns URL to follow for authorization code request
|
35
|
-
#
|
36
|
-
def generateAuthLink(clientID, redirectURI, scope = 'read', state = nil)
|
37
|
-
if !clientID.is_a? String
|
38
|
-
raise SDKInvalidArgException, '`clientID` must be a string'
|
39
|
-
elsif !redirectURI.is_a? String
|
40
|
-
raise SDKInvalidArgException, '`redirectURI` must be a string'
|
41
|
-
elsif !scope.is_a? String
|
42
|
-
raise SDKInvalidArgException, '`scope` must be a string'
|
43
|
-
elsif state && !state.is_a?(String)
|
44
|
-
raise SDKInvalidArgException, '`state` must be a string'
|
9
|
+
#
|
10
|
+
# Constructs an OAuth2Handler instance
|
11
|
+
#
|
12
|
+
# Arguments:
|
13
|
+
# origin Client -- Originating client reference
|
14
|
+
#
|
15
|
+
def initialize(origin)
|
16
|
+
@origin = origin
|
45
17
|
end
|
46
18
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
19
|
+
#
|
20
|
+
# Function that generates link for user to follow in order to request authorization code
|
21
|
+
#
|
22
|
+
# Arguments:
|
23
|
+
# clientID String -- client ID given at application registration
|
24
|
+
# redirectURI String -- URL to be redirected to after authorization
|
25
|
+
# scope String -- (optional) comma-separated list of requested scopes (default: 'read')
|
26
|
+
# state String -- (optional) random string for MITM attack prevention
|
27
|
+
#
|
28
|
+
# Exceptions:
|
29
|
+
# SDKInvalidArgException if provided clientID param is not a string
|
30
|
+
# SDKInvalidArgException if provided redirectURI param is not a string
|
31
|
+
# SDKInvalidArgException if provided scope param is not a string
|
32
|
+
# SDKInvalidArgException if provided state param is not a string
|
33
|
+
#
|
34
|
+
# Returns:
|
35
|
+
# String -- returns URL to follow for authorization code request
|
36
|
+
#
|
37
|
+
def generateAuthLink(clientID, redirectURI, scope = 'read', state = nil)
|
38
|
+
if !clientID.is_a? String
|
39
|
+
raise SDKInvalidArgException, '`clientID` must be a string'
|
40
|
+
elsif !redirectURI.is_a? String
|
41
|
+
raise SDKInvalidArgException, '`redirectURI` must be a string'
|
42
|
+
elsif !scope.is_a? String
|
43
|
+
raise SDKInvalidArgException, '`scope` must be a string'
|
44
|
+
elsif state && !state.is_a?(String)
|
45
|
+
raise SDKInvalidArgException, '`state` must be a string'
|
46
|
+
end
|
54
47
|
|
55
|
-
|
56
|
-
params['state'] = state
|
57
|
-
end
|
48
|
+
baseURL = 'https://leantesting.com/login/oauth/authorize'
|
58
49
|
|
59
|
-
|
60
|
-
|
61
|
-
|
50
|
+
params = {
|
51
|
+
'client_id' => clientID,
|
52
|
+
'redirect_uri' => redirectURI,
|
53
|
+
'scope' => scope
|
54
|
+
}
|
62
55
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
# Arguments:
|
67
|
-
# clientID String -- client ID given at application registration
|
68
|
-
# clientSecret String -- client secret given at application registration
|
69
|
-
# grantType String -- oauth specific grant_type value (i.e.: authorization_code)
|
70
|
-
# code String -- authorization code obtained from the generated auth link
|
71
|
-
# redirectURI String -- URL to be redirected to after authorization
|
56
|
+
if state
|
57
|
+
params['state'] = state
|
58
|
+
end
|
72
59
|
|
73
|
-
|
74
|
-
|
75
|
-
# SDKInvalidArgException if provided clientSecret param is not a string
|
76
|
-
# SDKInvalidArgException if provided grantType param is not a string
|
77
|
-
# SDKInvalidArgException if provided code param is not a string
|
78
|
-
# SDKInvalidArgException if provided redirectURI param is not a string
|
79
|
-
#
|
80
|
-
# Returns:
|
81
|
-
# String -- returns obtained access token string
|
82
|
-
#
|
83
|
-
def exchangeAuthCode(clientID, clientSecret, grantType, code, redirectURI)
|
84
|
-
if !clientID.is_a? String
|
85
|
-
raise SDKInvalidArgException, '`clientID` must be a string'
|
86
|
-
elsif !clientSecret.is_a? String
|
87
|
-
raise SDKInvalidArgException, '`clientSecret` must be a string'
|
88
|
-
elsif !grantType.is_a? String
|
89
|
-
raise SDKInvalidArgException, '`grantType` must be a string'
|
90
|
-
elsif !code.is_a? String
|
91
|
-
raise SDKInvalidArgException, '`code` must be a string'
|
92
|
-
elsif !redirectURI.is_a? String
|
93
|
-
raise SDKInvalidArgException, '`redirectURI` must be a string'
|
60
|
+
baseURL += '?' + Curl::postalize(params)
|
61
|
+
baseURL
|
94
62
|
end
|
95
63
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
64
|
+
#
|
65
|
+
# Generates an access token string from the provided authorization code
|
66
|
+
#
|
67
|
+
# Arguments:
|
68
|
+
# clientID String -- client ID given at application registration
|
69
|
+
# clientSecret String -- client secret given at application registration
|
70
|
+
# grantType String -- oauth specific grant_type value (i.e.: authorization_code)
|
71
|
+
# code String -- authorization code obtained from the generated auth link
|
72
|
+
# redirectURI String -- URL to be redirected to after authorization
|
103
73
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
74
|
+
# Exceptions:
|
75
|
+
# SDKInvalidArgException if provided clientID param is not a string
|
76
|
+
# SDKInvalidArgException if provided clientSecret param is not a string
|
77
|
+
# SDKInvalidArgException if provided grantType param is not a string
|
78
|
+
# SDKInvalidArgException if provided code param is not a string
|
79
|
+
# SDKInvalidArgException if provided redirectURI param is not a string
|
80
|
+
#
|
81
|
+
# Returns:
|
82
|
+
# String -- returns obtained access token string
|
83
|
+
#
|
84
|
+
def exchangeAuthCode(clientID, clientSecret, grantType, code, redirectURI)
|
85
|
+
if !clientID.is_a? String
|
86
|
+
raise SDKInvalidArgException, '`clientID` must be a string'
|
87
|
+
elsif !clientSecret.is_a? String
|
88
|
+
raise SDKInvalidArgException, '`clientSecret` must be a string'
|
89
|
+
elsif !grantType.is_a? String
|
90
|
+
raise SDKInvalidArgException, '`grantType` must be a string'
|
91
|
+
elsif !code.is_a? String
|
92
|
+
raise SDKInvalidArgException, '`code` must be a string'
|
93
|
+
elsif !redirectURI.is_a? String
|
94
|
+
raise SDKInvalidArgException, '`redirectURI` must be a string'
|
95
|
+
end
|
96
|
+
|
97
|
+
params = {
|
98
|
+
'grant_type' => grantType,
|
99
|
+
'client_id' => clientID,
|
100
|
+
'client_secret' => clientSecret,
|
101
|
+
'redirect_uri' => redirectURI,
|
102
|
+
'code' => code
|
111
103
|
}
|
112
|
-
)
|
113
104
|
|
114
|
-
|
115
|
-
|
116
|
-
|
105
|
+
req = APIRequest.new(
|
106
|
+
@origin,
|
107
|
+
'/login/oauth/access_token',
|
108
|
+
'POST',
|
109
|
+
{
|
110
|
+
'base_uri' => 'https://leantesting.com',
|
111
|
+
'params' => params
|
112
|
+
}
|
113
|
+
)
|
117
114
|
|
118
|
-
|
115
|
+
resp = req.exec
|
116
|
+
resp['access_token']
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
120
|
+
end
|
@@ -1,51 +1,53 @@
|
|
1
|
-
|
1
|
+
module LeanTesting
|
2
|
+
class BugAttachmentsHandler < LeanTesting::EntityHandler
|
2
3
|
|
3
|
-
|
4
|
-
|
4
|
+
def initialize(origin, bugID)
|
5
|
+
super(origin)
|
5
6
|
|
6
|
-
|
7
|
-
|
7
|
+
@bugID = bugID
|
8
|
+
end
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
10
|
+
#
|
11
|
+
# Uploads given file as an attachment for specified bug.
|
12
|
+
#
|
13
|
+
# Arguments:
|
14
|
+
# filepath String -- an absolute path of the file to be uploaded
|
15
|
+
# example: /home/path/to/file.txt (Linux), C:\\Users\\Documents\\file.txt (Windows)
|
16
|
+
#
|
17
|
+
# Exceptions:
|
18
|
+
# SDKInvalidArgException if filepath is not a string
|
19
|
+
#
|
20
|
+
# Returns:
|
21
|
+
# BugAttachment -- the newly uploaded attachment
|
22
|
+
#
|
23
|
+
def upload(filepath)
|
24
|
+
if !filepath.is_a? String
|
25
|
+
raise SDKInvalidArgException, '`filepath` must be of type string'
|
26
|
+
end
|
27
|
+
|
28
|
+
req = APIRequest.new(
|
29
|
+
@origin,
|
30
|
+
'/v1/bugs/' + @bugID.to_s() + '/attachments',
|
31
|
+
'POST',
|
32
|
+
{
|
33
|
+
'form_data' => true,
|
34
|
+
'file_path' => filepath
|
35
|
+
}
|
36
|
+
)
|
37
|
+
|
38
|
+
BugAttachment.new(@origin, req.exec)
|
25
39
|
end
|
26
40
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
{
|
32
|
-
'form_data' => true,
|
33
|
-
'file_path' => filepath
|
34
|
-
}
|
35
|
-
)
|
36
|
-
|
37
|
-
BugAttachment.new(@origin, req.exec)
|
38
|
-
end
|
41
|
+
def all(filters = nil)
|
42
|
+
if !filters
|
43
|
+
filters = {}
|
44
|
+
end
|
39
45
|
|
40
|
-
|
41
|
-
if !filters
|
42
|
-
filters = {}
|
43
|
-
end
|
46
|
+
super
|
44
47
|
|
45
|
-
|
48
|
+
request = APIRequest.new(@origin, '/v1/bugs/' + @bugID.to_s() + '/attachments', 'GET')
|
49
|
+
EntityList.new(@origin, request, BugAttachment, filters)
|
50
|
+
end
|
46
51
|
|
47
|
-
request = APIRequest.new(@origin, '/v1/bugs/' + @bugID.to_s() + '/attachments', 'GET')
|
48
|
-
EntityList.new(@origin, request, BugAttachment, filters)
|
49
52
|
end
|
50
|
-
|
51
|
-
end
|
53
|
+
end
|
@@ -1,20 +1,22 @@
|
|
1
|
-
|
1
|
+
module LeanTesting
|
2
|
+
class BugCommentsHandler < LeanTesting::EntityHandler
|
2
3
|
|
3
|
-
|
4
|
-
|
4
|
+
def initialize(origin, bugID)
|
5
|
+
super(origin)
|
5
6
|
|
6
|
-
|
7
|
-
end
|
8
|
-
|
9
|
-
def all(filters = nil)
|
10
|
-
if !filters
|
11
|
-
filters = {}
|
7
|
+
@bugID = bugID
|
12
8
|
end
|
13
9
|
|
14
|
-
|
10
|
+
def all(filters = nil)
|
11
|
+
if !filters
|
12
|
+
filters = {}
|
13
|
+
end
|
15
14
|
|
16
|
-
|
17
|
-
EntityList.new(@origin, request, BugComment, filters)
|
18
|
-
end
|
15
|
+
super
|
19
16
|
|
20
|
-
|
17
|
+
request = APIRequest.new(@origin, '/v1/bugs/' + @bugID.to_s() + '/comments', 'GET')
|
18
|
+
EntityList.new(@origin, request, BugComment, filters)
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -1,57 +1,59 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
'
|
1
|
+
module LeanTesting
|
2
|
+
class BugsHandler < LeanTesting::EntityHandler
|
3
|
+
|
4
|
+
def find(id)
|
5
|
+
super
|
6
|
+
|
7
|
+
req = APIRequest.new(
|
8
|
+
@origin,
|
9
|
+
'/v1/bugs/' + id.to_s(),
|
10
|
+
'GET',
|
11
|
+
{
|
12
|
+
'params' => {
|
13
|
+
'include' => 'steps,platform,attachments,comments,tags'
|
14
|
+
}
|
13
15
|
}
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
16
|
+
)
|
17
|
+
Bug.new(@origin, req.exec)
|
18
|
+
end
|
18
19
|
|
19
|
-
|
20
|
-
|
20
|
+
def delete(id)
|
21
|
+
super
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
23
|
+
req = APIRequest.new(@origin, '/v1/bugs/' + id.to_s(), 'DELETE')
|
24
|
+
req.exec
|
25
|
+
end
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
27
|
+
def update(id, fields)
|
28
|
+
super
|
29
|
+
|
30
|
+
supports = {
|
31
|
+
'title' => false,
|
32
|
+
'status_id' => false,
|
33
|
+
'severity_id' => false,
|
34
|
+
'project_version_id' => false,
|
35
|
+
'project_section_id' => false,
|
36
|
+
'type_id' => false,
|
37
|
+
'assigned_user_id' => false,
|
38
|
+
'description' => false,
|
39
|
+
'expected_results' => false,
|
40
|
+
'steps' => false,
|
41
|
+
'platform' => false
|
42
|
+
# 'device_model' => false,
|
43
|
+
# 'device_model_id' => false,
|
44
|
+
# 'os' => false,
|
45
|
+
# 'os_version' => false,
|
46
|
+
# 'os_version_id' => false,
|
47
|
+
# 'browser_version_id' => false
|
48
|
+
}
|
49
|
+
|
50
|
+
if enforce(fields, supports)
|
51
|
+
fields = {'include' => 'steps,platform'}.merge(fields)
|
52
|
+
|
53
|
+
req = APIRequest.new(@origin, '/v1/bugs/' + id.to_s(), 'PUT', {'params' => fields})
|
54
|
+
Bug.new(@origin, req.exec)
|
55
|
+
end
|
54
56
|
end
|
55
|
-
end
|
56
57
|
|
57
|
-
end
|
58
|
+
end
|
59
|
+
end
|