izanami 0.17.0 → 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +7 -2
- data/lib/izanami/app.rb +17 -4
- data/lib/izanami/version.rb +1 -1
- data/spec/helper.rb +6 -5
- data/spec/izanami/app_spec.rb +59 -46
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NmFiZWJjZDIxNDNkMzI2ZmUwNjg3NDRhYzA4ZWE2MjE3YWQ3NzM4MQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NWE3NjI5Nzc0NGJiMTU1NDA2M2I5OTE3YzA1MDAzMDNhMTQzZmIwMg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Njc2OWJhMmNlNGVmM2QzNGE0MGQ2M2YyZTA3OGY4ZTE5M2EwOThkMzM4ZGEy
|
10
|
+
NzA3NDZmNjAxMWFlZTc2YTc3MmY4YzVjNjRlOTJhOTIxNzI4Mzc4ZjYwZTgy
|
11
|
+
YmExOTM1ODA0NzQ1MjYwZWFhMWRjZWM0ZGU4ZTcyODBhM2M0Mzc=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZDZjYmU3NTAyMTcxZjk1OGM3YTNhOGFmMjA0YTYyMWRlOTA2NGM4MzVkMjdh
|
14
|
+
ZWZkNGQ2ZTdjMzdmZGE4N2QwOTg1NzRhNjBhZTIwODJhM2MzYmViZTQwNDE2
|
15
|
+
ZDc2M2RiZDgyZjRlMTAwM2ZlYTdlNWE2MWEyZGU5MWY1YzEzMGI=
|
data/README.md
CHANGED
@@ -52,8 +52,9 @@ Izanami configuration is handled via environment variables:
|
|
52
52
|
|
53
53
|
* `RACK_ENV`: App environment (e.g: `development`, `production`, `test`. Defaults to `development`).
|
54
54
|
* `IZANAMI_PORT`: Web app port (defaults to `4567`).
|
55
|
-
* `
|
56
|
-
* `
|
55
|
+
* `IZANAMI_AUTH`: Check if the app should use the built in basic auth module. Pass `disable` or `disabled` to skip it (is `enabled` by default).
|
56
|
+
* `IZANAMI_USER`: User for the HTTP Basic Authentication, if `IZANAMI_AUTH` is enabled (e.g: `izanami`).
|
57
|
+
* `IZANAMI_PASSWORD`: Password for the HTTP Basic Authentication, if `IZANAMI_AUTH` is enabled (e.g: `$3cr3t`).
|
57
58
|
* `IZANAMI_REDIS_URL`: Redis configuration in URL format (defaults to `redis://127.0.0.1:6379/0`).
|
58
59
|
* `IZANAMI_SANDBOX`: Path to the directory with the capistrano recipes.
|
59
60
|
* `IZANAMI_WATCHDOG_SLEEP_TIME`: The time the watchdog sleeps before update the sandbox git repository (default to 300 seconds).
|
@@ -62,8 +63,12 @@ Izanami configuration is handled via environment variables:
|
|
62
63
|
|
63
64
|
Izanami runs with `thin` by default. You can start the app with:
|
64
65
|
|
66
|
+
# With HTTP Basic Authentication
|
65
67
|
$ IZANAMI_USER=izanami IZANAMI_PASSWORD=izanami IZANAMI_SANDBOX=/path/to/recipes izanami app
|
66
68
|
|
69
|
+
# Without HTTP Basic Authentication
|
70
|
+
$ IZANAMI_AUTH=disable IZANAMI_SANDBOX=/path/to/recipes izanami app
|
71
|
+
|
67
72
|
But Izanami is a simple Sinatra app, so you can run it with any ruby server that handles a `config.ru` file:
|
68
73
|
|
69
74
|
```ruby
|
data/lib/izanami/app.rb
CHANGED
@@ -13,10 +13,6 @@ module Izanami
|
|
13
13
|
# handle PUT and DELETE actions
|
14
14
|
use Rack::MethodOverride
|
15
15
|
|
16
|
-
use Rack::Auth::Basic do |user, password|
|
17
|
-
user == ENV['IZANAMI_USER'] && password == ENV['IZANAMI_PASSWORD']
|
18
|
-
end
|
19
|
-
|
20
16
|
configure :development, :test do
|
21
17
|
set :stylesheets, ['/css/bootstrap.css', '/css/app.css']
|
22
18
|
end
|
@@ -162,5 +158,22 @@ module Izanami
|
|
162
158
|
out.close
|
163
159
|
end
|
164
160
|
end
|
161
|
+
|
162
|
+
# Sinatra overrides
|
163
|
+
# =====================
|
164
|
+
|
165
|
+
def self.new(*)
|
166
|
+
protect(super)
|
167
|
+
end
|
168
|
+
|
169
|
+
def self.protect(app)
|
170
|
+
if ENV['IZANAMI_AUTH'].to_s.match(/disabled?/i)
|
171
|
+
app
|
172
|
+
else
|
173
|
+
Rack::Auth::Basic.new(app) do |user, password|
|
174
|
+
user == ENV['IZANAMI_USER'] && password == ENV['IZANAMI_PASSWORD']
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
165
178
|
end
|
166
179
|
end
|
data/lib/izanami/version.rb
CHANGED
data/spec/helper.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
|
2
|
-
ENV['
|
3
|
-
ENV['
|
4
|
-
ENV['
|
5
|
-
ENV['
|
1
|
+
# Set configuration for specs.
|
2
|
+
ENV['RACK_ENV'] ||= 'test'
|
3
|
+
ENV['IZANAMI_USER'] = 'spec'
|
4
|
+
ENV['IZANAMI_PASSWORD'] = 'spec'
|
5
|
+
ENV['IZANAMI_SANDBOX'] = File.expand_path('..', __FILE__) + '/sandbox'
|
6
|
+
ENV['IZANAMI_REDIS_URL'] ||= 'redis://127.0.0.1:6379/0'
|
6
7
|
|
7
8
|
require 'bundler'
|
8
9
|
Bundler.setup(:default, :test)
|
data/spec/izanami/app_spec.rb
CHANGED
@@ -1,48 +1,7 @@
|
|
1
1
|
require_relative '../helper'
|
2
2
|
require 'izanami/app'
|
3
3
|
|
4
|
-
|
5
|
-
include Rack::Test::Methods
|
6
|
-
|
7
|
-
def app
|
8
|
-
Izanami::App
|
9
|
-
end
|
10
|
-
|
11
|
-
def worker
|
12
|
-
fork { yield }
|
13
|
-
end
|
14
|
-
|
15
|
-
# Simulate Worker::Command
|
16
|
-
def publish(redis_url, id)
|
17
|
-
redis = Redis.new(url: redis_url)
|
18
|
-
|
19
|
-
# wait for a subscriber to connect to a channel
|
20
|
-
loop do
|
21
|
-
subscribers = redis.info['pubsub_channels']
|
22
|
-
break if subscribers != '0'
|
23
|
-
end
|
24
|
-
|
25
|
-
key = "izanami:commands:#{id}"
|
26
|
-
channel = "izanami:commands:#{id}:channel"
|
27
|
-
output = 'PONG'
|
28
|
-
status = 'success'
|
29
|
-
|
30
|
-
redis.publish channel, output
|
31
|
-
redis.multi do
|
32
|
-
redis.publish channel, '--EOC--'
|
33
|
-
redis.hset key, 'status', status
|
34
|
-
redis.hset key, 'output', output
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def save_commands(redis, commands)
|
39
|
-
commands.each do |command|
|
40
|
-
# set all the values in redis in one step
|
41
|
-
redis.hmset "izanami:commands:#{command['id']}", *command.to_a.flatten
|
42
|
-
redis.sadd "izanami:commands:ids", command['id']
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
4
|
+
shared_examples 'web app' do
|
46
5
|
let!(:redis_url) { ENV['IZANAMI_REDIS_URL'] }
|
47
6
|
let(:redis) { Redis.new(url: redis_url) }
|
48
7
|
|
@@ -64,10 +23,6 @@ describe Izanami::App do
|
|
64
23
|
end
|
65
24
|
|
66
25
|
let(:commands) { [command_a, command_b] }
|
67
|
-
let(:user) { ENV['IZANAMI_USER'] }
|
68
|
-
let(:password) { ENV['IZANAMI_PASSWORD'] }
|
69
|
-
|
70
|
-
before { authorize(user, password) }
|
71
26
|
|
72
27
|
after { redis.flushdb }
|
73
28
|
|
@@ -193,3 +148,61 @@ describe Izanami::App do
|
|
193
148
|
end
|
194
149
|
end
|
195
150
|
end
|
151
|
+
|
152
|
+
describe Izanami::App do
|
153
|
+
include Rack::Test::Methods
|
154
|
+
|
155
|
+
def app
|
156
|
+
Izanami::App.new
|
157
|
+
end
|
158
|
+
|
159
|
+
def worker
|
160
|
+
fork { yield }
|
161
|
+
end
|
162
|
+
|
163
|
+
# Simulate Worker::Command
|
164
|
+
def publish(redis_url, id)
|
165
|
+
redis = Redis.new(url: redis_url)
|
166
|
+
|
167
|
+
# wait for a subscriber to connect to a channel
|
168
|
+
loop do
|
169
|
+
subscribers = redis.info['pubsub_channels']
|
170
|
+
break if subscribers != '0'
|
171
|
+
end
|
172
|
+
|
173
|
+
key = "izanami:commands:#{id}"
|
174
|
+
channel = "izanami:commands:#{id}:channel"
|
175
|
+
output = 'PONG'
|
176
|
+
status = 'success'
|
177
|
+
|
178
|
+
redis.publish channel, output
|
179
|
+
redis.multi do
|
180
|
+
redis.publish channel, '--EOC--'
|
181
|
+
redis.hset key, 'status', status
|
182
|
+
redis.hset key, 'output', output
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
def save_commands(redis, commands)
|
187
|
+
commands.each do |command|
|
188
|
+
# set all the values in redis in one step
|
189
|
+
redis.hmset "izanami:commands:#{command['id']}", *command.to_a.flatten
|
190
|
+
redis.sadd "izanami:commands:ids", command['id']
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
context 'with authorization enabled' do
|
195
|
+
let(:user) { ENV['IZANAMI_USER'] }
|
196
|
+
let(:password) { ENV['IZANAMI_PASSWORD'] }
|
197
|
+
|
198
|
+
before { authorize(user, password) }
|
199
|
+
|
200
|
+
it_should_behave_like 'web app'
|
201
|
+
end
|
202
|
+
|
203
|
+
context 'with authorization disabled' do
|
204
|
+
before { ENV['IZANAMI_AUTH'] = 'disabled' }
|
205
|
+
|
206
|
+
it_should_behave_like 'web app'
|
207
|
+
end
|
208
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: izanami
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.18.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Hernández
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|