redis_monitor 0.1 → 0.2
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 +7 -0
- data/.gitignore +1 -0
- data/.travis.yml +1 -2
- data/Gemfile +2 -1
- data/README.md +1 -1
- data/Rakefile +5 -0
- data/bin/redis_monitor +2 -2
- data/lib/{server/command_line_parser.rb → command_line_parser.rb} +0 -3
- data/lib/engine/.gitignore +16 -0
- data/lib/engine/.rspec +2 -0
- data/lib/engine/Gemfile +5 -0
- data/lib/engine/Rakefile +6 -0
- data/lib/engine/app/assets/images/.keep +0 -0
- data/lib/engine/app/controllers/application_controller.rb +10 -0
- data/lib/engine/app/controllers/concerns/.keep +0 -0
- data/lib/engine/app/controllers/content_controller.rb +34 -0
- data/lib/engine/app/controllers/info_controller.rb +6 -0
- data/lib/engine/app/controllers/performance_controller.rb +8 -0
- data/lib/engine/app/helpers/application_helper.rb +21 -0
- data/lib/engine/app/helpers/database_helper.rb +36 -0
- data/lib/engine/app/helpers/pagination_helper.rb +8 -0
- data/lib/engine/app/lib/backend.rb +45 -0
- data/lib/{modules → engine/app/lib}/performance_stats.rb +0 -0
- data/lib/engine/app/lib/security/authentication.rb +14 -0
- data/lib/engine/app/lib/security/authorization.rb +16 -0
- data/lib/engine/app/mailers/.keep +0 -0
- data/lib/engine/app/models/.keep +0 -0
- data/lib/engine/app/models/concerns/.keep +0 -0
- data/lib/{views → engine/app/views}/content/_search_form.haml +0 -0
- data/lib/engine/app/views/content/index.haml +1 -0
- data/lib/{views → engine/app/views}/content/search.haml +5 -5
- data/lib/{views/info/info.haml → engine/app/views/info/index.haml} +1 -1
- data/lib/engine/app/views/layouts/application.haml +23 -0
- data/lib/{views → engine/app/views}/performance/check.haml +1 -1
- data/lib/{views/performance/warning.haml → engine/app/views/performance/index.haml} +0 -0
- data/lib/engine/bin/bundle +3 -0
- data/lib/engine/bin/rails +4 -0
- data/lib/engine/bin/rake +4 -0
- data/lib/engine/config/application.rb +34 -0
- data/lib/engine/config/boot.rb +4 -0
- data/lib/engine/config/database.yml +25 -0
- data/lib/engine/config/environment.rb +5 -0
- data/lib/engine/config/environments/development.rb +25 -0
- data/lib/engine/config/environments/production.rb +65 -0
- data/lib/engine/config/environments/test.rb +36 -0
- data/lib/engine/config/initializers/backtrace_silencers.rb +7 -0
- data/lib/engine/config/initializers/configuration.rb +5 -0
- data/lib/engine/config/initializers/filter_parameter_logging.rb +4 -0
- data/lib/engine/config/initializers/haml.rb +1 -0
- data/lib/engine/config/initializers/inflections.rb +16 -0
- data/lib/engine/config/initializers/mime_types.rb +5 -0
- data/lib/engine/config/initializers/secret_token.rb +12 -0
- data/lib/engine/config/initializers/session_store.rb +3 -0
- data/lib/engine/config/initializers/will_paginate.rb +1 -0
- data/lib/engine/config/initializers/wrap_parameters.rb +14 -0
- data/lib/engine/config/locales/en.bootstrap.yml +18 -0
- data/lib/engine/config/locales/en.yml +23 -0
- data/lib/engine/config/routes.rb +73 -0
- data/lib/engine/config.ru +4 -0
- data/lib/engine/db/seeds.rb +7 -0
- data/lib/engine/lib/assets/.keep +0 -0
- data/lib/engine/lib/tasks/.keep +0 -0
- data/lib/engine/log/.keep +0 -0
- data/lib/engine/public/404.html +58 -0
- data/lib/engine/public/422.html +58 -0
- data/lib/engine/public/500.html +57 -0
- data/lib/engine/public/favicon.ico +0 -0
- data/lib/{static/scripts → engine/public/javascripts}/app.js +0 -0
- data/lib/{static/scripts → engine/public/javascripts}/bootstrap-select.min.js +0 -0
- data/lib/{static/scripts → engine/public/javascripts}/bootstrap.min.js +0 -0
- data/lib/{static/scripts → engine/public/javascripts}/jquery-2.0.3.min.js +0 -0
- data/lib/engine/public/robots.txt +5 -0
- data/lib/{static/styles → engine/public/stylesheets}/bootstrap-select.min.css +0 -0
- data/lib/{static/styles → engine/public/stylesheets}/bootstrap.min.css +0 -0
- data/lib/{static/styles → engine/public/stylesheets}/custom.css +0 -0
- data/lib/engine/spec/controllers/content_controller_spec.rb +28 -0
- data/lib/engine/spec/controllers/info_controller_spec.rb +10 -0
- data/lib/engine/spec/controllers/performance_controller_spec.rb +10 -0
- data/{spec/modules → lib/engine/spec/lib}/backend_spec.rb +3 -3
- data/{spec/modules → lib/engine/spec/lib}/performance_stats_spec.rb +1 -1
- data/lib/engine/spec/lib/security/authentication_spec.rb +23 -0
- data/{spec/modules → lib/engine/spec/lib}/security/authorization_spec.rb +1 -1
- data/lib/engine/spec/spec_helper.rb +47 -0
- data/lib/engine/test/controllers/.keep +0 -0
- data/lib/engine/test/fixtures/.keep +0 -0
- data/lib/engine/test/helpers/.keep +0 -0
- data/lib/engine/test/integration/.keep +0 -0
- data/lib/engine/test/mailers/.keep +0 -0
- data/lib/engine/test/models/.keep +0 -0
- data/lib/engine/test/test_helper.rb +15 -0
- data/lib/engine/vendor/assets/javascripts/.keep +0 -0
- data/lib/engine/vendor/assets/stylesheets/.keep +0 -0
- data/lib/redis_monitor.rb +14 -10
- data/lib/{modules/version.rb → version.rb} +1 -1
- data/redis_monitor.gemspec +14 -4
- metadata +153 -100
- data/lib/controllers/base_controller.rb +0 -53
- data/lib/controllers/content_controller.rb +0 -37
- data/lib/controllers/info_controller.rb +0 -14
- data/lib/controllers/performance_controller.rb +0 -19
- data/lib/errors/errors.rb +0 -1
- data/lib/errors/redis_not_available.rb +0 -7
- data/lib/helpers/base_helper.rb +0 -13
- data/lib/helpers/database_helper.rb +0 -40
- data/lib/helpers/layouts_helper.rb +0 -29
- data/lib/helpers/pagination_helper.rb +0 -10
- data/lib/modules/backend.rb +0 -49
- data/lib/modules/controllers.rb +0 -5
- data/lib/modules/helpers.rb +0 -15
- data/lib/modules/router.rb +0 -26
- data/lib/modules/security/authentication.rb +0 -29
- data/lib/modules/security/authorization.rb +0 -18
- data/lib/server/server.rb +0 -27
- data/lib/views/content/index.haml +0 -1
- data/lib/views/errors/redis_not_available.haml +0 -2
- data/lib/views/layouts/main.haml +0 -21
- data/spec/controllers/base_controller_spec.rb +0 -34
- data/spec/controllers/content_controller_spec.rb +0 -41
- data/spec/controllers/info_controller_spec.rb +0 -22
- data/spec/controllers/performance_controller_spec.rb +0 -21
- data/spec/modules/security/authentication_spec.rb +0 -48
- data/spec/server/command_line_parser_spec.rb +0 -42
- data/spec/spec_helper.rb +0 -23
data/lib/modules/backend.rb
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
require 'redis'
|
|
2
|
-
require 'errors/errors'
|
|
3
|
-
require 'modules/performance_stats'
|
|
4
|
-
require 'forwardable'
|
|
5
|
-
|
|
6
|
-
module RedisMonitor
|
|
7
|
-
class Backend
|
|
8
|
-
extend SingleForwardable
|
|
9
|
-
|
|
10
|
-
def_delegators :redis, :get, :set, :info, :keys, :dbsize, :select
|
|
11
|
-
|
|
12
|
-
def self.config(arguments)
|
|
13
|
-
@@host = arguments[:redis_host]
|
|
14
|
-
@@port = arguments[:redis_port]
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def self.host
|
|
18
|
-
@@host
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def self.port
|
|
22
|
-
@@port
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def self.redis
|
|
26
|
-
@@redis ||= Redis.new(:host => host, :port => port)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def self.performance_stats
|
|
30
|
-
PerformanceStats.new(self).results
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def self.search(key)
|
|
34
|
-
keys(key).map{|found| {key: found, value: get(found)} }
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def self.change_database(*args)
|
|
38
|
-
select(*args)
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def self.del(key)
|
|
42
|
-
redis.del(key) if Authorization.authorized_for?(:remove_content)
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def self.databases
|
|
46
|
-
info.keys.map{|d| d.match(/db(\d+)/);$1}.compact
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
data/lib/modules/controllers.rb
DELETED
data/lib/modules/helpers.rb
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
require 'helpers/base_helper'
|
|
2
|
-
require 'helpers/layouts_helper'
|
|
3
|
-
require 'helpers/pagination_helper'
|
|
4
|
-
require 'helpers/database_helper'
|
|
5
|
-
|
|
6
|
-
module RedisMonitor
|
|
7
|
-
module Helpers
|
|
8
|
-
module AllHelpers
|
|
9
|
-
include BaseHelper
|
|
10
|
-
include LayoutsHelper
|
|
11
|
-
include PaginationHelper
|
|
12
|
-
include DatabaseHelper
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
data/lib/modules/router.rb
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
require 'modules/helpers'
|
|
2
|
-
require 'modules/controllers'
|
|
3
|
-
|
|
4
|
-
module RedisMonitor
|
|
5
|
-
module Router
|
|
6
|
-
include RedisMonitor::Controllers
|
|
7
|
-
|
|
8
|
-
def dependencies
|
|
9
|
-
{context: self, session: session, params: params}
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def self.included(server)
|
|
13
|
-
server.get('/'){ redirect '/info' }
|
|
14
|
-
server.get('/info'){ InfoController.new(dependencies).execute(:index) }
|
|
15
|
-
|
|
16
|
-
server.get('/content'){ ContentController.new(dependencies).execute(:index) }
|
|
17
|
-
server.get('/content/search'){ ContentController.new(dependencies).execute(:search) }
|
|
18
|
-
server.post('/content/delete'){ ContentController.new(dependencies).execute(:delete) }
|
|
19
|
-
server.post('/content/change_database'){ ContentController.new(dependencies).execute(:change_database) }
|
|
20
|
-
|
|
21
|
-
server.get('/performance'){ redirect '/performance/warning' }
|
|
22
|
-
server.get('/performance/warning'){ PerformanceController.new(dependencies).execute(:warning) }
|
|
23
|
-
server.get('/performance/check'){ PerformanceController.new(dependencies).execute(:check) }
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
module RedisMonitor
|
|
2
|
-
module Authentication
|
|
3
|
-
|
|
4
|
-
def self.config(server, credentials)
|
|
5
|
-
@@credentials = credentials
|
|
6
|
-
@@server = server
|
|
7
|
-
inject_authentication
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def self.inject_authentication
|
|
11
|
-
if authentication_required?
|
|
12
|
-
@@server.class_eval do
|
|
13
|
-
use Rack::Auth::Basic, 'Restricted Area' do |username, password|
|
|
14
|
-
username == Authentication.credentials[:user] and password == Authentication.credentials[:password]
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
def self.authentication_required?
|
|
22
|
-
!!credentials
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def self.credentials
|
|
26
|
-
@@credentials
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
module RedisMonitor
|
|
2
|
-
class Authorization
|
|
3
|
-
DEFAULTS = {remove_content: true}
|
|
4
|
-
|
|
5
|
-
def self.config(opts = {})
|
|
6
|
-
opts = {} unless opts
|
|
7
|
-
@@permissions = DEFAULTS.merge(opts)
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def self.permissions
|
|
11
|
-
@@permissions
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def self.authorized_for?(action)
|
|
15
|
-
!!permissions[action]
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
data/lib/server/server.rb
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
require 'sinatra'
|
|
2
|
-
require 'haml'
|
|
3
|
-
require 'modules/router'
|
|
4
|
-
require 'modules/security/authorization'
|
|
5
|
-
require 'will_paginate/view_helpers/sinatra'
|
|
6
|
-
require 'will_paginate-bootstrap'
|
|
7
|
-
|
|
8
|
-
module RedisMonitor
|
|
9
|
-
class Server < Sinatra::Base
|
|
10
|
-
include RedisMonitor::Router
|
|
11
|
-
include RedisMonitor::Helpers::LayoutsHelper
|
|
12
|
-
include WillPaginate::Sinatra::Helpers
|
|
13
|
-
include RedisMonitor::Helpers::PaginationHelper
|
|
14
|
-
include RedisMonitor::Helpers::DatabaseHelper
|
|
15
|
-
|
|
16
|
-
set :public_folder, File.dirname(__FILE__) + '/../static'
|
|
17
|
-
set :views, File.dirname(__FILE__) + '/../views'
|
|
18
|
-
enable :sessions
|
|
19
|
-
|
|
20
|
-
def self.config(arguments)
|
|
21
|
-
set :server, arguments[:http_server]
|
|
22
|
-
set :port, arguments[:http_port]
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
= haml 'content/_search_form'.to_sym
|
data/lib/views/layouts/main.haml
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
%html
|
|
2
|
-
%head
|
|
3
|
-
%meta{name: 'viewport', content: 'width=device-width, initial-scale=1.0'}
|
|
4
|
-
%link{rel: 'stylesheet', media: 'screen, projection', type: 'text/css', href: '/styles/bootstrap.min.css'}
|
|
5
|
-
%link{rel: 'stylesheet', media: 'screen, projection', type: 'text/css', href: '/styles/bootstrap-select.min.css'}
|
|
6
|
-
%link{rel: 'stylesheet', media: 'screen, projection', type: 'text/css', href: '/styles/custom.css'}
|
|
7
|
-
%script{src: '/scripts/jquery-2.0.3.min.js'}
|
|
8
|
-
%script{src: '/scripts/bootstrap.min.js'}
|
|
9
|
-
%script{src: '/scripts/bootstrap-select.min.js'}
|
|
10
|
-
%script{src: '/scripts/app.js'}
|
|
11
|
-
%body
|
|
12
|
-
.navbar.navbar-inverse.navbar-fixed-top
|
|
13
|
-
.container
|
|
14
|
-
.navbar-header
|
|
15
|
-
%a.navbar-brand{href: '/'}
|
|
16
|
-
Redis Monitor
|
|
17
|
-
.collapse.navbar-collapse
|
|
18
|
-
= content_menu(section)
|
|
19
|
-
|
|
20
|
-
.container
|
|
21
|
-
= yield
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe BaseController do
|
|
4
|
-
let(:context){ double() }
|
|
5
|
-
let(:controller){ BaseController.new(context: context) }
|
|
6
|
-
|
|
7
|
-
before :each do
|
|
8
|
-
Backend.stub(:host)
|
|
9
|
-
Backend.stub(:port)
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
describe 'execute method' do
|
|
13
|
-
it 'should not raise error if the action executed raised RedisNotAvailable' do
|
|
14
|
-
controller.stub(:action) { raise RedisNotAvailable }
|
|
15
|
-
controller.should_receive(:redis_not_available)
|
|
16
|
-
expect{ controller.execute(:action) }.not_to raise_error
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
describe 'redis_not_available method' do
|
|
21
|
-
it 'should render redis not available error page' do
|
|
22
|
-
context.should_receive(:haml).with('errors/redis_not_available'.to_sym, anything)
|
|
23
|
-
controller.redis_not_available
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
describe 'set_database' do
|
|
28
|
-
it 'should change the actual database' do
|
|
29
|
-
controller.stub(:session){ {} }
|
|
30
|
-
Backend.should_receive(:change_database)
|
|
31
|
-
controller.set_database(2)
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe ContentController do
|
|
4
|
-
let(:context){ double() }
|
|
5
|
-
let(:params){ {key: ''} }
|
|
6
|
-
let(:controller){ ContentController.new(context: context, params: params) }
|
|
7
|
-
let(:search_results){ double(paginate: []) }
|
|
8
|
-
|
|
9
|
-
before :each do
|
|
10
|
-
controller.stub(:redirect_back)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
describe 'index action' do
|
|
14
|
-
it 'should render index template' do
|
|
15
|
-
context.should_receive(:haml).with('content/index'.to_sym, anything)
|
|
16
|
-
controller.index
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
describe 'search action' do
|
|
21
|
-
it 'should render search template' do
|
|
22
|
-
Backend.stub(:search){ search_results }
|
|
23
|
-
context.should_receive(:haml).with('content/search'.to_sym, anything)
|
|
24
|
-
controller.search
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
describe 'delete action' do
|
|
29
|
-
it 'should call del on Backend' do
|
|
30
|
-
Backend.should_receive(:del)
|
|
31
|
-
controller.delete
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
describe 'change_database' do
|
|
36
|
-
it 'should call set_database' do
|
|
37
|
-
controller.should_receive(:set_database)
|
|
38
|
-
controller.change_database
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe InfoController do
|
|
4
|
-
let(:context){ double() }
|
|
5
|
-
let(:controller){ InfoController.new(context: context) }
|
|
6
|
-
|
|
7
|
-
describe 'index action' do
|
|
8
|
-
before :each do
|
|
9
|
-
Backend.stub(:info){ {} }
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
it 'should not fail' do
|
|
13
|
-
context.stub(:haml)
|
|
14
|
-
expect{ controller.index }.not_to raise_error
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
it 'should render info template' do
|
|
18
|
-
context.should_receive(:haml).with('info/info'.to_sym, anything)
|
|
19
|
-
controller.index
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe PerformanceController do
|
|
4
|
-
let(:context){ double() }
|
|
5
|
-
let(:controller){ PerformanceController.new(context: context) }
|
|
6
|
-
|
|
7
|
-
describe 'warning action' do
|
|
8
|
-
it 'should render warning template' do
|
|
9
|
-
context.should_receive(:haml).with('performance/warning'.to_sym, anything)
|
|
10
|
-
controller.warning
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
describe 'check action' do
|
|
15
|
-
it 'should render check template' do
|
|
16
|
-
Backend.stub(:performance_stats){ {} }
|
|
17
|
-
context.should_receive(:haml).with('performance/check'.to_sym, anything)
|
|
18
|
-
controller.check
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe Authentication do
|
|
4
|
-
let(:server){ double(class_eval: nil, use: nil) }
|
|
5
|
-
let(:credentials){ {user: 'user', password: 'password'} }
|
|
6
|
-
|
|
7
|
-
describe 'config' do
|
|
8
|
-
it 'should inject authentication in server class' do
|
|
9
|
-
Authentication.should_receive(:inject_authentication)
|
|
10
|
-
Authentication.config(server, credentials)
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
describe 'inject_authentication' do
|
|
15
|
-
before :each do
|
|
16
|
-
Authentication.config(server, credentials)
|
|
17
|
-
server.stub(:class_eval){|&block| block.call }
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
it 'should include authentication if required' do
|
|
21
|
-
Authentication.stub(:authentication_required?){ true }
|
|
22
|
-
Authentication.should_receive(:use).with(Rack::Auth::Basic, anything)
|
|
23
|
-
Authentication.inject_authentication
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
it 'should not include authentication if not required' do
|
|
27
|
-
Authentication.stub(:authentication_required?){ false }
|
|
28
|
-
Authentication.should_not_receive(:use)
|
|
29
|
-
Authentication.inject_authentication
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
describe 'authentication_required??' do
|
|
34
|
-
before :each do
|
|
35
|
-
Authentication.stub(:inject_authentication)
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
it 'should return true if it has some credentials' do
|
|
39
|
-
Authentication.config(server, credentials)
|
|
40
|
-
Authentication.authentication_required?.should eq(true)
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
it 'should return false if no credentials were provided' do
|
|
44
|
-
Authentication.config(server, nil)
|
|
45
|
-
Authentication.authentication_required?.should eq(false)
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe CommandLineParser do
|
|
4
|
-
describe 'parse' do
|
|
5
|
-
it 'should read http-server option' do
|
|
6
|
-
args = ['--http-server', 'server']
|
|
7
|
-
CommandLineParser.parse(args)[:http_server].should eq('server')
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
it 'should read http-port option' do
|
|
11
|
-
args = ['--http-port', '2222']
|
|
12
|
-
CommandLineParser.parse(args)[:http_port].should eq(2222)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
it 'should read host option' do
|
|
16
|
-
args = ['--host', 'redisdb']
|
|
17
|
-
CommandLineParser.parse(args)[:redis_host].should eq('redisdb')
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
it 'should read port option' do
|
|
21
|
-
args = ['--port', '4444']
|
|
22
|
-
CommandLineParser.parse(args)[:redis_port].should eq(4444)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
it 'should read editable option' do
|
|
26
|
-
args = ['--editable']
|
|
27
|
-
CommandLineParser.parse(args)[:permissions][:remove_content].should eq(true)
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
it 'should read not-editable option' do
|
|
31
|
-
args = ['--not-editable']
|
|
32
|
-
CommandLineParser.parse(args)[:permissions][:remove_content].should eq(false)
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
it 'should read credentials options' do
|
|
36
|
-
args = ['--credentials', 'user:password']
|
|
37
|
-
credentials = CommandLineParser.parse(args)[:credentials]
|
|
38
|
-
credentials[:user].should eq('user')
|
|
39
|
-
credentials[:password].should eq('password')
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
data/spec/spec_helper.rb
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# This file was generated by the `rspec --init` command. Conventionally, all
|
|
2
|
-
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
|
3
|
-
# Require this file using `require "spec_helper"` to ensure that it is only
|
|
4
|
-
# loaded once.
|
|
5
|
-
#
|
|
6
|
-
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
|
7
|
-
RSpec.configure do |config|
|
|
8
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
|
9
|
-
config.run_all_when_everything_filtered = true
|
|
10
|
-
config.order = 'random'
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
require 'sinatra'
|
|
14
|
-
require 'modules/helpers'
|
|
15
|
-
require 'modules/controllers'
|
|
16
|
-
require 'modules/backend'
|
|
17
|
-
require 'server/command_line_parser'
|
|
18
|
-
require 'modules/security/authorization'
|
|
19
|
-
require 'modules/security/authentication'
|
|
20
|
-
|
|
21
|
-
include RedisMonitor
|
|
22
|
-
include RedisMonitor::Controllers
|
|
23
|
-
include RedisMonitor::Errors
|