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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 85d734b69f71052d1eb68e6c526c3f2bc68e1ad7209732d125a4ec6f293f8812
4
- data.tar.gz: ac1ccb0a0766e6d72e3abc2cad52d74f49974e23864458ff8cd465a56b532085
3
+ metadata.gz: 236cc084c39977f3fff52da0695f9d90e66c3209a7596d9ca6805239828be122
4
+ data.tar.gz: dabefe87c883d2aad2a6991140e03b4dbfc1c6e8a78c0903e9a90dbe25065f72
5
5
  SHA512:
6
- metadata.gz: 60e66fc6a9014f1001edd89df190a7c40276cb88c1b61ca3a924dc7a2205011efdef1305da0b5fcffa4ceb5c7051e144775f32c22bbbedc59bd89738a43948d8
7
- data.tar.gz: c7d638b3175add10cac77c16999b8a69e0d3cb16bf2a7c1975f5a67a4bac90410fa7c300aae7e457efeef715f7d162c8a7083236bfec6c0aa0fdd500cc2fa447
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.2` in your `Gemfile` and run `bundle install`.
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
@@ -1,3 +1,3 @@
1
1
  module SwiftypeAppSearch
2
- VERSION = '0.4.2'
2
+ VERSION = '0.4.4'
3
3
  end
@@ -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")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swiftype-app-search
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Quin Hoxie