limelm 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +5 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +75 -0
- data/LICENSE.txt +20 -0
- data/README.md +75 -0
- data/Rakefile +50 -0
- data/TODO.md +10 -0
- data/VERSION +1 -0
- data/lib/lime_lm/connection.rb +23 -0
- data/lib/lime_lm/exceptions.rb +6 -0
- data/lib/lime_lm/feature.rb +62 -0
- data/lib/lime_lm/key.rb +83 -0
- data/lib/lime_lm/utils.rb +7 -0
- data/lib/limelm.rb +30 -0
- data/limelm.gemspec +89 -0
- data/spec/fixtures/dish_cassettes/all_features.yml +47 -0
- data/spec/fixtures/dish_cassettes/create_custom_feature.yml +46 -0
- data/spec/fixtures/dish_cassettes/create_detailed_key.yml +46 -0
- data/spec/fixtures/dish_cassettes/create_key_default_configuration.yml +46 -0
- data/spec/fixtures/dish_cassettes/create_key_new_version.yml +46 -0
- data/spec/fixtures/dish_cassettes/create_keys_with_email.yml +46 -0
- data/spec/fixtures/dish_cassettes/create_product_default_feature.yml +46 -0
- data/spec/fixtures/dish_cassettes/default_search.yml +46 -0
- data/spec/fixtures/dish_cassettes/default_search_pagination.yml +46 -0
- data/spec/fixtures/dish_cassettes/destroy_feature.yml +46 -0
- data/spec/fixtures/dish_cassettes/destroy_key.yml +46 -0
- data/spec/fixtures/dish_cassettes/destroy_random_key.yml +47 -0
- data/spec/fixtures/dish_cassettes/details_for_a_given_key.yml +46 -0
- data/spec/fixtures/dish_cassettes/details_for_a_given_key_with_tags.yml +46 -0
- data/spec/fixtures/dish_cassettes/find_keys_by_email.yml +46 -0
- data/spec/fixtures/dish_cassettes/id_for_a_given_key.yml +46 -0
- data/spec/fixtures/dish_cassettes/remove_tag_for_a_given_key.yml +46 -0
- data/spec/fixtures/dish_cassettes/revoke_key.yml +46 -0
- data/spec/fixtures/dish_cassettes/set_tags_for_a_given_key.yml +46 -0
- data/spec/fixtures/dish_cassettes/unrevoke_key.yml +46 -0
- data/spec/fixtures/dish_cassettes/update_custom_feature.yml +46 -0
- data/spec/lib/lime_lm/feature_spec.rb +86 -0
- data/spec/lib/lime_lm/key_spec.rb +212 -0
- data/spec/lib/limelm_spec.rb +37 -0
- data/spec/spec_helper.rb +70 -0
- metadata +142 -0
@@ -0,0 +1,46 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://wyday.com/limelm/api/rest?api_key=new_key_from_yaml&format=json&method=limelm.pkey.revoke&pkey_id=1&revoke=true
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept-Encoding:
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
12
|
+
Accept:
|
13
|
+
- "*/*"
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Server:
|
22
|
+
- nginx
|
23
|
+
Date:
|
24
|
+
- Mon, 02 Mar 2015 17:17:35 GMT
|
25
|
+
Content-Type:
|
26
|
+
- application/json
|
27
|
+
Transfer-Encoding:
|
28
|
+
- chunked
|
29
|
+
Connection:
|
30
|
+
- keep-alive
|
31
|
+
Set-Cookie:
|
32
|
+
- PHPSESSID=4cp2glbm9k5eiauq3cjhgj7s25; path=/
|
33
|
+
Expires:
|
34
|
+
- Thu, 19 Nov 1981 08:52:00 GMT
|
35
|
+
Cache-Control:
|
36
|
+
- no-store, no-cache, must-revalidate, post-check=0, pre-check=0
|
37
|
+
Pragma:
|
38
|
+
- no-cache
|
39
|
+
X-Frame-Options:
|
40
|
+
- SAMEORIGIN
|
41
|
+
body:
|
42
|
+
encoding: UTF-8
|
43
|
+
string: jsonLimeLMApi({"stat":"ok"})
|
44
|
+
http_version:
|
45
|
+
recorded_at: Mon, 02 Mar 2015 17:17:35 GMT
|
46
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,46 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://wyday.com/limelm/api/rest?api_key=new_key_from_yaml&format=json&method=limelm.pkey.setTags&pkey_id=1&tag%5B%5D=demo&tag%5B%5D=enterprise
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept-Encoding:
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
12
|
+
Accept:
|
13
|
+
- "*/*"
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Server:
|
22
|
+
- nginx
|
23
|
+
Date:
|
24
|
+
- Fri, 27 Feb 2015 15:13:17 GMT
|
25
|
+
Content-Type:
|
26
|
+
- application/json
|
27
|
+
Transfer-Encoding:
|
28
|
+
- chunked
|
29
|
+
Connection:
|
30
|
+
- keep-alive
|
31
|
+
Set-Cookie:
|
32
|
+
- PHPSESSID=6tif4d0nffmfevep96tp5m9r71; path=/
|
33
|
+
Expires:
|
34
|
+
- Thu, 19 Nov 1981 08:52:00 GMT
|
35
|
+
Cache-Control:
|
36
|
+
- no-store, no-cache, must-revalidate, post-check=0, pre-check=0
|
37
|
+
Pragma:
|
38
|
+
- no-cache
|
39
|
+
X-Frame-Options:
|
40
|
+
- SAMEORIGIN
|
41
|
+
body:
|
42
|
+
encoding: UTF-8
|
43
|
+
string: jsonLimeLMApi({"stat":"ok"})
|
44
|
+
http_version:
|
45
|
+
recorded_at: Fri, 27 Feb 2015 15:13:17 GMT
|
46
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,46 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://wyday.com/limelm/api/rest?api_key=new_key_from_yaml&format=json&method=limelm.pkey.revoke&pkey_id=1&revoke=false
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept-Encoding:
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
12
|
+
Accept:
|
13
|
+
- "*/*"
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Server:
|
22
|
+
- nginx
|
23
|
+
Date:
|
24
|
+
- Mon, 02 Mar 2015 17:26:17 GMT
|
25
|
+
Content-Type:
|
26
|
+
- application/json
|
27
|
+
Transfer-Encoding:
|
28
|
+
- chunked
|
29
|
+
Connection:
|
30
|
+
- keep-alive
|
31
|
+
Set-Cookie:
|
32
|
+
- PHPSESSID=qe3dcp1vg20ev73mn249ci0d02; path=/
|
33
|
+
Expires:
|
34
|
+
- Thu, 19 Nov 1981 08:52:00 GMT
|
35
|
+
Cache-Control:
|
36
|
+
- no-store, no-cache, must-revalidate, post-check=0, pre-check=0
|
37
|
+
Pragma:
|
38
|
+
- no-cache
|
39
|
+
X-Frame-Options:
|
40
|
+
- SAMEORIGIN
|
41
|
+
body:
|
42
|
+
encoding: UTF-8
|
43
|
+
string: jsonLimeLMApi({"stat":"ok"})
|
44
|
+
http_version:
|
45
|
+
recorded_at: Mon, 02 Mar 2015 17:26:17 GMT
|
46
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,46 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://wyday.com/limelm/api/rest?api_key=new_key_from_yaml&description=updated_description&feature_id=3&format=json&method=limelm.feature.edit&name=updated_name&required=true&ta_readable=false
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept-Encoding:
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
12
|
+
Accept:
|
13
|
+
- "*/*"
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Server:
|
22
|
+
- nginx
|
23
|
+
Date:
|
24
|
+
- Tue, 03 Mar 2015 20:45:39 GMT
|
25
|
+
Content-Type:
|
26
|
+
- application/json
|
27
|
+
Transfer-Encoding:
|
28
|
+
- chunked
|
29
|
+
Connection:
|
30
|
+
- keep-alive
|
31
|
+
Set-Cookie:
|
32
|
+
- PHPSESSID=91fqd0ks6jjcp7ohq7lem5vr45; path=/
|
33
|
+
Expires:
|
34
|
+
- Thu, 19 Nov 1981 08:52:00 GMT
|
35
|
+
Cache-Control:
|
36
|
+
- no-store, no-cache, must-revalidate, post-check=0, pre-check=0
|
37
|
+
Pragma:
|
38
|
+
- no-cache
|
39
|
+
X-Frame-Options:
|
40
|
+
- SAMEORIGIN
|
41
|
+
body:
|
42
|
+
encoding: UTF-8
|
43
|
+
string: jsonLimeLMApi({"stat":"ok"})
|
44
|
+
http_version:
|
45
|
+
recorded_at: Tue, 03 Mar 2015 20:45:39 GMT
|
46
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe LimeLm::Feature do
|
4
|
+
describe '#initialize' do
|
5
|
+
it 'sets default object attributes' do
|
6
|
+
feature = LimeLm::Feature.new({
|
7
|
+
'id' => '1',
|
8
|
+
'name' => 'updates_expires',
|
9
|
+
'type' => 'date_time',
|
10
|
+
'ta_readable' => 'true',
|
11
|
+
'required' => 'false',
|
12
|
+
'description' => "Date when the license key expires."
|
13
|
+
})
|
14
|
+
assert_equal '1', feature.id
|
15
|
+
assert_equal 'updates_expires', feature.name
|
16
|
+
assert_equal 'date_time', feature.type
|
17
|
+
assert feature.ta_readable
|
18
|
+
assert !feature.required
|
19
|
+
assert !feature.description.empty?
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '.all' do
|
24
|
+
it 'returns all the custom license fields for a given product version' do
|
25
|
+
VCR.use_cassette("all_features", match_requests_on: [:path]) do
|
26
|
+
result = LimeLm::Feature.all(version_id: '2')
|
27
|
+
assert_equal 1, result.count
|
28
|
+
feature = result.first
|
29
|
+
assert_instance_of LimeLm::Feature, feature
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '.create' do
|
35
|
+
it 'creates a new product custom license field with a name by default' do
|
36
|
+
VCR.use_cassette("create_product_default_feature", match_requests_on: [:path]) do
|
37
|
+
new_feature_name = 'plan'
|
38
|
+
result = LimeLm::Feature.create(name: new_feature_name)
|
39
|
+
assert_instance_of LimeLm::Feature, result
|
40
|
+
assert_equal '2', result.id
|
41
|
+
assert_equal 'string', result.type
|
42
|
+
assert result.required, 'required by default'
|
43
|
+
assert result.ta_readable, 'readable by default'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'accepts more specified options' do
|
48
|
+
VCR.use_cassette("create_custom_feature", match_requests_on: [:path]) do
|
49
|
+
result = LimeLm::Feature.create(name: 'customized_plan', type: 'int', required: 'false',
|
50
|
+
ta_readable: 'false', description: 'new customized field')
|
51
|
+
assert_equal '3', result.id
|
52
|
+
assert_equal 'customized_plan', result.name
|
53
|
+
assert_equal 'int', result.type
|
54
|
+
assert_equal 'new customized field', result.description
|
55
|
+
assert !result.required
|
56
|
+
assert !result.ta_readable
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe '#update!' do
|
62
|
+
it 'updates features properties and returns true in case of success' do
|
63
|
+
VCR.use_cassette("update_custom_feature", match_requests_on: [:path]) do
|
64
|
+
feature = LimeLm::Feature.new(id: '3')
|
65
|
+
result = feature.update!(name: 'updated_name', required: 'true',
|
66
|
+
ta_readable: 'false', description: 'updated_description')
|
67
|
+
|
68
|
+
assert feature, 'Returns true if update succeed'
|
69
|
+
assert_equal '3', feature.id
|
70
|
+
assert_equal 'updated_name', feature.name
|
71
|
+
assert_equal 'updated_description', feature.description
|
72
|
+
assert feature.required
|
73
|
+
assert !feature.ta_readable
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe '#destroy!' do
|
79
|
+
it 'returns true if the feature has been destroyed' do
|
80
|
+
VCR.use_cassette("destroy_feature", match_requests_on: [:path]) do
|
81
|
+
feature = LimeLm::Feature.new(id: '3')
|
82
|
+
assert feature.destroy!, 'Destroy should work'
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,212 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe LimeLm::Key do
|
4
|
+
describe '#initialize' do
|
5
|
+
it 'raises an error if no id and no product key specified during Object creation' do
|
6
|
+
assert_raises(LimeLm::InvalidObject) { LimeLm::Key.new({}) }
|
7
|
+
LimeLm::Key.new({ 'id' => '1' })
|
8
|
+
LimeLm::Key.new({ 'key' => 'AAAA-BBBB' })
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'sets default object attributes' do
|
12
|
+
key = LimeLm::Key.new({ 'id' => '1', 'key' => 'AAA-BBB', 'version_id' => '1',
|
13
|
+
'email' => 'imberdis.damien@gmail.com' })
|
14
|
+
assert_equal 'imberdis.damien@gmail.com', key.email
|
15
|
+
assert_equal 'AAA-BBB', key.key
|
16
|
+
assert_equal '1', key.version_id
|
17
|
+
assert !key.revoked, 'A key is not revoked by default'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#details' do
|
22
|
+
it 'assigns properties of a key and returns them' do
|
23
|
+
VCR.use_cassette("details_for_a_given_key", match_requests_on: [:path]) do
|
24
|
+
key = LimeLm::Key.new({ 'id' => '1' })
|
25
|
+
result = key.details
|
26
|
+
assert !key.key.empty?, 'Details about a key should reassign the key property'
|
27
|
+
assert !key.email.empty?, 'Details about a key should reassign the email property'
|
28
|
+
assert result.is_a?(Hash), 'All the properties should be returned'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'including all custom license fields and tags' do
|
33
|
+
VCR.use_cassette("details_for_a_given_key_with_tags", match_requests_on: [:path]) do
|
34
|
+
key = LimeLm::Key.new({ 'id' => '1' })
|
35
|
+
result = key.details
|
36
|
+
assert_equal [{"name"=>"enterprise"}, {"name"=>"demo"}], result['tags']['tag']
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#id' do
|
42
|
+
it 'returns the id property if already present in the object' do
|
43
|
+
key = LimeLm::Key.new({ 'id' => '1' })
|
44
|
+
assert_equal '1', key.id
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'calls the API, save the id property and returns it if only the product key is present' do
|
48
|
+
VCR.use_cassette("id_for_a_given_key", match_requests_on: [:path]) do
|
49
|
+
key = LimeLm::Key.new({ 'key' => 'AAAA-BBBB' })
|
50
|
+
assert_equal '1', key.id
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '#tag' do
|
56
|
+
it 'sets a key tags providing an Array' do
|
57
|
+
VCR.use_cassette("set_tags_for_a_given_key", match_requests_on: [:path]) do
|
58
|
+
key = LimeLm::Key.new({ 'id' => '1' })
|
59
|
+
tags = ['demo', 'enterprise']
|
60
|
+
assert key.tag(tags), 'returns true if success'
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe '#remove_tag' do
|
66
|
+
it 'removes the specialized tag' do
|
67
|
+
VCR.use_cassette("remove_tag_for_a_given_key", match_requests_on: [:path]) do
|
68
|
+
key = LimeLm::Key.new({ 'id' => '1' })
|
69
|
+
assert key.remove_tag('demo'), 'returns true if success'
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe '#update' do
|
75
|
+
#TODO: https://wyday.com/limelm/help/api/limelm.pkey.setDetails/
|
76
|
+
end
|
77
|
+
|
78
|
+
describe '#toggle_revoke!' do
|
79
|
+
it 'calls the API and set revoked to true in case of success for a non revoked key' do
|
80
|
+
VCR.use_cassette("revoke_key", match_requests_on: [:path]) do
|
81
|
+
key = LimeLm::Key.new({ 'id' => '1' })
|
82
|
+
assert !key.revoked, 'By default a key is not revoked after its initialization'
|
83
|
+
key.toggle_revoke!
|
84
|
+
assert key.revoked, 'The key is revoked if succeed'
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'calls the API and unrevoke the key' do
|
89
|
+
VCR.use_cassette("unrevoke_key", match_requests_on: [:path]) do
|
90
|
+
key = LimeLm::Key.new({ 'id' => '1', 'revoked' => true })
|
91
|
+
assert key.revoked, 'the key should be revoked'
|
92
|
+
key.toggle_revoke!
|
93
|
+
assert !key.revoked, 'Unrevoke the key'
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
describe '.create' do
|
99
|
+
it 'creates a new default product key' do
|
100
|
+
VCR.use_cassette("create_key_default_configuration", match_requests_on: [:path]) do
|
101
|
+
result = LimeLm::Key.create
|
102
|
+
assert_equal 1, result.count, 'Should build an uniq key by default'
|
103
|
+
new_key = result.first
|
104
|
+
assert_instance_of LimeLm::Key, new_key
|
105
|
+
assert_equal '9', new_key.id
|
106
|
+
assert_equal 'CCCC-BBBB', new_key.key
|
107
|
+
assert new_key.version_id, 'version_id is set to the default configuration'
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'associates keys to an email and can generate more than a key' do
|
112
|
+
VCR.use_cassette("create_keys_with_email", match_requests_on: [:path]) do
|
113
|
+
email = 'imberdis.damien@gmail.com'
|
114
|
+
|
115
|
+
result = LimeLm::Key.create(email: email, num_keys: 2)
|
116
|
+
assert_equal 2, result.count
|
117
|
+
|
118
|
+
first_key, second_key = result.first, result.last
|
119
|
+
assert_instance_of LimeLm::Key, first_key
|
120
|
+
assert_instance_of LimeLm::Key, second_key
|
121
|
+
|
122
|
+
assert_equal email, first_key.email
|
123
|
+
assert_equal email, second_key.email
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
it 'accept more detailed configuration about the limitation of activations/deactivations' do
|
128
|
+
VCR.use_cassette("create_detailed_key", match_requests_on: [:path]) do
|
129
|
+
email = 'imberdis.damien@gmail.com'
|
130
|
+
|
131
|
+
result = LimeLm::Key.create(email: email, num_acts: 5, deact_limit: 2)
|
132
|
+
assert '9', result.first.id
|
133
|
+
assert 'CCCC-EEEE', result.first.key
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
it 'accepts the creation of a new key, specifying a product version_id (not using the default configuration)' do
|
138
|
+
VCR.use_cassette("create_key_new_version", match_requests_on: [:path]) do
|
139
|
+
result = LimeLm::Key.create(version_id: '2')
|
140
|
+
assert_equal '2', result.first.version_id
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
describe '#destroy!' do
|
146
|
+
it 'deletes a key' do
|
147
|
+
VCR.use_cassette("destroy_key", match_requests_on: [:path]) do
|
148
|
+
key_to_destroy = LimeLm::Key.new({ 'id' => '1' })
|
149
|
+
assert key_to_destroy.destroy!, 'Should return true if key deleted'
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
it 'raises error if try to delete a key out of my version_id' do
|
154
|
+
VCR.use_cassette("destroy_random_key", match_requests_on: [:path]) do
|
155
|
+
key_to_destroy = LimeLm::Key.new({ 'id' => '3' })
|
156
|
+
assert_raises(LimeLm::ApiError) { key_to_destroy.destroy! }
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
describe '.find' do
|
162
|
+
it 'returns a list of keys associated with an email' do
|
163
|
+
email = 'imberdis.damien@gmail.com'
|
164
|
+
VCR.use_cassette("find_keys_by_email", match_requests_on: [:path]) do
|
165
|
+
keys = LimeLm::Key.find(email)
|
166
|
+
assert_equal 2, keys.count
|
167
|
+
key = keys.first
|
168
|
+
assert key.is_a?(LimeLm::Key)
|
169
|
+
|
170
|
+
assert key.properties.is_a?(Hash) && !key.properties.empty?, 'All data are stored as a Hash under properties'
|
171
|
+
assert !key.id.empty?, 'A key should contains the id information'
|
172
|
+
assert !key.key.empty?, 'A key should contains the key information'
|
173
|
+
assert !key.version_id.empty?, 'A key as a link to its product version'
|
174
|
+
assert !key.email.empty?, 'A key as a link to the user email provided'
|
175
|
+
assert !key.properties['acts'].empty?, 'A key should contains the total of activations information'
|
176
|
+
assert !key.properties['acts_used'].empty?, 'A key should contains the used activations information'
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
describe '.search' do
|
182
|
+
it 'returns by default 20 keys of all products and versions' do
|
183
|
+
VCR.use_cassette("default_search", match_requests_on: [:path]) do
|
184
|
+
result = LimeLm::Key.search
|
185
|
+
|
186
|
+
# NOTE: the next values are only set for the purpose of a test
|
187
|
+
assert_equal 2, result.count
|
188
|
+
first_key, last_key = result.first, result.last
|
189
|
+
|
190
|
+
assert_instance_of LimeLm::Key, first_key
|
191
|
+
assert_equal '1', first_key.id
|
192
|
+
assert_equal '1', first_key.version_id
|
193
|
+
|
194
|
+
assert_instance_of LimeLm::Key, last_key
|
195
|
+
assert_equal '2', last_key.id
|
196
|
+
assert_equal '4', last_key.version_id
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
it 'paginates the result returned' do
|
201
|
+
VCR.use_cassette("default_search_pagination", match_requests_on: [:path]) do
|
202
|
+
result = LimeLm::Key.search(num: 2, page: 3)
|
203
|
+
assert_equal 2, result.count
|
204
|
+
|
205
|
+
first_key = result.first
|
206
|
+
assert_instance_of LimeLm::Key, first_key
|
207
|
+
assert_equal '10', first_key.id
|
208
|
+
assert_equal '2', first_key.version_id
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|