Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
Noah
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Noah
Commits
41913163
Commit
41913163
authored
Mar 18, 2011
by
John E. Vincent
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor routes (minus ephemerals) to match patterns
parent
88e0d993
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
108 additions
and
108 deletions
+108
-108
noah.rb
lib/noah.rb
+1
-1
application_routes.rb
lib/noah/application_routes.rb
+6
-6
configuration_routes.rb
lib/noah/configuration_routes.rb
+6
-6
host_routes.rb
lib/noah/host_routes.rb
+6
-6
service_routes.rb
lib/noah/service_routes.rb
+6
-6
watcher_routes.rb
lib/noah/watcher_routes.rb
+4
-4
noahapp_application_spec.rb
spec/noahapp_application_spec.rb
+10
-10
noahapp_configuration_spec.rb
spec/noahapp_configuration_spec.rb
+12
-12
noahapp_host_spec.rb
spec/noahapp_host_spec.rb
+10
-10
noahapp_service_spec.rb
spec/noahapp_service_spec.rb
+12
-12
noahapp_watcher_spec.rb
spec/noahapp_watcher_spec.rb
+20
-20
index.haml
views/index.haml
+15
-15
No files found.
lib/noah.rb
View file @
41913163
module
Noah
module
Noah
PROTECTED_PATHS
=
%w[a
c h s w
]
PROTECTED_PATHS
=
%w[a
pplications configurations hosts services watches
]
end
end
begin
begin
require
'yajl'
require
'yajl'
...
...
lib/noah/application_routes.rb
View file @
41913163
class
Noah
::
App
class
Noah
::
App
# Application URIs
# Application URIs
get
'/a/:appname/:config/?'
do
|
appname
,
config
|
get
'/a
pplications
/:appname/:config/?'
do
|
appname
,
config
|
app
=
Noah
::
Application
.
find
(
:name
=>
appname
).
first
app
=
Noah
::
Application
.
find
(
:name
=>
appname
).
first
if
app
.
nil?
if
app
.
nil?
halt
404
halt
404
...
@@ -10,7 +10,7 @@ class Noah::App
...
@@ -10,7 +10,7 @@ class Noah::App
end
end
end
end
get
'/a/:appname/?'
do
|
appname
|
get
'/a
pplications
/:appname/?'
do
|
appname
|
app
=
Noah
::
Application
.
find
(
:name
=>
appname
).
first
app
=
Noah
::
Application
.
find
(
:name
=>
appname
).
first
if
app
.
nil?
if
app
.
nil?
halt
404
halt
404
...
@@ -19,7 +19,7 @@ class Noah::App
...
@@ -19,7 +19,7 @@ class Noah::App
end
end
end
end
put
'/a/:appname/watch'
do
|
appname
|
put
'/a
pplications
/:appname/watch'
do
|
appname
|
required_params
=
[
"endpoint"
]
required_params
=
[
"endpoint"
]
data
=
JSON
.
parse
(
request
.
body
.
read
)
data
=
JSON
.
parse
(
request
.
body
.
read
)
(
data
.
keys
.
sort
==
required_params
.
sort
)
?
(
a
=
Noah
::
Application
.
find
(:
name
=>
appname
).
first
)
:
(
raise
"Missing Parameters"
)
(
data
.
keys
.
sort
==
required_params
.
sort
)
?
(
a
=
Noah
::
Application
.
find
(:
name
=>
appname
).
first
)
:
(
raise
"Missing Parameters"
)
...
@@ -27,7 +27,7 @@ class Noah::App
...
@@ -27,7 +27,7 @@ class Noah::App
w
.
to_json
w
.
to_json
end
end
put
'/a/:appname/?'
do
|
appname
|
put
'/a
pplications
/:appname/?'
do
|
appname
|
required_params
=
[
"name"
]
required_params
=
[
"name"
]
data
=
JSON
.
parse
(
request
.
body
.
read
)
data
=
JSON
.
parse
(
request
.
body
.
read
)
if
data
.
keys
.
sort
==
required_params
.
sort
&&
data
[
'name'
]
==
appname
if
data
.
keys
.
sort
==
required_params
.
sort
&&
data
[
'name'
]
==
appname
...
@@ -45,7 +45,7 @@ class Noah::App
...
@@ -45,7 +45,7 @@ class Noah::App
end
end
end
end
delete
'/a/:appname/?'
do
|
appname
|
delete
'/a
pplications
/:appname/?'
do
|
appname
|
app
=
Noah
::
Application
.
find
(
:name
=>
appname
).
first
app
=
Noah
::
Application
.
find
(
:name
=>
appname
).
first
if
app
.
nil?
if
app
.
nil?
halt
404
halt
404
...
@@ -58,7 +58,7 @@ class Noah::App
...
@@ -58,7 +58,7 @@ class Noah::App
end
end
end
end
get
'/a/?'
do
get
'/a
pplications
/?'
do
apps
=
[]
apps
=
[]
Noah
::
Application
.
all
.
sort
.
each
{
|
a
|
apps
<<
a
.
to_hash
}
Noah
::
Application
.
all
.
sort
.
each
{
|
a
|
apps
<<
a
.
to_hash
}
if
apps
.
empty?
if
apps
.
empty?
...
...
lib/noah/configuration_routes.rb
View file @
41913163
...
@@ -6,7 +6,7 @@ class Noah::App
...
@@ -6,7 +6,7 @@ class Noah::App
:string
=>
"text/plain"
:string
=>
"text/plain"
}
}
# Configuration URIs
# Configuration URIs
get
'/c/:appname/:element/?'
do
|
appname
,
element
|
get
'/c
onfigurations
/:appname/:element/?'
do
|
appname
,
element
|
a
=
Noah
::
Application
.
find
(
:name
=>
appname
).
first
a
=
Noah
::
Application
.
find
(
:name
=>
appname
).
first
if
a
.
nil?
if
a
.
nil?
halt
404
halt
404
...
@@ -17,7 +17,7 @@ class Noah::App
...
@@ -17,7 +17,7 @@ class Noah::App
end
end
end
end
get
'/c/:appname/?'
do
|
appname
|
get
'/c
onfigurations
/:appname/?'
do
|
appname
|
config
=
[]
config
=
[]
a
=
Noah
::
Application
.
find
(
:name
=>
appname
).
first
a
=
Noah
::
Application
.
find
(
:name
=>
appname
).
first
if
a
.
nil?
if
a
.
nil?
...
@@ -28,7 +28,7 @@ class Noah::App
...
@@ -28,7 +28,7 @@ class Noah::App
end
end
end
end
get
'/c/?'
do
get
'/c
onfigurations
/?'
do
configs
=
[]
configs
=
[]
Noah
::
Configuration
.
all
.
sort
.
each
{
|
c
|
configs
<<
c
.
to_hash
}
Noah
::
Configuration
.
all
.
sort
.
each
{
|
c
|
configs
<<
c
.
to_hash
}
if
configs
.
empty?
if
configs
.
empty?
...
@@ -38,7 +38,7 @@ class Noah::App
...
@@ -38,7 +38,7 @@ class Noah::App
end
end
end
end
put
'/c/:configname/watch'
do
|
configname
|
put
'/c
onfigurations
/:configname/watch'
do
|
configname
|
required_params
=
[
"endpoint"
]
required_params
=
[
"endpoint"
]
data
=
JSON
.
parse
(
request
.
body
.
read
)
data
=
JSON
.
parse
(
request
.
body
.
read
)
(
data
.
keys
.
sort
==
required_params
.
sort
)
?
(
c
=
Noah
::
Configuration
.
find
(:
name
=>
configname
).
first
)
:
(
raise
"Missing Parameters"
)
(
data
.
keys
.
sort
==
required_params
.
sort
)
?
(
c
=
Noah
::
Configuration
.
find
(:
name
=>
configname
).
first
)
:
(
raise
"Missing Parameters"
)
...
@@ -46,7 +46,7 @@ class Noah::App
...
@@ -46,7 +46,7 @@ class Noah::App
w
.
to_json
w
.
to_json
end
end
put
'/c/:appname/:element?'
do
|
appname
,
element
|
put
'/c
onfigurations
/:appname/:element?'
do
|
appname
,
element
|
app
=
Noah
::
Application
.
find_or_create
(
:name
=>
appname
)
app
=
Noah
::
Application
.
find_or_create
(
:name
=>
appname
)
config
=
Noah
::
Configuration
.
find_or_create
(
:name
=>
element
,
:application_id
=>
app
.
id
)
config
=
Noah
::
Configuration
.
find_or_create
(
:name
=>
element
,
:application_id
=>
app
.
id
)
required_params
=
[
"format"
,
"body"
]
required_params
=
[
"format"
,
"body"
]
...
@@ -63,7 +63,7 @@ class Noah::App
...
@@ -63,7 +63,7 @@ class Noah::App
end
end
end
end
delete
'/c/:appname/:element?'
do
|
appname
,
element
|
delete
'/c
onfigurations
/:appname/:element?'
do
|
appname
,
element
|
app
=
Noah
::
Application
.
find
(
:name
=>
appname
).
first
app
=
Noah
::
Application
.
find
(
:name
=>
appname
).
first
if
app
if
app
config
=
Noah
::
Configuration
.
find
(
:name
=>
element
,
:application_id
=>
app
.
id
).
first
config
=
Noah
::
Configuration
.
find
(
:name
=>
element
,
:application_id
=>
app
.
id
).
first
...
...
lib/noah/host_routes.rb
View file @
41913163
...
@@ -2,7 +2,7 @@ class Noah::App
...
@@ -2,7 +2,7 @@ class Noah::App
# Host URIs
# Host URIs
# GET named {Service} for named {Host}
# GET named {Service} for named {Host}
get
'/h/:hostname/:servicename/?'
do
|
hostname
,
servicename
|
get
'/h
osts
/:hostname/:servicename/?'
do
|
hostname
,
servicename
|
h
=
host_service
(
hostname
,
servicename
)
h
=
host_service
(
hostname
,
servicename
)
if
h
.
nil?
if
h
.
nil?
halt
404
halt
404
...
@@ -14,7 +14,7 @@ class Noah::App
...
@@ -14,7 +14,7 @@ class Noah::App
# GET named {Host}
# GET named {Host}
# @param :hostname name of {Host}
# @param :hostname name of {Host}
# @return [JSON] representation of {Host}
# @return [JSON] representation of {Host}
get
'/h/:hostname/?'
do
|
hostname
|
get
'/h
osts
/:hostname/?'
do
|
hostname
|
h
=
host
(
:name
=>
hostname
)
h
=
host
(
:name
=>
hostname
)
if
h
.
nil?
if
h
.
nil?
halt
404
halt
404
...
@@ -24,7 +24,7 @@ class Noah::App
...
@@ -24,7 +24,7 @@ class Noah::App
end
end
# GET all {Hosts}
# GET all {Hosts}
get
'/h/?'
do
get
'/h
osts
/?'
do
hosts
.
map
{
|
h
|
h
.
to_hash
}
hosts
.
map
{
|
h
|
h
.
to_hash
}
if
hosts
.
size
==
0
if
hosts
.
size
==
0
halt
404
halt
404
...
@@ -33,7 +33,7 @@ class Noah::App
...
@@ -33,7 +33,7 @@ class Noah::App
end
end
end
end
put
'/h/:hostname/watch'
do
|
hostname
|
put
'/h
osts
/:hostname/watch'
do
|
hostname
|
required_params
=
[
"endpoint"
]
required_params
=
[
"endpoint"
]
data
=
JSON
.
parse
(
request
.
body
.
read
)
data
=
JSON
.
parse
(
request
.
body
.
read
)
(
data
.
keys
.
sort
==
required_params
.
sort
)
?
(
h
=
Noah
::
Host
.
find
(:
name
=>
hostname
).
first
)
:
(
raise
"Missing Parameters"
)
(
data
.
keys
.
sort
==
required_params
.
sort
)
?
(
h
=
Noah
::
Host
.
find
(:
name
=>
hostname
).
first
)
:
(
raise
"Missing Parameters"
)
...
@@ -41,7 +41,7 @@ class Noah::App
...
@@ -41,7 +41,7 @@ class Noah::App
w
.
to_json
w
.
to_json
end
end
put
'/h/:hostname/?'
do
|
hostname
|
put
'/h
osts
/:hostname/?'
do
|
hostname
|
required_params
=
[
"name"
,
"status"
]
required_params
=
[
"name"
,
"status"
]
data
=
JSON
.
parse
(
request
.
body
.
read
)
data
=
JSON
.
parse
(
request
.
body
.
read
)
(
data
.
keys
.
sort
==
required_params
.
sort
&&
data
[
'name'
]
==
hostname
)
?
(
host
=
Noah
::
Host
.
find_or_create
(:
name
=>
data
[
'name'
],
:status
=>
data
[
'status'
]))
:
(
raise
"Missing Parameters"
)
(
data
.
keys
.
sort
==
required_params
.
sort
&&
data
[
'name'
]
==
hostname
)
?
(
host
=
Noah
::
Host
.
find_or_create
(:
name
=>
data
[
'name'
],
:status
=>
data
[
'status'
]))
:
(
raise
"Missing Parameters"
)
...
@@ -53,7 +53,7 @@ class Noah::App
...
@@ -53,7 +53,7 @@ class Noah::App
end
end
end
end
delete
'/h/:hostname/?'
do
|
hostname
|
delete
'/h
osts
/:hostname/?'
do
|
hostname
|
host
=
Noah
::
Host
.
find
(
:name
=>
hostname
).
first
host
=
Noah
::
Host
.
find
(
:name
=>
hostname
).
first
if
host
if
host
services
=
[]
services
=
[]
...
...
lib/noah/service_routes.rb
View file @
41913163
...
@@ -2,7 +2,7 @@ class Noah::App
...
@@ -2,7 +2,7 @@ class Noah::App
# Service URIs
# Service URIs
# get named {Service} for named {Host}
# get named {Service} for named {Host}
get
'/s/:servicename/:hostname/?'
do
|
servicename
,
hostname
|
get
'/s
ervices
/:servicename/:hostname/?'
do
|
servicename
,
hostname
|
hs
=
host_service
(
hostname
,
servicename
)
hs
=
host_service
(
hostname
,
servicename
)
if
hs
.
nil?
if
hs
.
nil?
halt
404
halt
404
...
@@ -11,7 +11,7 @@ class Noah::App
...
@@ -11,7 +11,7 @@ class Noah::App
end
end
end
end
get
'/s/:servicename/?'
do
|
servicename
|
get
'/s
ervices
/:servicename/?'
do
|
servicename
|
s
=
services
(
:name
=>
servicename
)
s
=
services
(
:name
=>
servicename
)
s
.
map
{
|
x
|
x
.
to_hash
}
s
.
map
{
|
x
|
x
.
to_hash
}
if
s
.
empty?
if
s
.
empty?
...
@@ -21,7 +21,7 @@ class Noah::App
...
@@ -21,7 +21,7 @@ class Noah::App
end
end
end
end
get
'/s/?'
do
get
'/s
ervices
/?'
do
if
services
.
empty?
if
services
.
empty?
halt
404
halt
404
else
else
...
@@ -30,7 +30,7 @@ class Noah::App
...
@@ -30,7 +30,7 @@ class Noah::App
end
end
end
end
put
'/s/:servicename/watch'
do
|
servicename
|
put
'/s
ervices
/:servicename/watch'
do
|
servicename
|
required_params
=
[
"endpoint"
]
required_params
=
[
"endpoint"
]
data
=
JSON
.
parse
(
request
.
body
.
read
)
data
=
JSON
.
parse
(
request
.
body
.
read
)
(
data
.
keys
.
sort
==
required_params
.
sort
)
?
(
s
=
Noah
::
Service
.
find
(:
name
=>
servicename
).
first
)
:
(
raise
"Missing Parameters"
)
(
data
.
keys
.
sort
==
required_params
.
sort
)
?
(
s
=
Noah
::
Service
.
find
(:
name
=>
servicename
).
first
)
:
(
raise
"Missing Parameters"
)
...
@@ -38,7 +38,7 @@ class Noah::App
...
@@ -38,7 +38,7 @@ class Noah::App
w
.
to_json
w
.
to_json
end
end
put
'/s/:servicename/?'
do
|
servicename
|
put
'/s
ervices
/:servicename/?'
do
|
servicename
|
required_params
=
[
"status"
,
"host"
,
"name"
]
required_params
=
[
"status"
,
"host"
,
"name"
]
data
=
JSON
.
parse
(
request
.
body
.
read
)
data
=
JSON
.
parse
(
request
.
body
.
read
)
if
data
.
keys
.
sort
==
required_params
.
sort
if
data
.
keys
.
sort
==
required_params
.
sort
...
@@ -57,7 +57,7 @@ class Noah::App
...
@@ -57,7 +57,7 @@ class Noah::App
end
end
end
end
delete
'/s/:servicename/:hostname/?'
do
|
servicename
,
hostname
|
delete
'/s
ervices
/:servicename/:hostname/?'
do
|
servicename
,
hostname
|
host
=
Noah
::
Host
.
find
(
:name
=>
hostname
).
first
||
(
halt
404
)
host
=
Noah
::
Host
.
find
(
:name
=>
hostname
).
first
||
(
halt
404
)
service
=
Noah
::
Service
.
find
(
:name
=>
servicename
,
:host_id
=>
host
.
id
).
first
||
(
halt
404
)
service
=
Noah
::
Service
.
find
(
:name
=>
servicename
,
:host_id
=>
host
.
id
).
first
||
(
halt
404
)
if
host
&&
service
if
host
&&
service
...
...
lib/noah/watcher_routes.rb
View file @
41913163
class
Noah
::
App
class
Noah
::
App
get
'/w/:name'
do
|
name
|
get
'/w
atches
/:name'
do
|
name
|
w
=
Noah
::
Watcher
.
find_by_name
(
name
)
w
=
Noah
::
Watcher
.
find_by_name
(
name
)
w
.
nil?
?
(
halt
404
)
:
w
.
to_json
w
.
nil?
?
(
halt
404
)
:
w
.
to_json
end
end
get
'/w/?'
do
get
'/w
atches
/?'
do
w
=
Noah
::
Watcher
.
all
.
sort_by
(
:pattern
)
w
=
Noah
::
Watcher
.
all
.
sort_by
(
:pattern
)
if
w
.
size
==
0
if
w
.
size
==
0
halt
404
halt
404
...
@@ -14,7 +14,7 @@ class Noah::App
...
@@ -14,7 +14,7 @@ class Noah::App
end
end
end
end
put
'/w/?'
do
put
'/w
atches
/?'
do
required_params
=
%w[endpoint pattern]
required_params
=
%w[endpoint pattern]
data
=
JSON
.
parse
(
request
.
body
.
read
)
data
=
JSON
.
parse
(
request
.
body
.
read
)
(
data
.
keys
.
sort
==
required_params
.
sort
)
?
(
pattern
,
endpoint
=
data
[
'pattern'
],
data
[
'endpoint'
])
:
(
raise
"Missing Parameters"
)
(
data
.
keys
.
sort
==
required_params
.
sort
)
?
(
pattern
,
endpoint
=
data
[
'pattern'
],
data
[
'endpoint'
])
:
(
raise
"Missing Parameters"
)
...
@@ -28,7 +28,7 @@ class Noah::App
...
@@ -28,7 +28,7 @@ class Noah::App
end
end
end
end
delete
'/w/?'
do
delete
'/w
atches
/?'
do
required_params
=
%w[endpoint pattern]
required_params
=
%w[endpoint pattern]
data
=
JSON
.
parse
(
request
.
body
.
read
)
data
=
JSON
.
parse
(
request
.
body
.
read
)
(
data
.
keys
.
sort
==
required_params
.
sort
)
?
(
pattern
,
endpoint
=
data
[
'pattern'
],
data
[
'endpoint'
])
:
(
raise
"Missing Parameters"
)
(
data
.
keys
.
sort
==
required_params
.
sort
)
?
(
pattern
,
endpoint
=
data
[
'pattern'
],
data
[
'endpoint'
])
:
(
raise
"Missing Parameters"
)
...
...
spec/noahapp_application_spec.rb
View file @
41913163
...
@@ -11,13 +11,13 @@ describe "Using the Application API", :reset_redis => false do
...
@@ -11,13 +11,13 @@ describe "Using the Application API", :reset_redis => false do
describe
"GET"
do
describe
"GET"
do
it
"all applications should work"
do
it
"all applications should work"
do
get
'/a'
get
'/a
pplications
'
last_response
.
should
be_ok
last_response
.
should
be_ok
response
=
last_response
.
should
return_json
response
=
last_response
.
should
return_json
response
.
is_a?
(
Array
).
should
==
true
response
.
is_a?
(
Array
).
should
==
true
end
end
it
"named application should work"
do
it
"named application should work"
do
get
'/a/rspec_sample_app'
get
'/a
pplications
/rspec_sample_app'
last_response
.
should
be_ok
last_response
.
should
be_ok
response
=
last_response
.
should
return_json
response
=
last_response
.
should
return_json
...
@@ -30,7 +30,7 @@ describe "Using the Application API", :reset_redis => false do
...
@@ -30,7 +30,7 @@ describe "Using the Application API", :reset_redis => false do
c
[
"format"
].
should
==
@c
.
format
c
[
"format"
].
should
==
@c
.
format
end
end
it
"named configuration for application should work"
do
it
"named configuration for application should work"
do
get
"/a/
#{
@a
.
name
}
/
#{
@c
.
name
}
"
get
"/a
pplications
/
#{
@a
.
name
}
/
#{
@c
.
name
}
"
last_response
.
should
be_ok
last_response
.
should
be_ok
response
=
last_response
.
should
return_json
response
=
last_response
.
should
return_json
...
@@ -41,11 +41,11 @@ describe "Using the Application API", :reset_redis => false do
...
@@ -41,11 +41,11 @@ describe "Using the Application API", :reset_redis => false do
response
[
"application"
].
should
==
@a
.
name
response
[
"application"
].
should
==
@a
.
name
end
end
it
"invalid application should not work"
do
it
"invalid application should not work"
do
get
"/a/should_not_exist"
get
"/a
pplications
/should_not_exist"
last_response
.
should
be_missing
last_response
.
should
be_missing
end
end
it
"invalid configuration for application should not work"
do
it
"invalid configuration for application should not work"
do
get
"/a/should_not_exist/should_not_exist"
get
"/a
pplications
/should_not_exist/should_not_exist"
last_response
.
should
be_missing
last_response
.
should
be_missing
end
end
end
end
...
@@ -55,7 +55,7 @@ describe "Using the Application API", :reset_redis => false do
...
@@ -55,7 +55,7 @@ describe "Using the Application API", :reset_redis => false do
@appdata
=
{
:name
=>
"should_now_exist"
}
@appdata
=
{
:name
=>
"should_now_exist"
}
end
end
it
"new application should work"
do
it
"new application should work"
do
put
"/a/
#{
@appdata
[
:name
]
}
"
,
@appdata
.
to_json
,
"CONTENT_TYPE"
=>
"application/json"
put
"/a
pplications
/
#{
@appdata
[
:name
]
}
"
,
@appdata
.
to_json
,
"CONTENT_TYPE"
=>
"application/json"
last_response
.
should
be_ok
last_response
.
should
be_ok
response
=
last_response
.
should
return_json
response
=
last_response
.
should
return_json
response
[
"result"
].
should
==
"success"
response
[
"result"
].
should
==
"success"
...
@@ -66,13 +66,13 @@ describe "Using the Application API", :reset_redis => false do
...
@@ -66,13 +66,13 @@ describe "Using the Application API", :reset_redis => false do
Noah
::
Application
.
find
(
:name
=>
@appdata
[
:name
]).
first
.
is_new?
.
should
==
true
Noah
::
Application
.
find
(
:name
=>
@appdata
[
:name
]).
first
.
is_new?
.
should
==
true
end
end
it
"new application with missing name should not work"
do
it
"new application with missing name should not work"
do
put
"/a/should_not_work"
,
'{"foo":"bar"}'
,
"CONTENT_TYPE"
=>
"application/json"
put
"/a
pplications
/should_not_work"
,
'{"foo":"bar"}'
,
"CONTENT_TYPE"
=>
"application/json"
last_response
.
should
be_invalid
last_response
.
should
be_invalid
end
end
it
"existing application should work"
do
it
"existing application should work"
do
sleep
3
sleep
3
put
"/a/
#{
@appdata
[
:name
]
}
"
,
@appdata
.
to_json
,
"CONTENT_TYPE"
=>
"application/json"
put
"/a
pplications
/
#{
@appdata
[
:name
]
}
"
,
@appdata
.
to_json
,
"CONTENT_TYPE"
=>
"application/json"
last_response
.
should
be_ok
last_response
.
should
be_ok
response
=
last_response
.
should
return_json
response
=
last_response
.
should
return_json
response
[
"result"
].
should
==
"success"
response
[
"result"
].
should
==
"success"
...
@@ -89,7 +89,7 @@ describe "Using the Application API", :reset_redis => false do
...
@@ -89,7 +89,7 @@ describe "Using the Application API", :reset_redis => false do
@appdata
=
{
:name
=>
"should_now_exist"
}
@appdata
=
{
:name
=>
"should_now_exist"
}
end
end
it
"existing application should work"
do
it
"existing application should work"
do
delete
"/a/
#{
@appdata
[
:name
]
}
"
delete
"/a
pplications
/
#{
@appdata
[
:name
]
}
"
last_response
.
should
be_ok
last_response
.
should
be_ok
response
=
last_response
.
should
return_json
response
=
last_response
.
should
return_json
response
[
"result"
].
should
==
"success"
response
[
"result"
].
should
==
"success"
...
@@ -99,7 +99,7 @@ describe "Using the Application API", :reset_redis => false do
...
@@ -99,7 +99,7 @@ describe "Using the Application API", :reset_redis => false do
response
[
"configurations"
].
should
==
"0"
response
[
"configurations"
].
should
==
"0"
end
end
it
"invalid application should not work"
do
it
"invalid application should not work"
do
delete
"/a/should_not_work"
delete
"/a
pplications
/should_not_work"
last_response
.
should
be_missing
last_response
.
should
be_missing
end
end
end
end
...
...
spec/noahapp_configuration_spec.rb
View file @
41913163
...
@@ -5,12 +5,12 @@ describe "Using the Configuration API", :reset_redis => false, :populate_sample_
...
@@ -5,12 +5,12 @@ describe "Using the Configuration API", :reset_redis => false, :populate_sample_
describe
"GET"
do
describe
"GET"
do
it
"all configurations should work"
do
it
"all configurations should work"
do
get
'/c'
get
'/c
onfigurations
'
last_response
.
should
be_ok
last_response
.
should
be_ok
last_response
.
should
return_json
last_response
.
should
return_json
end
end
it
"named application should work"
do
it
"named application should work"
do
get
'/c/noah'
get
'/c
onfigurations
/noah'
last_response
.
should
be_ok
last_response
.
should
be_ok
response
=
last_response
.
should
return_json
response
=
last_response
.
should
return_json
...
@@ -21,14 +21,14 @@ describe "Using the Configuration API", :reset_redis => false, :populate_sample_
...
@@ -21,14 +21,14 @@ describe "Using the Configuration API", :reset_redis => false, :populate_sample_
response
.
first
[
"application"
].
should
==
"noah"
response
.
first
[
"application"
].
should
==
"noah"
end
end
it
"named configuration for application should work"
do
it
"named configuration for application should work"
do
get
'/c/noah/redis'
get
'/c
onfigurations
/noah/redis'
last_response
.
should
be_ok
last_response
.
should
be_ok
response
=
last_response
.
body
response
=
last_response
.
body
response
.
should
==
"redis://127.0.0.1:6379/0"
response
.
should
==
"redis://127.0.0.1:6379/0"
end
end
it
"named configuration should work with mime-type"
do
it
"named configuration should work with mime-type"
do
require
'yaml'
require
'yaml'
get
'/c/myrailsapp1/database.yml'
get
'/c
onfigurations
/myrailsapp1/database.yml'
last_response
.
should
be_ok
last_response
.
should
be_ok
last_response
.
headers
[
"Content-Type"
].
should
==
"text/x-yaml;charset=utf-8"
last_response
.
headers
[
"Content-Type"
].
should
==
"text/x-yaml;charset=utf-8"
response
=
YAML
.
load
(
last_response
.
body
)
response
=
YAML
.
load
(
last_response
.
body
)
...
@@ -38,11 +38,11 @@ describe "Using the Configuration API", :reset_redis => false, :populate_sample_
...
@@ -38,11 +38,11 @@ describe "Using the Configuration API", :reset_redis => false, :populate_sample_
response
[
"development"
].
values
.
sort
.
should
==
[
"dev_password"
,
"dev_user"
,
"development_database"
,
"mysql"
]
response
[
"development"
].
values
.
sort
.
should
==
[
"dev_password"
,
"dev_user"
,
"development_database"
,
"mysql"
]
end
end
it
"invalid application should not work"
do
it
"invalid application should not work"
do
get
'/c/badapp'
get
'/c
onfigurations
/badapp'
last_response
.
should
be_missing
last_response
.
should
be_missing
end
end
it
"invalid configuration for application should not work"
do
it
"invalid configuration for application should not work"
do
get
'/c/badapp/badconfig'
get
'/c
onfigurations
/badapp/badconfig'
last_response
.
should
be_missing
last_response
.
should
be_missing
end
end
end
end
...
@@ -50,7 +50,7 @@ describe "Using the Configuration API", :reset_redis => false, :populate_sample_
...
@@ -50,7 +50,7 @@ describe "Using the Configuration API", :reset_redis => false, :populate_sample_
describe
"PUT"
do
describe
"PUT"
do
it
"new configuration should work"
do
it
"new configuration should work"
do
config_data
=
{
:format
=>
"string"
,
:body
=>
"sample_config_entry"
}.
to_json
config_data
=
{
:format
=>
"string"
,
:body
=>
"sample_config_entry"
}.
to_json
put
'/c/newapp/newconfig'
,
config_data
,
"CONTENT_TYPE"
=>
"application/json"
put
'/c
onfigurations
/newapp/newconfig'
,
config_data
,
"CONTENT_TYPE"
=>
"application/json"
last_response
.
should
be_ok
last_response
.
should
be_ok
response
=
last_response
.
should
return_json
response
=
last_response
.
should
return_json
response
[
"result"
].
should
==
"success"
response
[
"result"
].
should
==
"success"
...
@@ -62,7 +62,7 @@ describe "Using the Configuration API", :reset_redis => false, :populate_sample_
...
@@ -62,7 +62,7 @@ describe "Using the Configuration API", :reset_redis => false, :populate_sample_
it
"existing configuration should work"
do
it
"existing configuration should work"
do
config_data
=
{
:format
=>
"string"
,
:body
=>
"sample_config_entry"
}.
to_json
config_data
=
{
:format
=>
"string"
,
:body
=>
"sample_config_entry"
}.
to_json
sleep
3
sleep
3
put
'/c/newapp/newconfig'
,
config_data
,
"CONTENT_TYPE"
=>
"application/json"
put
'/c
onfigurations
/newapp/newconfig'
,
config_data
,
"CONTENT_TYPE"
=>
"application/json"
last_response
.
should
be_ok
last_response
.
should
be_ok
response
=
last_response
.
should
return_json
response
=
last_response
.
should
return_json
response
[
"result"
].
should
==
"success"
response
[
"result"
].
should
==
"success"
...
@@ -73,12 +73,12 @@ describe "Using the Configuration API", :reset_redis => false, :populate_sample_
...
@@ -73,12 +73,12 @@ describe "Using the Configuration API", :reset_redis => false, :populate_sample_
end
end
it
"new configuration with missing format should not work"
do
it
"new configuration with missing format should not work"
do
config_data
=
{
:body
=>
"a string"
}.
to_json
config_data
=
{
:body
=>
"a string"
}.
to_json
put
'/c/newnewapp/someconfig'
,
config_data
,
"CONTENT_TYPE"
=>
"application/json"
put
'/c
onfigurations
/newnewapp/someconfig'
,
config_data
,
"CONTENT_TYPE"
=>
"application/json"
last_response
.
should
be_invalid
last_response
.
should
be_invalid
end
end
it
"new configuration with missing body should not work"
do
it
"new configuration with missing body should not work"
do
config_data
=
{
:body
=>
"a string"
}.
to_json
config_data
=
{
:body
=>
"a string"
}.
to_json
put
'/c/newnewapp/someconfig'
,
config_data
,
"CONTENT_TYPE"
=>
"application/json"
put
'/c
onfigurations
/newnewapp/someconfig'
,
config_data
,
"CONTENT_TYPE"
=>
"application/json"
last_response
.
should
be_invalid
last_response
.
should
be_invalid
end
end
end
end
...
@@ -93,7 +93,7 @@ describe "Using the Configuration API", :reset_redis => false, :populate_sample_
...
@@ -93,7 +93,7 @@ describe "Using the Configuration API", :reset_redis => false, :populate_sample_
end
end
it
"existing configuration should work"
do
it
"existing configuration should work"
do
delete
"/c/
#{
@a
.
name
}
/
#{
@c
.
name
}
"
delete
"/c
onfigurations
/
#{
@a
.
name
}
/
#{
@c
.
name
}
"
last_response
.
should
be_ok
last_response
.
should
be_ok
response
=
last_response
.
should
return_json
response
=
last_response
.
should
return_json
response
[
"result"
].
should
==
"success"
response
[
"result"
].
should
==
"success"
...
@@ -103,7 +103,7 @@ describe "Using the Configuration API", :reset_redis => false, :populate_sample_
...
@@ -103,7 +103,7 @@ describe "Using the Configuration API", :reset_redis => false, :populate_sample_
response
[
"item"
].
should
==
@c
.
name
response
[
"item"
].
should
==
@c
.
name
end
end
it
"invalid configuration should not work"
do
it
"invalid configuration should not work"
do
delete
"/c/
#{
@a
.
name
}
/
#{
@c
.
name
}
"
delete
"/c
onfigurations
/
#{
@a
.
name
}
/
#{
@c
.
name
}
"
last_response
.
should
be_missing
last_response
.
should
be_missing
end
end
end
end
...
...
spec/noahapp_host_spec.rb
View file @
41913163
...
@@ -5,13 +5,13 @@ describe "Using the Host API", :reset_redis => false, :populate_sample_data => t
...
@@ -5,13 +5,13 @@ describe "Using the Host API", :reset_redis => false, :populate_sample_data => t
describe
"GET"
do
describe
"GET"
do
it
"all hosts should work"
do
it
"all hosts should work"
do
get
'/h'
get
'/h
osts
'
last_response
.
should
be_ok
last_response
.
should
be_ok
last_response
.
should
return_json
last_response
.
should
return_json
end
end
it
"existing host should work"
do
it
"existing host should work"
do
get
'/h/localhost'
get
'/h
osts
/localhost'
last_response
.
should
be_ok
last_response
.
should
be_ok
response
=
last_response
.
should
return_json
response
=
last_response
.
should
return_json
...
@@ -29,7 +29,7 @@ describe "Using the Host API", :reset_redis => false, :populate_sample_data => t
...
@@ -29,7 +29,7 @@ describe "Using the Host API", :reset_redis => false, :populate_sample_data => t
end
end
it
"named service for host should work"
do
it
"named service for host should work"
do
get
'/h/localhost/noah'
get
'/h
osts
/localhost/noah'
last_response
.
should
be_ok
last_response
.
should
be_ok
response
=
last_response
.
should
return_json
response
=
last_response
.
should
return_json
...
@@ -42,7 +42,7 @@ describe "Using the Host API", :reset_redis => false, :populate_sample_data => t
...
@@ -42,7 +42,7 @@ describe "Using the Host API", :reset_redis => false, :populate_sample_data => t
describe
"PUT"
do
describe
"PUT"
do
it
"new host should work"
do
it
"new host should work"
do
host_data
=
{
:name
=>
"host99.domain.com"
,
:status
=>
"down"
}.
to_json
host_data
=
{
:name
=>
"host99.domain.com"
,
:status
=>
"down"
}.
to_json
put
'/h/host99.domain.com'
,
host_data
,
"CONTENT_TYPE"
=>
"application/json"
put
'/h
osts
/host99.domain.com'
,
host_data
,
"CONTENT_TYPE"
=>
"application/json"
last_response
.
should
be_ok
last_response
.
should
be_ok
response
=
last_response
.
should
return_json
response
=
last_response
.
should
return_json
...
@@ -56,7 +56,7 @@ describe "Using the Host API", :reset_redis => false, :populate_sample_data => t
...
@@ -56,7 +56,7 @@ describe "Using the Host API", :reset_redis => false, :populate_sample_data => t
it
"existing host should work"
do
it
"existing host should work"
do
sleep
3
sleep
3
host_data
=
{
:name
=>
"host99.domain.com"
,
:status
=>
"pending"
}.
to_json
host_data
=
{
:name
=>
"host99.domain.com"
,
:status
=>
"pending"
}.
to_json
put
'/h/host99.domain.com'
,
host_data
,
"CONTENT_TYPE"
=>
"application/json"
put
'/h
osts
/host99.domain.com'
,
host_data
,
"CONTENT_TYPE"
=>
"application/json"
last_response
.
should
be_ok
last_response
.
should
be_ok
response
=
last_response
.
should
return_json
response
=
last_response
.
should
return_json
...
@@ -65,19 +65,19 @@ describe "Using the Host API", :reset_redis => false, :populate_sample_data => t
...
@@ -65,19 +65,19 @@ describe "Using the Host API", :reset_redis => false, :populate_sample_data => t
it
"host missing name parameter should not work"
do
it
"host missing name parameter should not work"
do
host_data
=
{
:status
=>
"pending"
}.
to_json
host_data
=
{
:status
=>
"pending"
}.
to_json
put
'/h/host100.domain.com'
,
host_data
,
"CONTENT_TYPE"
=>
"application/json"
put
'/h
osts
/host100.domain.com'
,
host_data
,
"CONTENT_TYPE"
=>
"application/json"
last_response
.
should
be_invalid
last_response
.
should
be_invalid
end
end
it
"host missing status parameter should not work"
do
it
"host missing status parameter should not work"
do
host_data
=
{
:name
=>
"host100.domain.com"
}.
to_json
host_data
=
{
:name
=>
"host100.domain.com"
}.
to_json
put
'/h/host100.domain.com'
,
host_data
,
"CONTENT_TYPE"
=>
"application/json"
put
'/h
osts
/host100.domain.com'
,
host_data
,
"CONTENT_TYPE"
=>
"application/json"
last_response
.
should
be_invalid
last_response
.
should
be_invalid
end
end
it
"host with invalid status parameter should not work"
do
it
"host with invalid status parameter should not work"
do
host_data
=
{
:name
=>
"host100.domain.com"
,
:status
=>
"fscked"
}.
to_json
host_data
=
{
:name
=>
"host100.domain.com"
,
:status
=>
"fscked"
}.
to_json
put
'/h/host100.domain.com'
,
host_data
,
"CONTENT_TYPE"
=>
"application/json"
put
'/h
osts
/host100.domain.com'
,
host_data
,
"CONTENT_TYPE"
=>
"application/json"
last_response
.
should_not
be_ok
last_response
.
should_not
be_ok
response
=
last_response
.
should
return_json
response
=
last_response
.
should
return_json
...
@@ -96,7 +96,7 @@ describe "Using the Host API", :reset_redis => false, :populate_sample_data => t
...
@@ -96,7 +96,7 @@ describe "Using the Host API", :reset_redis => false, :populate_sample_data => t
end
end
it
"existing host should work"
do
it
"existing host should work"
do
svc_size
=
@h
.
services
.
size
svc_size
=
@h
.
services
.
size
delete
"/h/
#{
@h
.
name
}
"
delete
"/h
osts
/
#{
@h
.
name
}
"
last_response
.
should
be_ok
last_response
.
should
be_ok
response
=
last_response
.
should
return_json
response
=
last_response
.
should
return_json
...
@@ -107,7 +107,7 @@ describe "Using the Host API", :reset_redis => false, :populate_sample_data => t
...
@@ -107,7 +107,7 @@ describe "Using the Host API", :reset_redis => false, :populate_sample_data => t
end
end
it
"invalid host should not work"
do
it
"invalid host should not work"
do
delete
"/h/
#{
@h
.
name
}
"
delete
"/h
osts
/
#{
@h
.
name
}
"
last_response
.
should
be_missing
last_response
.
should
be_missing
end
end
end
end
...
...
spec/noahapp_service_spec.rb
View file @
41913163
...
@@ -13,13 +13,13 @@ describe "Using the Service API", :reset_redis => false, :populate_sample_data =
...
@@ -13,13 +13,13 @@ describe "Using the Service API", :reset_redis => false, :populate_sample_data =
describe
"GET"
do
describe
"GET"
do
it
"all services should work"
do
it
"all services should work"
do
get
'/s'
get
'/s
ervices
'
last_response
.
should
be_ok
last_response
.
should
be_ok
response
=
last_response
.
should
return_json
response
=
last_response
.
should
return_json
response
.
is_a?
(
Array
).
should
==
true
response
.
is_a?
(
Array
).
should
==
true
end
end
it
"all named services should work"
do
it
"all named services should work"
do
get
"/s/
#{
@sample_service
[
:name
]
}
"
get
"/s
ervices
/
#{
@sample_service
[
:name
]
}
"
last_response
.
should
be_ok
last_response
.
should
be_ok
response
=
last_response
.
should
return_json
response
=
last_response
.
should
return_json
response
.
is_a?
(
Array
).
should
==
true
response
.
is_a?
(
Array
).
should
==
true
...
@@ -30,7 +30,7 @@ describe "Using the Service API", :reset_redis => false, :populate_sample_data =
...
@@ -30,7 +30,7 @@ describe "Using the Service API", :reset_redis => false, :populate_sample_data =
s
[
"host"
].
should
==
@h
.
name
s
[
"host"
].
should
==
@h
.
name
end
end
it
"named service for host should work"
do
it
"named service for host should work"
do
get
"/s/
#{
@sample_service
[
:name
]
}
/
#{
@sample_host
[
:name
]
}
"
get
"/s
ervices
/
#{
@sample_service
[
:name
]
}
/
#{
@sample_host
[
:name
]
}
"
last_response
.
should
be_ok
last_response
.
should
be_ok
response
=
last_response
.
should
return_json
response
=
last_response
.
should
return_json
response
[
"id"
].
should
==
@s
.
id
response
[
"id"
].
should
==
@s
.
id
...
@@ -39,7 +39,7 @@ describe "Using the Service API", :reset_redis => false, :populate_sample_data =
...
@@ -39,7 +39,7 @@ describe "Using the Service API", :reset_redis => false, :populate_sample_data =
response
[
"host"
].
should
==
@h
.
name
response
[
"host"
].
should
==
@h
.
name
end
end
it
"missing service for host should not work"
do
it
"missing service for host should not work"
do
get
'/s/foobar/baz'
get
'/s
ervices
/foobar/baz'
last_response
.
should
be_missing
last_response
.
should
be_missing
end
end
end
end
...
@@ -49,7 +49,7 @@ describe "Using the Service API", :reset_redis => false, :populate_sample_data =
...
@@ -49,7 +49,7 @@ describe "Using the Service API", :reset_redis => false, :populate_sample_data =
@payload
=
{
:name
=>
'another_rspec_service'
,
:status
=>
'up'
,
:host
=>
@h
.
name
}
@payload
=
{
:name
=>
'another_rspec_service'
,
:status
=>
'up'
,
:host
=>
@h
.
name
}
end
end
it
"new service should work"
do
it
"new service should work"
do
put
"/s/
#{
@payload
[
:name
]
}
/"
,
@payload
.
to_json
,
"CONTENT_TYPE"
=>
"application/json"
put
"/s
ervices
/
#{
@payload
[
:name
]
}
/"
,
@payload
.
to_json
,
"CONTENT_TYPE"
=>
"application/json"
last_response
.
should
be_ok
last_response
.
should
be_ok
response
=
last_response
.
should
return_json
response
=
last_response
.
should
return_json
response
[
"result"
].
should
==
"success"
response
[
"result"
].
should
==
"success"
...
@@ -61,26 +61,26 @@ describe "Using the Service API", :reset_redis => false, :populate_sample_data =
...
@@ -61,26 +61,26 @@ describe "Using the Service API", :reset_redis => false, :populate_sample_data =
Noah
::
Service
.
find
(
:name
=>
@payload
[
:name
]).
first
.
is_new?
.
should
==
true
Noah
::
Service
.
find
(
:name
=>
@payload
[
:name
]).
first
.
is_new?
.
should
==
true
end
end
it
"new service without host should not work"
do
it
"new service without host should not work"
do
put
"/s/foobar"
,
{
:name
=>
"foobar"
,
:status
=>
"up"
}.
to_json
,
"CONTENT_TYPE"
=>
"application/json"
put
"/s
ervices
/foobar"
,
{
:name
=>
"foobar"
,
:status
=>
"up"
}.
to_json
,
"CONTENT_TYPE"
=>
"application/json"
last_response
.
should
be_invalid
last_response
.
should
be_invalid
end
end
it
"new service with invalid status should not work"
do
it
"new service with invalid status should not work"
do
put
"/s/foobar"
,
{
:name
=>
"foobar"
,
:status
=>
"fsck"
,
:host
=>
@h
.
name
}.
to_json
,
"CONTENT_TYPE"
=>
"application/json"
put
"/s
ervices
/foobar"
,
{
:name
=>
"foobar"
,
:status
=>
"fsck"
,
:host
=>
@h
.
name
}.
to_json
,
"CONTENT_TYPE"
=>
"application/json"
last_response
.
should_not
be_ok
last_response
.
should_not
be_ok
response
=
last_response
.
should
return_json
response
=
last_response
.
should
return_json
response
[
"error_message"
].
should
==
"Status must be up, down or pending"
response
[
"error_message"
].
should
==
"Status must be up, down or pending"
end
end
it
"new service with missing name should not work"
do
it
"new service with missing name should not work"
do
put
"/s/foobar"
,
{
:status
=>
"fsck"
,
:host
=>
@h
.
name
}.
to_json
,
"CONTENT_TYPE"
=>
"application/json"
put
"/s
ervices
/foobar"
,
{
:status
=>
"fsck"
,
:host
=>
@h
.
name
}.
to_json
,
"CONTENT_TYPE"
=>
"application/json"
last_response
.
should
be_invalid
last_response
.
should
be_invalid
end
end
it
"new service with missing status should not work"
do
it
"new service with missing status should not work"
do
put
"/s/foobar"
,
{
:name
=>
"foobar"
,
:host
=>
@h
.
name
}.
to_json
,
"CONTENT_TYPE"
=>
"application/json"
put
"/s
ervices
/foobar"
,
{
:name
=>
"foobar"
,
:host
=>
@h
.
name
}.
to_json
,
"CONTENT_TYPE"
=>
"application/json"
last_response
.
should
be_invalid
last_response
.
should
be_invalid
end
end
it
"existing service should work"
do
it
"existing service should work"
do
sleep
3
sleep
3
put
"/s/
#{
@payload
[
:name
]
}
"
,
{
:name
=>
@payload
[
:name
],
:status
=>
"down"
,
:host
=>
@payload
[
:host
]}.
to_json
,
"CONTENT_TYPE"
=>
"application/json"
put
"/s
ervices
/
#{
@payload
[
:name
]
}
"
,
{
:name
=>
@payload
[
:name
],
:status
=>
"down"
,
:host
=>
@payload
[
:host
]}.
to_json
,
"CONTENT_TYPE"
=>
"application/json"
last_response
.
should
be_ok
last_response
.
should
be_ok
response
=
last_response
.
should
return_json
response
=
last_response
.
should
return_json
response
[
"result"
].
should
==
"success"
response
[
"result"
].
should
==
"success"
...
@@ -101,7 +101,7 @@ describe "Using the Service API", :reset_redis => false, :populate_sample_data =
...
@@ -101,7 +101,7 @@ describe "Using the Service API", :reset_redis => false, :populate_sample_data =
@s
=
@h
.
services
.
first
@s
=
@h
.
services
.
first
end
end
it
"existing host should work"
do
it
"existing host should work"
do
delete
"/s/
#{
@s
.
name
}
/
#{
@h
.
name
}
"
delete
"/s
ervices
/
#{
@s
.
name
}
/
#{
@h
.
name
}
"
last_response
.
should
be_ok
last_response
.
should
be_ok
response
=
last_response
.
should
return_json
response
=
last_response
.
should
return_json
...
@@ -112,7 +112,7 @@ describe "Using the Service API", :reset_redis => false, :populate_sample_data =
...
@@ -112,7 +112,7 @@ describe "Using the Service API", :reset_redis => false, :populate_sample_data =
response
[
"service"
].
should
==
@s
.
name
response
[
"service"
].
should
==
@s
.
name
end
end
it
"invalid host should not work"
do
it
"invalid host should not work"
do
delete
"/s/
#{
@s
.
name
}
/
#{
@h
.
name
}
"
delete
"/s
ervices
/
#{
@s
.
name
}
/
#{
@h
.
name
}
"
last_response
.
should
be_missing
last_response
.
should
be_missing
end
end
end
end
...
...
spec/noahapp_watcher_spec.rb
View file @
41913163
...
@@ -22,7 +22,7 @@ describe "Using the Watcher API", :reset_redis => true do
...
@@ -22,7 +22,7 @@ describe "Using the Watcher API", :reset_redis => true do
describe
"GET"
do
describe
"GET"
do
it
"all watches should work"
do
it
"all watches should work"
do
get
'/w'
get
'/w
atches
'
last_response
.
should
be_ok
last_response
.
should
be_ok
response
=
last_response
.
should
return_json
response
=
last_response
.
should
return_json
response
.
is_a?
(
Array
).
should
==
true
response
.
is_a?
(
Array
).
should
==
true
...
@@ -30,8 +30,8 @@ describe "Using the Watcher API", :reset_redis => true do
...
@@ -30,8 +30,8 @@ describe "Using the Watcher API", :reset_redis => true do
end
end
it
"named watch should work"
do
it
"named watch should work"
do
w
=
Noah
::
Watcher
.
create
(
:pattern
=>
'//noah/application/myapp'
,
:endpoint
=>
'http://localhost/webhook'
)
w
=
Noah
::
Watcher
.
create
(
:pattern
=>
'//noah/application/myapp'
,
:endpoint
=>
'http://localhost/w
atchers
ebhook'
)
get
"/w/
#{
w
.
name
}
"
get
"/w
atches
/
#{
w
.
name
}
"
last_response
.
should
be_ok
last_response
.
should
be_ok
response
=
last_response
.
should
return_json
response
=
last_response
.
should
return_json
response
[
'pattern'
].
should
==
w
.
pattern
response
[
'pattern'
].
should
==
w
.
pattern
...
@@ -39,15 +39,15 @@ describe "Using the Watcher API", :reset_redis => true do
...
@@ -39,15 +39,15 @@ describe "Using the Watcher API", :reset_redis => true do
end
end
it
"invalid watch should not work"
do
it
"invalid watch should not work"
do
get
'/w/asdfasdfasdfasdfasdfsdf'
get
'/w
atches
/asdfasdfasdfasdfasdfsdf'
last_response
.
should
be_missing
last_response
.
should
be_missing
end
end
end
end
describe
"PUT"
do
describe
"PUT"
do
it
"new watch should work"
do
it
"new watch should work"
do
data
=
{
:pattern
=>
"//noah/application"
,
:endpoint
=>
"http://myendpoint/webhook"
}
data
=
{
:pattern
=>
"//noah/application"
,
:endpoint
=>
"http://myendpoint/w
atchers
ebhook"
}
put
'/w'
,
data
.
to_json
,
"CONTENT_TYPE"
=>
"application/json"
put
'/w
atches
'
,
data
.
to_json
,
"CONTENT_TYPE"
=>
"application/json"
last_response
.
should
be_ok
last_response
.
should
be_ok
response
=
last_response
.
should
return_json
response
=
last_response
.
should
return_json
response
[
'pattern'
].
should
==
data
[
:pattern
]
response
[
'pattern'
].
should
==
data
[
:pattern
]
...
@@ -58,30 +58,30 @@ describe "Using the Watcher API", :reset_redis => true do
...
@@ -58,30 +58,30 @@ describe "Using the Watcher API", :reset_redis => true do
end
end
it
"new watch without pattern should not work"
do
it
"new watch without pattern should not work"
do
data
=
{
:endpoint
=>
"http://myendpoint/webhook"
}
data
=
{
:endpoint
=>
"http://myendpoint/w
atchers
ebhook"
}
put
'/w'
,
data
.
to_json
,
"CONTENT_TYPE"
=>
"application/json"
put
'/w
atches
'
,
data
.
to_json
,
"CONTENT_TYPE"
=>
"application/json"
last_response
.
should
be_invalid
last_response
.
should
be_invalid
end
end
it
"new watch without endpoint should not work"
do
it
"new watch without endpoint should not work"
do
data
=
{
:pattern
=>
"//noah/application"
}
data
=
{
:pattern
=>
"//noah/application"
}
put
'/w'
,
data
.
to_json
,
"CONTENT_TYPE"
=>
"application/json"
put
'/w
atches
'
,
data
.
to_json
,
"CONTENT_TYPE"
=>
"application/json"
last_response
.
should
be_invalid
last_response
.
should
be_invalid
end
end
it
"new watch that supercedes existing should not work"
do
it
"new watch that supercedes existing should not work"
do
Noah
::
Watcher
.
create
(
:endpoint
=>
'http://myendpoint/webhook'
,
:pattern
=>
'//noah/application/foo'
)
Noah
::
Watcher
.
create
(
:endpoint
=>
'http://myendpoint/w
atchers
ebhook'
,
:pattern
=>
'//noah/application/foo'
)
data
=
{
:endpoint
=>
"http://myendpoint/webhook"
,
:pattern
=>
'//noah/application'
}
data
=
{
:endpoint
=>
"http://myendpoint/w
atchers
ebhook"
,
:pattern
=>
'//noah/application'
}
put
'/w'
,
data
.
to_json
,
"CONTENT_TYPE"
=>
"application/json"
put
'/w
atches
'
,
data
.
to_json
,
"CONTENT_TYPE"
=>
"application/json"
last_response
.
should_not
be_ok
last_response
.
should_not
be_ok
response
=
last_response
.
should
return_json
response
=
last_response
.
should
return_json
response
[
'error_message'
].
should
==
'Pattern would overwrite existing'
response
[
'error_message'
].
should
==
'Pattern would overwrite existing'
end
end
it
"new watch that subsets an existing should not work"
do
it
"new watch that subsets an existing should not work"
do
Noah
::
Watcher
.
create
(
:endpoint
=>
'http://myendpoint/webhook'
,
:pattern
=>
'//noah/application'
)
Noah
::
Watcher
.
create
(
:endpoint
=>
'http://myendpoint/w
atchers
ebhook'
,
:pattern
=>
'//noah/application'
)
data
=
{
:endpoint
=>
"http://myendpoint/webhook"
,
:pattern
=>
'//noah/application/foo'
}
data
=
{
:endpoint
=>
"http://myendpoint/w
atchers
ebhook"
,
:pattern
=>
'//noah/application/foo'
}
put
'/w'
,
data
.
to_json
,
"CONTENT_TYPE"
=>
"application/json"
put
'/w
atches
'
,
data
.
to_json
,
"CONTENT_TYPE"
=>
"application/json"
last_response
.
should_not
be_ok
last_response
.
should_not
be_ok
response
=
last_response
.
should
return_json
response
=
last_response
.
should
return_json
response
[
'error_message'
].
should
==
'Pattern is already provided'
response
[
'error_message'
].
should
==
'Pattern is already provided'
...
@@ -90,9 +90,9 @@ describe "Using the Watcher API", :reset_redis => true do
...
@@ -90,9 +90,9 @@ describe "Using the Watcher API", :reset_redis => true do
describe
"DELETE"
do
describe
"DELETE"
do
it
"delete an existing watch should work"
do
it
"delete an existing watch should work"
do
data
=
{
:endpoint
=>
"http://myendpoint/webhookd"
,
:pattern
=>
'//noah/application/d'
}
data
=
{
:endpoint
=>
"http://myendpoint/w
atchers
ebhookd"
,
:pattern
=>
'//noah/application/d'
}
w
=
Noah
::
Watcher
.
create
(
data
)
w
=
Noah
::
Watcher
.
create
(
data
)
delete
'/w'
,
data
.
to_json
,
"CONTENT_TYPE"
=>
"application/json"
delete
'/w
atches
'
,
data
.
to_json
,
"CONTENT_TYPE"
=>
"application/json"
last_response
.
should
be_ok
last_response
.
should
be_ok
response
=
last_response
.
should
return_json
response
=
last_response
.
should
return_json
response
[
'pattern'
].
should
==
data
[
:pattern
]
response
[
'pattern'
].
should
==
data
[
:pattern
]
...
@@ -103,19 +103,19 @@ describe "Using the Watcher API", :reset_redis => true do
...
@@ -103,19 +103,19 @@ describe "Using the Watcher API", :reset_redis => true do
it
"delete an invalid watch should not work"
do
it
"delete an invalid watch should not work"
do
data
=
{
:endpoint
=>
'missing'
,
:pattern
=>
'//noah/application/dag'
}
data
=
{
:endpoint
=>
'missing'
,
:pattern
=>
'//noah/application/dag'
}
delete
'/w'
,
data
.
to_json
,
"CONTENT_TYPE"
=>
"application/json"
delete
'/w
atches
'
,
data
.
to_json
,
"CONTENT_TYPE"
=>
"application/json"
last_response
.
should
be_missing
last_response
.
should
be_missing
end
end
it
"delete without pattern should not work"
do
it
"delete without pattern should not work"
do
data
=
{
:endpoint
=>
"invalid"
}
data
=
{
:endpoint
=>
"invalid"
}
delete
'/w'
,
data
.
to_json
,
"CONTENT_TYPE"
=>
"application/json"
delete
'/w
atches
'
,
data
.
to_json
,
"CONTENT_TYPE"
=>
"application/json"
last_response
.
should
be_invalid
last_response
.
should
be_invalid
end
end
it
"delete without endpoint should not work"
do
it
"delete without endpoint should not work"
do
data
=
{
:pattern
=>
"//noah/invalid"
}
data
=
{
:pattern
=>
"//noah/invalid"
}
delete
'/w'
,
data
.
to_json
,
"CONTENT_TYPE"
=>
"application/json"
delete
'/w
atches
'
,
data
.
to_json
,
"CONTENT_TYPE"
=>
"application/json"
last_response
.
should
be_invalid
last_response
.
should
be_invalid
end
end
end
end
...
...
views/index.haml
View file @
41913163
...
@@ -14,42 +14,42 @@
...
@@ -14,42 +14,42 @@
%h2
Hosts
%h2
Hosts
%ul
%ul
%li
%li
%a
{
:href
=>
"h/"
}
All registered Hosts
%a
{
:href
=>
"h
osts
/"
}
All registered Hosts
%li
%li
%a
{
:href
=>
"h/localhost"
}
localhost (this server)
%a
{
:href
=>
"h
osts
/localhost"
}
localhost (this server)
%li
%li
%a
{
:href
=>
"h/localhost/noah"
}
localhost noah service
%a
{
:href
=>
"h
osts
/localhost/noah"
}
localhost noah service
#header
#header
%h2
Services
%h2
Services
%ul
%ul
%li
%li
%a
{
:href
=>
"s/"
}
All registered Services
%a
{
:href
=>
"s
ervices
/"
}
All registered Services
%li
%li
%a
{
:href
=>
"s/http"
}
All hosts providing 'http'
%a
{
:href
=>
"s
ervices
/http"
}
All hosts providing 'http'
%li
%li
%a
{
:href
=>
"s/noah/localhost"
}
localhost noah service
%a
{
:href
=>
"s
ervices
/noah/localhost"
}
localhost noah service
#header
#header
%h2
Applications
%h2
Applications
%ul
%ul
%li
%li
%a
{
:href
=>
"a/"
}
All registered Applications
%a
{
:href
=>
"a
pplications
/"
}
All registered Applications
%li
%li
%a
{
:href
=>
"a/noah"
}
Noah Application entry
%a
{
:href
=>
"a
pplications
/noah"
}
Noah Application entry
%li
%li
%a
{
:href
=>
"a/noah/redis"
}
Noah Redis configuration entry
%a
{
:href
=>
"a
pplications
/noah/redis"
}
Noah Redis configuration entry
#header
#header
%h2
Configurations
%h2
Configurations
%ul
%ul
%li
%li
%a
{
:href
=>
"c/"
}
All registered Configurations
%a
{
:href
=>
"c
onfigurations
/"
}
All registered Configurations
%li
%li
%a
{
:href
=>
"c/noah"
}
Noah Configuration entry
%a
{
:href
=>
"c
onfigurations
/noah"
}
Noah Configuration entry
%li
%li
%a
{
:href
=>
"c/myrailsapp1"
}
myrailsapp1 Configuration entry
%a
{
:href
=>
"c
onfigurations
/myrailsapp1"
}
myrailsapp1 Configuration entry
%li
%li
%a
{
:href
=>
"c/myrestapp1"
}
myrestapp1 Configuration entry
%a
{
:href
=>
"c
onfigurations
/myrestapp1"
}
myrestapp1 Configuration entry
%li
%li
%a
{
:href
=>
"c/myrailsapp1/database.yml"
}
database.yml file for myrailsapp1 (should return the proper content-type)
%a
{
:href
=>
"c
onfigurations
/myrailsapp1/database.yml"
}
database.yml file for myrailsapp1 (should return the proper content-type)
%li
%li
%a
{
:href
=>
"c/myrestapp1/config.json"
}
config.json file for myrestapp1
%a
{
:href
=>
"c
onfigurations
/myrestapp1/config.json"
}
config.json file for myrestapp1
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment