source_license_sdk 1.0.0 → 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/CHANGELOG.md +19 -0
- data/lib/source_license_sdk/client.rb +22 -22
- data/lib/source_license_sdk/license_validator.rb +2 -0
- data/lib/source_license_sdk/version.rb +1 -1
- data/lib/source_license_sdk.rb +8 -8
- data/source_license_sdk.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 327326a19b59632840583676a679731e351ab0f40bc31c2095f079905b06c299
|
4
|
+
data.tar.gz: 72d845f7bc3eb793cab0aa68d25d1f75333707ee1630109892e05cf918a467f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '08cd20df3c2d5ff12c32ca4e06f95d37929b0360c65fbee3bcdcd54b117997dcba17e2de9734c0dbf02790c71ed683e8aff155901ae5bc26544d31daab2c97c6'
|
7
|
+
data.tar.gz: e92846a2bbcb467ce233e8a5b036e625c7b8628a44d744a828f5d5811f45ffd74de2bfb2550bcbfdfc971ed24a9ca977524e17ff948dfb689c2fa05e3ae58b74
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,25 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
7
|
|
8
|
+
## [1.0.2] - 2025-10-05
|
9
|
+
|
10
|
+
### Changed
|
11
|
+
- Updated gemspec to exclude SL_Ruby_SDK_Test directory from gem builds
|
12
|
+
- Test suite is now available in repository but not included in distributed gem
|
13
|
+
|
14
|
+
## [1.0.1] - 2025-10-05
|
15
|
+
|
16
|
+
### Fixed
|
17
|
+
- Improved test suite reliability and error handling
|
18
|
+
- Fixed nil license key validation test logic
|
19
|
+
- Fixed machine ID activation test edge cases
|
20
|
+
- Enhanced configuration state management in tests
|
21
|
+
|
22
|
+
### Added
|
23
|
+
- Comprehensive test script with 45 test cases covering all SDK functionality
|
24
|
+
- Better error handling for edge cases in license validation and activation
|
25
|
+
- Improved test coverage for network errors and rate limiting scenarios
|
26
|
+
|
8
27
|
## [1.0.0] - 2025-01-05
|
9
28
|
|
10
29
|
### Added
|
@@ -15,7 +15,7 @@ class SourceLicenseSDK::Client
|
|
15
15
|
|
16
16
|
# Validate a license key
|
17
17
|
def validate_license(license_key, machine_id: nil, machine_fingerprint: nil)
|
18
|
-
machine_fingerprint ||= MachineIdentifier.generate_fingerprint if machine_id
|
18
|
+
machine_fingerprint ||= SourceLicenseSDK::MachineIdentifier.generate_fingerprint if machine_id
|
19
19
|
|
20
20
|
path = "/api/license/#{license_key}/validate"
|
21
21
|
params = {}
|
@@ -23,14 +23,14 @@ class SourceLicenseSDK::Client
|
|
23
23
|
params[:machine_fingerprint] = machine_fingerprint if machine_fingerprint
|
24
24
|
|
25
25
|
response = make_request(:get, path, params: params)
|
26
|
-
LicenseValidationResult.new(response)
|
27
|
-
rescue NetworkError => e
|
26
|
+
SourceLicenseSDK::LicenseValidationResult.new(response)
|
27
|
+
rescue SourceLicenseSDK::NetworkError => e
|
28
28
|
handle_network_error(e)
|
29
29
|
end
|
30
30
|
|
31
31
|
# Activate a license on this machine
|
32
32
|
def activate_license(license_key, machine_id:, machine_fingerprint: nil)
|
33
|
-
machine_fingerprint ||= MachineIdentifier.generate_fingerprint
|
33
|
+
machine_fingerprint ||= SourceLicenseSDK::MachineIdentifier.generate_fingerprint
|
34
34
|
|
35
35
|
path = "/api/license/#{license_key}/activate"
|
36
36
|
body = {
|
@@ -39,16 +39,16 @@ class SourceLicenseSDK::Client
|
|
39
39
|
}
|
40
40
|
|
41
41
|
response = make_request(:post, path, body: body)
|
42
|
-
LicenseValidationResult.new(response)
|
43
|
-
rescue NetworkError => e
|
42
|
+
SourceLicenseSDK::LicenseValidationResult.new(response)
|
43
|
+
rescue SourceLicenseSDK::NetworkError => e
|
44
44
|
handle_network_error(e)
|
45
45
|
end
|
46
46
|
|
47
47
|
private
|
48
48
|
|
49
49
|
def validate_config!
|
50
|
-
raise ConfigurationError, 'Server URL is required' unless config.server_url
|
51
|
-
raise ConfigurationError, 'Invalid server URL format' unless valid_url?(config.server_url)
|
50
|
+
raise SourceLicenseSDK::ConfigurationError, 'Server URL is required' unless config.server_url
|
51
|
+
raise SourceLicenseSDK::ConfigurationError, 'Invalid server URL format' unless valid_url?(config.server_url)
|
52
52
|
end
|
53
53
|
|
54
54
|
def valid_url?(url)
|
@@ -115,15 +115,15 @@ class SourceLicenseSDK::Client
|
|
115
115
|
raise_license_error(data, response.code.to_i)
|
116
116
|
when 404
|
117
117
|
data = parse_json_response(response.body)
|
118
|
-
raise LicenseNotFoundError, data['error'] || 'License not found'
|
118
|
+
raise SourceLicenseSDK::LicenseNotFoundError, data['error'] || 'License not found'
|
119
119
|
when 429
|
120
120
|
data = parse_json_response(response.body)
|
121
121
|
retry_after = response['Retry-After']&.to_i || data['retry_after']
|
122
|
-
raise RateLimitError.new(data['error'] || 'Rate limit exceeded', retry_after: retry_after)
|
122
|
+
raise SourceLicenseSDK::RateLimitError.new(data['error'] || 'Rate limit exceeded', retry_after: retry_after)
|
123
123
|
when 500..599
|
124
|
-
raise NetworkError.new('Server error occurred', response_code: response.code.to_i, response_body: response.body)
|
124
|
+
raise SourceLicenseSDK::NetworkError.new('Server error occurred', response_code: response.code.to_i, response_body: response.body)
|
125
125
|
else
|
126
|
-
raise NetworkError.new("Unexpected response: #{response.code}", response_code: response.code.to_i,
|
126
|
+
raise SourceLicenseSDK::NetworkError.new("Unexpected response: #{response.code}", response_code: response.code.to_i,
|
127
127
|
response_body: response.body)
|
128
128
|
end
|
129
129
|
end
|
@@ -133,7 +133,7 @@ class SourceLicenseSDK::Client
|
|
133
133
|
|
134
134
|
JSON.parse(body)
|
135
135
|
rescue JSON::ParserError
|
136
|
-
raise NetworkError.new('Invalid JSON response from server', response_body: body)
|
136
|
+
raise SourceLicenseSDK::NetworkError.new('Invalid JSON response from server', response_body: body)
|
137
137
|
end
|
138
138
|
|
139
139
|
def raise_license_error(data, _status_code)
|
@@ -141,32 +141,32 @@ class SourceLicenseSDK::Client
|
|
141
141
|
|
142
142
|
case error_message.downcase
|
143
143
|
when /expired/
|
144
|
-
raise LicenseExpiredError, error_message
|
144
|
+
raise SourceLicenseSDK::LicenseExpiredError, error_message
|
145
145
|
when /rate limit/
|
146
146
|
retry_after = data['retry_after']
|
147
|
-
raise RateLimitError.new(error_message, retry_after: retry_after)
|
147
|
+
raise SourceLicenseSDK::RateLimitError.new(error_message, retry_after: retry_after)
|
148
148
|
when /not found/
|
149
|
-
raise LicenseNotFoundError, error_message
|
149
|
+
raise SourceLicenseSDK::LicenseNotFoundError, error_message
|
150
150
|
when /activation/
|
151
|
-
raise ActivationError, error_message
|
151
|
+
raise SourceLicenseSDK::ActivationError, error_message
|
152
152
|
else
|
153
|
-
raise LicenseError.new(error_message, error_code: data['error_code'])
|
153
|
+
raise SourceLicenseSDK::LicenseError.new(error_message, error_code: data['error_code'])
|
154
154
|
end
|
155
155
|
end
|
156
156
|
|
157
157
|
def handle_network_error(error)
|
158
158
|
# Convert network errors to license validation results for consistency
|
159
159
|
case error
|
160
|
-
when RateLimitError
|
161
|
-
LicenseValidationResult.new(
|
160
|
+
when SourceLicenseSDK::RateLimitError
|
161
|
+
SourceLicenseSDK::LicenseValidationResult.new(
|
162
162
|
valid: false,
|
163
163
|
success: false,
|
164
164
|
error: error.message,
|
165
165
|
error_code: error.error_code,
|
166
166
|
retry_after: error.retry_after
|
167
167
|
)
|
168
|
-
when LicenseNotFoundError, LicenseExpiredError, ActivationError
|
169
|
-
LicenseValidationResult.new(
|
168
|
+
when SourceLicenseSDK::LicenseNotFoundError, SourceLicenseSDK::LicenseExpiredError, SourceLicenseSDK::ActivationError
|
169
|
+
SourceLicenseSDK::LicenseValidationResult.new(
|
170
170
|
valid: false,
|
171
171
|
success: false,
|
172
172
|
error: error.message,
|
data/lib/source_license_sdk.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'source_license_sdk/version'
|
4
|
-
require_relative 'source_license_sdk/
|
4
|
+
require_relative 'source_license_sdk/exceptions'
|
5
5
|
require_relative 'source_license_sdk/machine_identifier'
|
6
6
|
require_relative 'source_license_sdk/license_validator'
|
7
|
-
require_relative 'source_license_sdk/
|
7
|
+
require_relative 'source_license_sdk/client'
|
8
8
|
|
9
9
|
module SourceLicenseSDK
|
10
10
|
# Configure the SDK with your Source-License server details
|
@@ -31,9 +31,9 @@ module SourceLicenseSDK
|
|
31
31
|
license_key ||= configuration.license_key
|
32
32
|
machine_id ||= configuration.machine_id
|
33
33
|
|
34
|
-
raise ConfigurationError, 'License key is required' if license_key.nil? || license_key.empty?
|
34
|
+
raise SourceLicenseSDK::ConfigurationError, 'License key is required' if license_key.nil? || license_key.empty?
|
35
35
|
|
36
|
-
client = Client.new(configuration)
|
36
|
+
client = SourceLicenseSDK::Client.new(configuration)
|
37
37
|
client.validate_license(license_key, machine_id: machine_id)
|
38
38
|
end
|
39
39
|
|
@@ -41,12 +41,12 @@ module SourceLicenseSDK
|
|
41
41
|
def self.activate_license(license_key = nil, machine_id: nil)
|
42
42
|
license_key ||= configuration.license_key
|
43
43
|
machine_id ||= configuration.machine_id ||
|
44
|
-
(configuration.auto_generate_machine_id ? MachineIdentifier.generate : nil)
|
44
|
+
(configuration.auto_generate_machine_id ? SourceLicenseSDK::MachineIdentifier.generate : nil)
|
45
45
|
|
46
|
-
raise ConfigurationError, 'License key is required' if license_key.nil? || license_key.empty?
|
47
|
-
raise ConfigurationError, 'Machine ID is required for activation' if machine_id.nil? || machine_id.empty?
|
46
|
+
raise SourceLicenseSDK::ConfigurationError, 'License key is required' if license_key.nil? || license_key.empty?
|
47
|
+
raise SourceLicenseSDK::ConfigurationError, 'Machine ID is required for activation' if machine_id.nil? || machine_id.empty?
|
48
48
|
|
49
|
-
client = Client.new(configuration)
|
49
|
+
client = SourceLicenseSDK::Client.new(configuration)
|
50
50
|
client.activate_license(license_key, machine_id: machine_id)
|
51
51
|
end
|
52
52
|
|
data/source_license_sdk.gemspec
CHANGED
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
Gemfile
|
31
31
|
Rakefile
|
32
32
|
source_license_sdk.gemspec
|
33
|
-
]).select { |f| File.file?(f) }
|
33
|
+
]).select { |f| File.file?(f) }.reject { |f| f.match?(/SL_Ruby_SDK_Test/) }
|
34
34
|
spec.bindir = 'exe'
|
35
35
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
36
36
|
spec.require_paths = ['lib']
|