swiftype-app-search 0.4.2 → 0.4.4
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 +1 -1
- data/lib/swiftype-app-search/client.rb +0 -1
- data/lib/swiftype-app-search/version.rb +1 -1
- data/spec/client_spec.rb +20 -0
- 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: 236cc084c39977f3fff52da0695f9d90e66c3209a7596d9ca6805239828be122
|
4
|
+
data.tar.gz: dabefe87c883d2aad2a6991140e03b4dbfc1c6e8a78c0903e9a90dbe25065f72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86c5e5978343a171276ef98d8b84fb6e780a32781d27486d7b172b0d0d64a1864441a0d0cb1ff8322851483e6163bc269df79a6bfda0aa094e3f2ebc75c41935
|
7
|
+
data.tar.gz: 12650e7cd5ff571ebe6243824bb4caa07205a8e8889c45fb07b5ac6e1d32bb75f89b48c4f08923335910c2be598697bf1cb90417f7d5fb1d948688725181ac8c
|
data/README.md
CHANGED
@@ -10,7 +10,7 @@ To install the gem, execute:
|
|
10
10
|
gem install swiftype-app-search
|
11
11
|
```
|
12
12
|
|
13
|
-
Or place `gem 'swiftype-app-search', '~> 0.4.
|
13
|
+
Or place `gem 'swiftype-app-search', '~> 0.4.4` in your `Gemfile` and run `bundle install`.
|
14
14
|
|
15
15
|
## Usage
|
16
16
|
|
@@ -43,7 +43,6 @@ module SwiftypeAppSearch
|
|
43
43
|
#
|
44
44
|
# @return [String] the JWT to use for authentication
|
45
45
|
def create_signed_search_key(api_key, api_key_name, options = {})
|
46
|
-
raise 'Must create signed search key with an API Key, cannot use a Search Key' unless api_key.start_with?('api')
|
47
46
|
payload = Utils.symbolize_keys(options).merge(:api_key_name => api_key_name)
|
48
47
|
JWT.encode(payload, api_key, ALGORITHM)
|
49
48
|
end
|
data/spec/client_spec.rb
CHANGED
@@ -37,6 +37,26 @@ describe SwiftypeAppSearch::Client do
|
|
37
37
|
@static_client.destroy_engine(@static_engine_name)
|
38
38
|
end
|
39
39
|
|
40
|
+
describe '#create_signed_search_key' do
|
41
|
+
let(:key) { 'private-xxxxxxxxxxxxxxxxxxxx' }
|
42
|
+
let(:api_key_name) { 'private-key' }
|
43
|
+
let(:enforced_options) do
|
44
|
+
{
|
45
|
+
'query' => 'cat'
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
subject do
|
50
|
+
SwiftypeAppSearch::Client.create_signed_search_key(key, api_key_name, enforced_options)
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should build a valid jwt' do
|
54
|
+
decoded_token = JWT.decode subject, key, true, { algorithm: 'HS256' }
|
55
|
+
expect(decoded_token[0]['api_key_name']).to eq(api_key_name)
|
56
|
+
expect(decoded_token[0]['query']).to eq('cat')
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
40
60
|
describe 'Requests' do
|
41
61
|
it 'should include client name and version in headers' do
|
42
62
|
stub_request(:any, "#{client_options[:host_identifier]}.api.swiftype.com/api/as/v1/engines")
|