torquebox-backstage 0.1.0
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.
- data/Gemfile +18 -0
- data/Gemfile.lock +69 -0
- data/README.md +164 -0
- data/Rakefile +32 -0
- data/TODO +9 -0
- data/TORQUEBOX_VERSION +1 -0
- data/VERSION +1 -0
- data/backstage.rb +84 -0
- data/bin/backstage +78 -0
- data/config.ru +3 -0
- data/config/torquebox.yml +14 -0
- data/lib/apps.rb +18 -0
- data/lib/apps/models/app.rb +33 -0
- data/lib/apps/routes.rb +18 -0
- data/lib/authentication.rb +64 -0
- data/lib/destinations.rb +21 -0
- data/lib/destinations/models/destination.rb +80 -0
- data/lib/destinations/models/message.rb +67 -0
- data/lib/destinations/models/queue.rb +33 -0
- data/lib/destinations/models/topic.rb +59 -0
- data/lib/destinations/routes.rb +44 -0
- data/lib/has_mbean.rb +59 -0
- data/lib/helpers.rb +142 -0
- data/lib/jobs.rb +19 -0
- data/lib/jobs/models/job.rb +35 -0
- data/lib/jobs/routes.rb +18 -0
- data/lib/message_processors.rb +18 -0
- data/lib/message_processors/models/message_processor.rb +40 -0
- data/lib/message_processors/routes.rb +18 -0
- data/lib/pools.rb +18 -0
- data/lib/pools/models/pool.rb +51 -0
- data/lib/pools/routes.rb +41 -0
- data/lib/resource.rb +53 -0
- data/lib/resource_helpers.rb +63 -0
- data/lib/runtimes.rb +19 -0
- data/lib/runtimes/models/job.rb +35 -0
- data/lib/runtimes/routes.rb +18 -0
- data/lib/services.rb +18 -0
- data/lib/services/models/service.rb +35 -0
- data/lib/services/routes.rb +17 -0
- data/lib/torquebox_managed.rb +36 -0
- data/lib/util.rb +33 -0
- data/spec/api_spec.rb +136 -0
- data/spec/auth_spec.rb +70 -0
- data/spec/spec_helper.rb +39 -0
- data/views/apps/index.haml +15 -0
- data/views/apps/show.haml +12 -0
- data/views/css/_mixins.sass +51 -0
- data/views/css/html5reset.sass +82 -0
- data/views/css/style.sass +152 -0
- data/views/destinations/index.haml +37 -0
- data/views/destinations/show.haml +18 -0
- data/views/jobs/index.haml +23 -0
- data/views/jobs/show.haml +13 -0
- data/views/layout.haml +31 -0
- data/views/message_processors/index.haml +28 -0
- data/views/message_processors/show.haml +12 -0
- data/views/messages/index.haml +20 -0
- data/views/messages/properties.haml +3 -0
- data/views/messages/show.haml +19 -0
- data/views/pools/index.haml +32 -0
- data/views/pools/show.haml +44 -0
- data/views/services/index.haml +21 -0
- data/views/services/show.haml +13 -0
- metadata +289 -0
data/spec/auth_spec.rb
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright 2011 Red Hat, Inc.
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
#
|
|
16
|
+
|
|
17
|
+
require 'spec_helper'
|
|
18
|
+
|
|
19
|
+
module Backstage
|
|
20
|
+
describe 'with authentication enabled' do
|
|
21
|
+
before(:each) do
|
|
22
|
+
App.stub(:all).and_return([resource_with_mock_mbean(App)])
|
|
23
|
+
ENV['REQUIRE_AUTHENTICATION'] = 'true'
|
|
24
|
+
@authenticator = mock(:authenticator)
|
|
25
|
+
TorqueBox::Authentication.stub(:default).and_return(@authenticator)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "allow access with proper credentials" do
|
|
29
|
+
@authenticator.should_receive(:authenticate).with('blah', 'pw').and_return(true)
|
|
30
|
+
authorize 'blah', 'pw'
|
|
31
|
+
get '/apps'
|
|
32
|
+
last_response.should be_ok
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "should 401 w/o credentials" do
|
|
36
|
+
get '/apps'
|
|
37
|
+
last_response.status.should == 401
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "should 401 with invalid credentials" do
|
|
41
|
+
@authenticator.should_receive(:authenticate).with('foo', 'bar').and_return(false)
|
|
42
|
+
authorize 'foo', 'bar'
|
|
43
|
+
get '/apps'
|
|
44
|
+
last_response.status.should == 401
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
after(:each) do
|
|
48
|
+
ENV['REQUIRE_AUTHENTICATION'] = nil
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
describe 'with authentication disabled' do
|
|
53
|
+
before(:each) do
|
|
54
|
+
App.stub(:all).and_return([resource_with_mock_mbean(App)])
|
|
55
|
+
ENV['REQUIRE_AUTHENTICATION'] = nil
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it "should allow access w/o credentials" do
|
|
59
|
+
get '/apps'
|
|
60
|
+
last_response.should be_ok
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it "should allow access with credentials" do
|
|
64
|
+
authorize 'blah', 'pwasfd'
|
|
65
|
+
get '/apps'
|
|
66
|
+
last_response.should be_ok
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright 2011 Red Hat, Inc.
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
#
|
|
16
|
+
|
|
17
|
+
require 'rack/test'
|
|
18
|
+
require 'backstage'
|
|
19
|
+
require 'json'
|
|
20
|
+
|
|
21
|
+
def app
|
|
22
|
+
Backstage::Application
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def resource_with_mock_mbean(klass)
|
|
26
|
+
mock_mbean = mock('mbean')
|
|
27
|
+
def mock_mbean.method_missing(method, *args, &block)
|
|
28
|
+
method.to_s
|
|
29
|
+
end
|
|
30
|
+
resource = klass.new('mock_mbean', mock_mbean)
|
|
31
|
+
resource.stub(:name).and_return('name')
|
|
32
|
+
resource.stub(:app_name).and_return('app_name')
|
|
33
|
+
resource.stub(:app).and_return(resource_with_mock_mbean(Backstage::App)) unless klass == Backstage::App
|
|
34
|
+
resource
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
RSpec.configure do |conf|
|
|
38
|
+
conf.include Rack::Test::Methods
|
|
39
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#apps-show
|
|
2
|
+
%h2
|
|
3
|
+
== App: #{@object.name}
|
|
4
|
+
.actions
|
|
5
|
+
|
|
6
|
+
%table.data-table
|
|
7
|
+
- %w{ name environment_name root_path deployed_at }.each do |method|
|
|
8
|
+
= data_row( method.humanize, @object.send( method ) )
|
|
9
|
+
|
|
10
|
+
.controls
|
|
11
|
+
= link_to collection_path( :apps ), '<< Back'
|
|
12
|
+
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
@mixin rounded-top-left-corner($radius: 5px)
|
|
2
|
+
-moz-border-radius-topleft: $radius
|
|
3
|
+
-webkit-border-top-left-radius: $radius
|
|
4
|
+
border-top-left-radius: $radius
|
|
5
|
+
|
|
6
|
+
@mixin rounded-top-right-corner($radius: 5px)
|
|
7
|
+
-moz-border-radius-topright: $radius
|
|
8
|
+
-webkit-border-top-right-radius: $radius
|
|
9
|
+
border-top-right-radius: $radius
|
|
10
|
+
|
|
11
|
+
@mixin rounded-top-corners($radius: 5px)
|
|
12
|
+
@include rounded-top-left-corner($radius)
|
|
13
|
+
@include rounded-top-right-corner($radius)
|
|
14
|
+
|
|
15
|
+
@mixin rounded-bottom-left-corner($radius: 5px)
|
|
16
|
+
-moz-border-radius-bottomleft: $radius
|
|
17
|
+
-webkit-border-bottom-left-radius: $radius
|
|
18
|
+
border-bottom-left-radius: $radius
|
|
19
|
+
|
|
20
|
+
@mixin rounded-bottom-right-corner($radius: 5px)
|
|
21
|
+
-moz-border-radius-bottomright: $radius
|
|
22
|
+
-webkit-border-bottom-right-radius: $radius
|
|
23
|
+
border-bottom-right-radius: $radius
|
|
24
|
+
|
|
25
|
+
@mixin rounded-bottom-corners($radius: 5px)
|
|
26
|
+
@include rounded-bottom-left-corner($radius)
|
|
27
|
+
@include rounded-bottom-right-corner($radius)
|
|
28
|
+
|
|
29
|
+
@mixin rounded-corners($radius: 5px)
|
|
30
|
+
@include rounded-top-corners($radius)
|
|
31
|
+
@include rounded-bottom-corners($radius)
|
|
32
|
+
|
|
33
|
+
@mixin clearfix
|
|
34
|
+
&:after
|
|
35
|
+
content: "\0020"
|
|
36
|
+
display: block
|
|
37
|
+
height: 0
|
|
38
|
+
clear: both
|
|
39
|
+
overflow: hidden
|
|
40
|
+
visibility: hidden
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
@mixin highlighted-tab
|
|
44
|
+
background-color: $active_tab_color
|
|
45
|
+
|
|
46
|
+
@mixin selected-tab($body_class, $link_class: "")
|
|
47
|
+
@if $link_class == ""
|
|
48
|
+
$link_class: $body_class
|
|
49
|
+
body.#{$body_class}
|
|
50
|
+
#navigation a.#{$link_class}
|
|
51
|
+
@include highlighted-tab
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/* html5doctor.com Reset Stylesheet
|
|
2
|
+
/* v1.6
|
|
3
|
+
/* Last Updated: 2010-08-18
|
|
4
|
+
/* Author: Richard Clark - http://richclarkdesign.com
|
|
5
|
+
/* Twitter: @rich_clark
|
|
6
|
+
|
|
7
|
+
html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, abbr, address, cite, code, del, dfn, em, img, ins, kbd, q, samp, small, strong, sub, sup, var, b, i, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, figcaption, figure, footer, header, hgroup, menu, nav, section, summary, time, mark, audio, video
|
|
8
|
+
margin: 0
|
|
9
|
+
padding: 0
|
|
10
|
+
border: 0
|
|
11
|
+
outline: 0
|
|
12
|
+
font-size: 100%
|
|
13
|
+
vertical-align: baseline
|
|
14
|
+
background: transparent
|
|
15
|
+
|
|
16
|
+
body
|
|
17
|
+
line-height: 1
|
|
18
|
+
|
|
19
|
+
article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section
|
|
20
|
+
display: block
|
|
21
|
+
|
|
22
|
+
nav ul
|
|
23
|
+
list-style: none
|
|
24
|
+
|
|
25
|
+
blockquote, q
|
|
26
|
+
quotes: none
|
|
27
|
+
|
|
28
|
+
blockquote
|
|
29
|
+
&:before, &:after
|
|
30
|
+
content: ''
|
|
31
|
+
content: none
|
|
32
|
+
|
|
33
|
+
q
|
|
34
|
+
&:before, &:after
|
|
35
|
+
content: ''
|
|
36
|
+
content: none
|
|
37
|
+
|
|
38
|
+
a
|
|
39
|
+
margin: 0
|
|
40
|
+
padding: 0
|
|
41
|
+
font-size: 100%
|
|
42
|
+
vertical-align: baseline
|
|
43
|
+
background: transparent
|
|
44
|
+
|
|
45
|
+
/* change colours to suit your needs
|
|
46
|
+
|
|
47
|
+
ins
|
|
48
|
+
background-color: #ff9
|
|
49
|
+
color: #000
|
|
50
|
+
text-decoration: none
|
|
51
|
+
|
|
52
|
+
/* change colours to suit your needs
|
|
53
|
+
|
|
54
|
+
mark
|
|
55
|
+
background-color: #ff9
|
|
56
|
+
color: #000
|
|
57
|
+
font-style: italic
|
|
58
|
+
font-weight: bold
|
|
59
|
+
|
|
60
|
+
del
|
|
61
|
+
text-decoration: line-through
|
|
62
|
+
|
|
63
|
+
abbr[title], dfn[title]
|
|
64
|
+
border-bottom: 1px dotted inherit
|
|
65
|
+
cursor: help
|
|
66
|
+
|
|
67
|
+
table
|
|
68
|
+
border-collapse: collapse
|
|
69
|
+
border-spacing: 0
|
|
70
|
+
|
|
71
|
+
/* change border colour to suit your needs
|
|
72
|
+
|
|
73
|
+
hr
|
|
74
|
+
display: block
|
|
75
|
+
height: 1px
|
|
76
|
+
border: 0
|
|
77
|
+
border-top: 1px solid #cccccc
|
|
78
|
+
margin: 1em 0
|
|
79
|
+
padding: 0
|
|
80
|
+
|
|
81
|
+
input, select
|
|
82
|
+
vertical-align: middle
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
$medium_gray: #cccccc
|
|
2
|
+
$light_gray: #eeeeee
|
|
3
|
+
$border_color: $medium_gray
|
|
4
|
+
|
|
5
|
+
$content_background_color: $light_gray
|
|
6
|
+
$header_color: #0d4c4c
|
|
7
|
+
$navigation_color: #3e707f
|
|
8
|
+
$standout_color: #429693
|
|
9
|
+
$text_color: #1b1d1e
|
|
10
|
+
$highlight_color: #fbffa4
|
|
11
|
+
$warning_background_color: red
|
|
12
|
+
$warning_color: white
|
|
13
|
+
$active_tab_color: $content_background_color
|
|
14
|
+
$link_color: #424e4f
|
|
15
|
+
$link_hover_color: $text_color
|
|
16
|
+
|
|
17
|
+
@import "mixins"
|
|
18
|
+
|
|
19
|
+
body
|
|
20
|
+
font-family: Verdana, Arial, Helvetica, sans-serif
|
|
21
|
+
font-size: 13px
|
|
22
|
+
color: $text_color
|
|
23
|
+
background-color: $content_background_color
|
|
24
|
+
min-width: 100px
|
|
25
|
+
|
|
26
|
+
#header
|
|
27
|
+
background-color: $header_color
|
|
28
|
+
padding-top: 15px
|
|
29
|
+
h1
|
|
30
|
+
margin-left: 30px
|
|
31
|
+
font-size: 1.2em
|
|
32
|
+
color: white
|
|
33
|
+
|
|
34
|
+
#navigation
|
|
35
|
+
@include clearfix
|
|
36
|
+
margin-top: 15px
|
|
37
|
+
padding-left: 10px
|
|
38
|
+
background-color: $navigation_color
|
|
39
|
+
a
|
|
40
|
+
display: block
|
|
41
|
+
float: left
|
|
42
|
+
padding: 5px 10px
|
|
43
|
+
color: $text_color
|
|
44
|
+
text-decoration: none
|
|
45
|
+
&:hover
|
|
46
|
+
@include highlighted-tab
|
|
47
|
+
|
|
48
|
+
#content-wrapper
|
|
49
|
+
padding: 0.5em
|
|
50
|
+
#content
|
|
51
|
+
@include rounded-corners
|
|
52
|
+
padding: 0.5em
|
|
53
|
+
background-color: white
|
|
54
|
+
border: 1px solid $border_color
|
|
55
|
+
min-height: 600px
|
|
56
|
+
a
|
|
57
|
+
color: $link_color
|
|
58
|
+
padding: 2px
|
|
59
|
+
&:hover
|
|
60
|
+
@include rounded-corners(3px)
|
|
61
|
+
text-decoration: none
|
|
62
|
+
background-color: $highlight_color
|
|
63
|
+
|
|
64
|
+
#flash
|
|
65
|
+
@include rounded-corners
|
|
66
|
+
border: 1px solid $border_color
|
|
67
|
+
padding: 0.5em
|
|
68
|
+
margin-bottom: 0.5em
|
|
69
|
+
color: black
|
|
70
|
+
background-color: $highlight_color
|
|
71
|
+
font-weight: bold
|
|
72
|
+
|
|
73
|
+
#footer
|
|
74
|
+
margin: 30px 0
|
|
75
|
+
text-align: center
|
|
76
|
+
|
|
77
|
+
.data-table
|
|
78
|
+
.data-row
|
|
79
|
+
td.label, td.value
|
|
80
|
+
border: 1px solid $border_color
|
|
81
|
+
.label
|
|
82
|
+
background-color: $light_gray
|
|
83
|
+
|
|
84
|
+
h1, h2
|
|
85
|
+
margin-bottom: 15px
|
|
86
|
+
|
|
87
|
+
h2
|
|
88
|
+
@include rounded-corners(3px)
|
|
89
|
+
background-color: $standout_color
|
|
90
|
+
line-height: 1.2em
|
|
91
|
+
padding: 2px 5px
|
|
92
|
+
|
|
93
|
+
td, th
|
|
94
|
+
padding: 3px
|
|
95
|
+
margin: 1px
|
|
96
|
+
form
|
|
97
|
+
display: inline
|
|
98
|
+
th
|
|
99
|
+
border-bottom: 1px solid $text_color
|
|
100
|
+
text-align: left
|
|
101
|
+
|
|
102
|
+
.actions,
|
|
103
|
+
.controls
|
|
104
|
+
font-size: 0.9em
|
|
105
|
+
form
|
|
106
|
+
display: inline
|
|
107
|
+
|
|
108
|
+
.actions
|
|
109
|
+
text-align: right
|
|
110
|
+
margin-bottom: 15px
|
|
111
|
+
|
|
112
|
+
.controls
|
|
113
|
+
margin-top: 15px
|
|
114
|
+
|
|
115
|
+
.status.paused,
|
|
116
|
+
.status.stopped
|
|
117
|
+
background-color: $warning_background_color
|
|
118
|
+
color: $warning_color
|
|
119
|
+
|
|
120
|
+
#evaluate
|
|
121
|
+
margin-top: 10px
|
|
122
|
+
#results
|
|
123
|
+
.result
|
|
124
|
+
background-color: $light_gray
|
|
125
|
+
border: 1px solid $medium_gray
|
|
126
|
+
margin: 3px
|
|
127
|
+
padding: 3px
|
|
128
|
+
&.exception
|
|
129
|
+
background-color: $warning_background_color
|
|
130
|
+
#script_form
|
|
131
|
+
background-color: $light_gray
|
|
132
|
+
border: 1px solid $medium_gray
|
|
133
|
+
margin: 3px
|
|
134
|
+
padding: 3px
|
|
135
|
+
textarea
|
|
136
|
+
width: 500px
|
|
137
|
+
height: 200px
|
|
138
|
+
|
|
139
|
+
@include selected-tab('apps')
|
|
140
|
+
@include selected-tab('queues')
|
|
141
|
+
@include selected-tab('queue', 'queues')
|
|
142
|
+
@include selected-tab('topics')
|
|
143
|
+
@include selected-tab('topic', 'topics')
|
|
144
|
+
@include selected-tab('message_processors')
|
|
145
|
+
@include selected-tab('message_processor', 'message_processors')
|
|
146
|
+
@include selected-tab('jobs')
|
|
147
|
+
@include selected-tab('job', 'jobs')
|
|
148
|
+
@include selected-tab('services')
|
|
149
|
+
@include selected-tab('service', 'services')
|
|
150
|
+
@include selected-tab('pools')
|
|
151
|
+
@include selected-tab('pool', 'pools')
|
|
152
|
+
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#destinations-index
|
|
2
|
+
%table
|
|
3
|
+
%tr
|
|
4
|
+
%th Name
|
|
5
|
+
%th App
|
|
6
|
+
%th Status
|
|
7
|
+
%th Messages
|
|
8
|
+
%th Delivering
|
|
9
|
+
%th Scheduled
|
|
10
|
+
%th Added
|
|
11
|
+
%th Consumers
|
|
12
|
+
%th
|
|
13
|
+
- @collection.each do |destination|
|
|
14
|
+
%tr
|
|
15
|
+
%td
|
|
16
|
+
= link_to( object_path( destination ), destination.display_name )
|
|
17
|
+
- if destination.is_a?( Backstage::Queue )
|
|
18
|
+
= destination.durable ? "(durable)" : "(non-durable)"
|
|
19
|
+
%td
|
|
20
|
+
- if destination.app
|
|
21
|
+
= link_to( object_path( destination.app ), destination.app_name )
|
|
22
|
+
- else
|
|
23
|
+
= destination.app_name
|
|
24
|
+
%td.status{:class => destination.status.downcase}= destination.status
|
|
25
|
+
%td= destination.message_count
|
|
26
|
+
%td= destination.delivering_count
|
|
27
|
+
%td= destination.scheduled_count
|
|
28
|
+
%td= destination.messages_added
|
|
29
|
+
%td= destination.consumer_count
|
|
30
|
+
%td
|
|
31
|
+
= link_to collection_path(destination, :messages), 'View Messages' unless destination.is_a?(Backstage::Topic)
|
|
32
|
+
- destination.available_actions.each do |action|
|
|
33
|
+
= action_button( destination, action )
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|