nephos-server 0.6.8 → 0.6.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG +6 -0
- data/Rakefile +7 -4
- data/bin/nephos-server +2 -1
- data/lib/nephos-server/bin-helpers.rb +2 -1
- data/lib/nephos-server/controller.rb +4 -0
- data/lib/nephos-server/server/responder.rb +1 -1
- data/nephos-server.gemspec +1 -0
- data/test/functional/controller.rb +39 -0
- data/test/functional/global.rb +38 -0
- data/test/functional/server.rb +10 -0
- data/test/functional.rb +7 -2
- data/test/responder.rb +3 -3
- data/version +1 -1
- data.tar.gz.sig +0 -0
- metadata +3 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe9427a82fb27f38d05a61d389a4908310c1d943
|
4
|
+
data.tar.gz: 70968b136a8816c7b91fef7c4d5c8b3b4a3c8941
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0dc889edb2267acd90ca1606b9f999fe70aa7bab5baeec9fd87734d06a307bcd66a0609139695549bdb6189fd51ccab8920201cfe323d4a48dc9b51839c6d7a1
|
7
|
+
data.tar.gz: 130a86745ed28082f987b755f1a42ba96d03cdf05b00cb1dc1745ffd3608d7e06bf1bcd8a6d177beb1d477635029fc6e07c27f35a41232e1d8c194e5f6c08df0
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/CHANGELOG
CHANGED
data/Rakefile
CHANGED
@@ -12,15 +12,18 @@ namespace :test do
|
|
12
12
|
|
13
13
|
desc "Unitary tests. Fasts and on the sources."
|
14
14
|
task :test do
|
15
|
-
puts
|
16
15
|
ruby "test/test.rb"
|
17
16
|
end
|
18
17
|
|
19
18
|
desc "Functional tests. Slow, test real the features under real conditions of usage."
|
20
19
|
task :functional do
|
21
|
-
puts "!!! Important !!!".yellow
|
22
|
-
puts "You have to access to internet to test the generator.".yellow
|
23
|
-
puts
|
24
20
|
ruby "test/functional.rb"
|
25
21
|
end
|
22
|
+
|
23
|
+
namespace :functional do
|
24
|
+
task :internet do
|
25
|
+
ruby "test/functional.rb internet"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
26
29
|
end
|
data/bin/nephos-server
CHANGED
@@ -51,8 +51,9 @@ begin
|
|
51
51
|
|
52
52
|
if $kill_daemon
|
53
53
|
raise "No Daemon started" if not Nephos::Bin::Daemon.started?
|
54
|
-
|
54
|
+
pid = Nephos::Bin::Daemon.get_pid
|
55
55
|
Nephos::Bin::Daemon.kill!
|
56
|
+
puts "Daemon #{pid} stopped"
|
56
57
|
exit 0
|
57
58
|
end
|
58
59
|
if $daemon and Nephos::Bin::Daemon.started?
|
data/nephos-server.gemspec
CHANGED
@@ -0,0 +1,39 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
class FakeController1241525 < Nephos::Controller
|
4
|
+
DATA = %w(hello wôrld)
|
5
|
+
def log_test
|
6
|
+
Nephos::Logger.fd = File.open '/tmp/nephos_ftest.log', 'w'
|
7
|
+
log DATA
|
8
|
+
return {json: DATA}
|
9
|
+
end
|
10
|
+
|
11
|
+
def set_cookie
|
12
|
+
cookies["name"] = "value"
|
13
|
+
return {code: 200}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class TestController < Test::Unit::TestCase
|
18
|
+
|
19
|
+
FILE = "/tmp/nephos_ftest.log"
|
20
|
+
|
21
|
+
def test_log_with_one_controller
|
22
|
+
# fd = File.open(FILE, "w")
|
23
|
+
# Nephos::Logger.fd = fd
|
24
|
+
# Nephos.log %w(hello wôrld)
|
25
|
+
r = Rack::Request.new({})
|
26
|
+
c = FakeController1241525.new(r, {params: []})
|
27
|
+
c.log_test
|
28
|
+
assert_equal("hello\nwôrld\n", File.read(FILE))
|
29
|
+
File.delete FILE
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_set_cookies
|
33
|
+
router = Nephos::Router.new(silent: true)
|
34
|
+
r = Rack::Request.new({"REQUEST_METHOD"=>"GET", "PATH_INFO"=>"/add_cookie"})
|
35
|
+
out = router.execute(r)
|
36
|
+
assert_equal "UN_COOKIE_VAUT%3A=UN+BON+MOMENT+%21", out.header["Set-Cookie"]
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
data/test/functional/global.rb
CHANGED
@@ -1,6 +1,44 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
|
1
3
|
class TestGlobal < Test::Unit::TestCase
|
2
4
|
|
5
|
+
def start_server
|
6
|
+
stop_server
|
7
|
+
s = `./bin/nephos-server --test -d`
|
8
|
+
sleep 1
|
9
|
+
s
|
10
|
+
end
|
11
|
+
|
12
|
+
def stop_server
|
13
|
+
`./bin/nephos-server --test -k`
|
14
|
+
end
|
15
|
+
|
3
16
|
def test_simpe_requests_on_app
|
17
|
+
start_server
|
18
|
+
r = open("http://127.0.0.1:8080/")
|
19
|
+
assert_equal "{\"list\":[],\"add\":\"/add\",\"rm\":\"/rm\"}\n", r.read
|
20
|
+
assert_equal "application/json; charset=UTF-8", r.meta["content-type"]
|
21
|
+
assert_equal "a=b", r.meta["set-cookie"]
|
22
|
+
assert_equal ["200", "OK"], r.status
|
23
|
+
|
24
|
+
r = open("http://127.0.0.1:8080/home")
|
25
|
+
assert_equal "{\"list\":[],\"add\":\"/add\",\"rm\":\"/rm\"}\n", r.read
|
26
|
+
assert_equal "application/json; charset=UTF-8", r.meta["content-type"]
|
27
|
+
assert_equal "a=b", r.meta["set-cookie"]
|
28
|
+
assert_equal ["200", "OK"], r.status
|
29
|
+
|
30
|
+
r = open("http://127.0.0.1:8080/home/")
|
31
|
+
assert_equal "{\"list\":[],\"add\":\"/add\",\"rm\":\"/rm\"}\n", r.read
|
32
|
+
assert_equal "application/json; charset=UTF-8", r.meta["content-type"]
|
33
|
+
assert_equal ["200", "OK"], r.status
|
34
|
+
|
35
|
+
r = open("http://127.0.0.1:8080/hello")
|
36
|
+
assert_equal "<html><body><h1>hello world</h1><p>lol</p></body></html>\n", r.read
|
37
|
+
assert_equal ["200", "OK"], r.status
|
38
|
+
|
39
|
+
assert_raise do open("http://127.0.0.1:8080/err500") end
|
40
|
+
|
41
|
+
stop_server
|
4
42
|
end
|
5
43
|
|
6
44
|
end
|
data/test/functional/server.rb
CHANGED
@@ -2,35 +2,45 @@ class TestNephosServerBinServer < Test::Unit::TestCase
|
|
2
2
|
|
3
3
|
def test_daemon
|
4
4
|
# WARNING: be sure there is no instance before running theses tests
|
5
|
+
`./bin/nephos-server --test -k`
|
5
6
|
|
6
7
|
# test start and kill
|
7
8
|
`./bin/nephos-server --test -d`
|
9
|
+
sleep 2
|
8
10
|
assert_equal 0, $?.exitstatus
|
9
11
|
`./bin/nephos-server --test -k`
|
12
|
+
sleep 0.5
|
10
13
|
assert_equal 0, $?.exitstatus
|
11
14
|
|
12
15
|
# test kill after killed
|
13
16
|
`./bin/nephos-server --test -k`
|
17
|
+
sleep 0.5
|
14
18
|
assert_equal 1, $?.exitstatus
|
15
19
|
`./bin/nephos-server --test -k`
|
20
|
+
sleep 0.5
|
16
21
|
assert_equal 1, $?.exitstatus
|
17
22
|
|
18
23
|
# test start after killed
|
19
24
|
`./bin/nephos-server --test -d`
|
25
|
+
sleep 2
|
20
26
|
assert_equal 0, $?.exitstatus
|
21
27
|
|
22
28
|
# test start after started
|
23
29
|
`./bin/nephos-server --test -d`
|
30
|
+
sleep 0.5
|
24
31
|
assert_equal 1, $?.exitstatus
|
25
32
|
`./bin/nephos-server --test -d`
|
33
|
+
sleep 0.5
|
26
34
|
assert_equal 1, $?.exitstatus
|
27
35
|
|
28
36
|
# test kill after started N times
|
29
37
|
`./bin/nephos-server --test -k`
|
38
|
+
sleep 0.5
|
30
39
|
assert_equal 0, $?.exitstatus
|
31
40
|
|
32
41
|
# test kill after started N times and then killed
|
33
42
|
`./bin/nephos-server --test -k`
|
43
|
+
sleep 0.5
|
34
44
|
assert_equal 1, $?.exitstatus
|
35
45
|
end
|
36
46
|
|
data/test/functional.rb
CHANGED
@@ -2,8 +2,13 @@ require "test/unit"
|
|
2
2
|
|
3
3
|
require_relative "../lib/nephos-server"
|
4
4
|
|
5
|
-
|
6
|
-
require_relative 'functional/server'
|
5
|
+
# tests global
|
7
6
|
require_relative 'functional/global'
|
7
|
+
require_relative 'functional/server'
|
8
8
|
|
9
|
+
# tests on master classes
|
10
|
+
require_relative 'functional/controller'
|
9
11
|
require_relative 'functional/router'
|
12
|
+
|
13
|
+
# test global with internet required
|
14
|
+
require_relative 'functional/generator' if ARGV[0] == "internet"
|
data/test/responder.rb
CHANGED
@@ -111,13 +111,13 @@ class TestNephosServerResponder < Test::Unit::TestCase
|
|
111
111
|
r3 = Nephos::Responder.new.render(status: 201, html: "<p>p</p>")
|
112
112
|
assert_equal(201, r1.status)
|
113
113
|
assert_equal("text/plain; charset=UTF-8", r1["Content-type"])
|
114
|
-
assert_equal(["plaaaain"], r1.body)
|
114
|
+
assert_equal(["plaaaain\n"], r1.body)
|
115
115
|
assert_equal(201, r2.status)
|
116
116
|
assert_equal("application/json; charset=UTF-8", r2["Content-type"])
|
117
|
-
assert_equal(["{\"data\":[1,2]}"], r2.body)
|
117
|
+
assert_equal(["{\"data\":[1,2]}\n"], r2.body)
|
118
118
|
assert_equal(201, r3.status)
|
119
119
|
assert_equal("text/html; charset=UTF-8", r3["Content-type"])
|
120
|
-
assert_equal(["<p>p</p
|
120
|
+
assert_equal(["<p>p</p>\n"], r3.body)
|
121
121
|
end
|
122
122
|
|
123
123
|
end
|
data/version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.9
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nephos-server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- poulet_a
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
tcYkgfqUJPitIJx1RvWZpIyH5uJhRUYK3+vU9nMOxez5WbIlC1TtpByKAPMX+sht
|
32
32
|
gib3AoIT8jh/2w==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2015-11-
|
34
|
+
date: 2015-11-06 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: nomorebeer
|
@@ -134,6 +134,7 @@ files:
|
|
134
134
|
- routes.rb
|
135
135
|
- test/controller.rb
|
136
136
|
- test/functional.rb
|
137
|
+
- test/functional/controller.rb
|
137
138
|
- test/functional/generator.rb
|
138
139
|
- test/functional/global.rb
|
139
140
|
- test/functional/router.rb
|
metadata.gz.sig
CHANGED
Binary file
|