forked from stevegraham/slanger
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adds -p and -c command line params for private key and cert. * Passes them to the handler * A seperate test setup
- Loading branch information
Showing
5 changed files
with
125 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
require 'bundler/setup' | ||
|
||
require 'active_support/json' | ||
require 'active_support/core_ext/hash' | ||
require 'eventmachine' | ||
require 'em-http-request' | ||
require 'pusher' | ||
require 'thin' | ||
require './spec/spec_helper' | ||
|
||
describe 'Integration' do | ||
let(:errback) { Proc.new { fail 'cannot connect to slanger. your box might be too slow. try increasing sleep value in the before block' } } | ||
|
||
before(:each) do | ||
# Fork service. Our integration tests MUST block the main thread because we want to wait for i/o to finish. | ||
@server_pid = EM.fork_reactor do | ||
require File.expand_path(File.dirname(__FILE__) + '/../../slanger.rb') | ||
Thin::Logging.silent = true | ||
|
||
Slanger::Config.load host: '0.0.0.0', | ||
api_port: '4567', | ||
websocket_port: '8080', | ||
app_key: '765ec374ae0a69f4ce44', | ||
secret: 'your-pusher-secret', | ||
cert_chain_file: 'spec/server.crt', | ||
private_key_file: 'spec/server.key' | ||
|
||
Slanger::Service.run | ||
end | ||
# Give Slanger a chance to start | ||
sleep 0.6 | ||
end | ||
|
||
after(:each) do | ||
# Ensure Slanger is properly stopped. No orphaned processes allowed! | ||
Process.kill 'SIGKILL', @server_pid | ||
Process.wait @server_pid | ||
end | ||
|
||
before :all do | ||
Pusher.tap do |p| | ||
p.host = '0.0.0.0' | ||
p.port = 4567 | ||
p.app_id = 'your-pusher-app-id' | ||
p.secret = 'your-pusher-secret' | ||
p.key = '765ec374ae0a69f4ce44' | ||
end | ||
end | ||
|
||
describe 'regular channels:' do | ||
it 'pushes messages to interested websocket connections' do | ||
messages = em_stream do |websocket, messages| | ||
websocket.callback do | ||
websocket.send({ event: 'pusher:subscribe', data: { channel: 'MY_CHANNEL'} }.to_json) | ||
end if messages.one? | ||
|
||
if messages.length < 3 | ||
Pusher['MY_CHANNEL'].trigger_async 'an_event', { some: 'data' } | ||
else | ||
EM.stop | ||
end | ||
|
||
end | ||
|
||
messages.should have_attributes connection_established: true, id_present: true, | ||
last_event: 'an_event', last_data: { some: 'data' }.to_json | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIIBvzCCASgCCQCsMkmDVYNDETANBgkqhkiG9w0BAQUFADAkMQswCQYDVQQGEwJE | ||
RTEVMBMGA1UEAwwMc2xhbmdlci50ZXN0MB4XDTEyMDQxMTE2NDMwNloXDTE5MDIx | ||
NDE2NDMwNlowJDELMAkGA1UEBhMCREUxFTATBgNVBAMMDHNsYW5nZXIudGVzdDCB | ||
nzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAmlTxrcqXw+hbdjnpNENgx4p6T+x7 | ||
SgN/5ti3+gr5ZJElebEdJdGymM/KK817GFhLuYSEv72oEVitC1ISCfo/iOu4S71Y | ||
sGsrdyPVl3cDswSkvmo27J3rtAbY1fNDs68YFAQGH8wlQtPSPvd9KBKg0klafsDU | ||
VvDYjQ+XZ2+ZKZECAwEAATANBgkqhkiG9w0BAQUFAAOBgQCHGqUddcsTfvV0Nk3F | ||
zZ5kGvAiZ02MUourZ4GVs5uBYtkIrQ7HAlQbHAbC8d7e0UVgcTwUKgwpw/RfNR/O | ||
Ho/zn7lPciLQ7VMnOZ2+MfbJ2HIFgZL6qH1gTcQpBW4s3gKR5hFpaGJ+8l/cmEWj | ||
AvywaOcSLex+q0OwZaiusiDorg== | ||
-----END CERTIFICATE----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
-----BEGIN RSA PRIVATE KEY----- | ||
MIICXQIBAAKBgQCaVPGtypfD6Ft2Oek0Q2DHinpP7HtKA3/m2Lf6CvlkkSV5sR0l | ||
0bKYz8orzXsYWEu5hIS/vagRWK0LUhIJ+j+I67hLvViwayt3I9WXdwOzBKS+ajbs | ||
neu0BtjV80OzrxgUBAYfzCVC09I+930oEqDSSVp+wNRW8NiND5dnb5kpkQIDAQAB | ||
AoGABGzBDSGM3mIQFUCtzgDMiowO27HFCyc0iJLYG4QrCFYdA/MvCcGMZFM40a6v | ||
g9AsQ6JoB/NRGUY4l+V/fOe+4Iuycf8+vN1mrSVR1lTjy/mOwj900pc4ff6cDv6S | ||
bI/hm4BNiuj8OD11R+ZK07Lo1iCzBkAy53RkTFcBk74MYgECQQDMyAMT0DhlRBqD | ||
4vrPF+GZ+rMYpeTjuNDOZphIwzxpv70uyh2RNg+7F6U91Qxz6vpbIkz8Zf4TgdwM | ||
u/rroktxAkEAwO6wyzidm2yrPMPtnwxDIYnH/ETdNraa3JyHsjXsQwGAIG80+hCv | ||
QfCA/LmvNOm/Mpe1EyiAeI1/YJp4a2xwIQJBAKysFpQ1ZehVtbnxwaSwMWXiE/Q7 | ||
pjYyl7cCoXPxVFai+8WhXa8dE8Shmo75v2dbAsGnuZy177jJLiB6vYjFL7ECQQCI | ||
Zri7lLVo8zVFasgO0F6N0ZmAMzeqvQNTwZ72UcVNwjvRso3j1fPyTJUFGEpUwIWa | ||
wUMV3mal1HQf2lYUrL/BAkBBtXqOLFHINHUmffdRSV/2HECYXHazb6lAnL8nnQX0 | ||
vin2ujCli9mcYWnrY7zwlXdAxgQv5Q2ByQT9Fd8S7FjA | ||
-----END RSA PRIVATE KEY----- |