|
7 | 7 | require 'sinatra' |
8 | 8 | require 'rspec' |
9 | 9 |
|
| 10 | +securenative = SecureNative::Client.init_with_api_key('YOUR_API_KEY') |
| 11 | + |
10 | 12 | RSpec.describe SecureNative::Context do |
11 | 13 | it 'creates context from ruby default request' do |
12 | 14 | stub_request(:any, 'www.example.com') |
13 | 15 | .to_return(status: 200, |
14 | 16 | headers: { '_sn': '71532c1fad2c7f56118f7969e401f3cf080239140d208e7934e6a530818c37e544a0c2330a487bcc6fe4f662a57f265a3ed9f37871e80529128a5e4f2ca02db0fb975ded401398f698f19bb0cafd68a239c6caff99f6f105286ab695eaf3477365bdef524f5d70d9be1d1d474506b433aed05d7ed9a435eeca357de57817b37c638b6bb417ffb101eaf856987615a77a' }) |
15 | 17 |
|
16 | 18 | request = Net::HTTP.get_response('www.example.com', '/') |
17 | | - context = SecureNative::Context.from_http_request(request) |
| 19 | + context = securenative.from_http_request(request) |
18 | 20 |
|
19 | 21 | expect(context.ip).to eq('') |
20 | 22 | expect(context.http_method).to eq('') |
|
26 | 28 |
|
27 | 29 | it 'creates context from rails request' do |
28 | 30 | request = ActionDispatch::Request.new(nil) |
29 | | - context = SecureNative::Context.from_http_request(request) |
| 31 | + context = securenative.from_http_request(request) |
30 | 32 |
|
31 | 33 | expect(context.ip).to eq('') |
32 | 34 | expect(context.http_method).to eq('') |
33 | 35 | expect(context.url).to eq('') |
34 | 36 | expect(context.remote_ip).to eq('') |
35 | | - expect(context.headers).to eq([]) |
| 37 | + expect(context.headers).to eq({}) |
36 | 38 | expect(context.body).to eq('') |
37 | 39 | end |
38 | 40 |
|
39 | 41 | it 'creates context from sinatra request' do |
40 | 42 | request = Sinatra::Request.new(nil) |
41 | | - context = SecureNative::Context.from_http_request(request) |
| 43 | + context = securenative.from_http_request(request) |
42 | 44 |
|
43 | 45 | expect(context.ip).to eq('') |
44 | 46 | expect(context.http_method).to eq('') |
45 | 47 | expect(context.url).to eq('') |
46 | 48 | expect(context.remote_ip).to eq('') |
47 | | - expect(context.headers).to eq([]) |
| 49 | + expect(context.headers).to eq({}) |
48 | 50 | expect(context.body).to eq('') |
49 | 51 | end |
50 | 52 |
|
51 | 53 | it 'creates context from hanami request' do |
52 | 54 | request = Hanami::Action::Request |
53 | | - context = SecureNative::Context.from_http_request(request) |
| 55 | + context = securenative.from_http_request(request) |
54 | 56 |
|
55 | 57 | expect(context.ip).to eq('') |
56 | 58 | expect(context.http_method).to eq('') |
57 | 59 | expect(context.url).to eq('') |
58 | 60 | expect(context.remote_ip).to eq('') |
59 | | - expect(context.headers).to eq([]) |
| 61 | + expect(context.headers).to eq({}) |
60 | 62 | expect(context.body).to eq('') |
61 | 63 | end |
62 | 64 |
|
|
0 commit comments