hyperion-postgres 0.0.1.alpha5 → 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/lib/hyperion/postgres.rb +1 -1
- data/spec/hyperion/postgres_spec.rb +38 -35
- metadata +8 -9
data/lib/hyperion/postgres.rb
CHANGED
@@ -8,7 +8,7 @@ module Hyperion
|
|
8
8
|
module Postgres
|
9
9
|
|
10
10
|
def self.new(opts={})
|
11
|
-
Sql::Datastore.new(DbStrategy.new, QueryExecutorStrategy.new, QueryBuilderStrategy.new)
|
11
|
+
Sql::Datastore.new(opts[:connection_url], DbStrategy.new, QueryExecutorStrategy.new, QueryBuilderStrategy.new)
|
12
12
|
end
|
13
13
|
|
14
14
|
end
|
@@ -5,6 +5,8 @@ require 'hyperion/postgres'
|
|
5
5
|
|
6
6
|
describe Hyperion::Postgres do
|
7
7
|
|
8
|
+
CONNECTION_URL = 'postgres://localhost/hyperion_ruby'
|
9
|
+
|
8
10
|
def execute(query)
|
9
11
|
Hyperion::Sql.connection.create_command(query).execute_non_query
|
10
12
|
end
|
@@ -24,54 +26,55 @@ describe Hyperion::Postgres do
|
|
24
26
|
execute "DROP TABLE IF EXISTS #{table_name};"
|
25
27
|
end
|
26
28
|
|
29
|
+
TABLES = ['testing', 'other_testing']
|
30
|
+
|
27
31
|
around :each do |example|
|
28
|
-
Hyperion
|
32
|
+
Hyperion.with_datastore(:postgres, :connection_url => CONNECTION_URL) do
|
29
33
|
example.run
|
30
34
|
end
|
31
35
|
end
|
32
36
|
|
33
|
-
|
37
|
+
before :each do |example|
|
38
|
+
Hyperion::Sql.with_connection(CONNECTION_URL) do
|
39
|
+
TABLES.each { |table| create_table(table) }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
after :each do |example|
|
44
|
+
Hyperion::Sql.with_connection(CONNECTION_URL) do
|
45
|
+
TABLES.each { |table| drop_table(table) }
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
include_examples 'Datastore'
|
50
|
+
|
51
|
+
context 'Transactions' do
|
34
52
|
around :each do |example|
|
35
|
-
Hyperion::Sql.
|
36
|
-
tables = ['testing', 'other_testing']
|
37
|
-
tables.each { |table| create_table(table) }
|
53
|
+
Hyperion::Sql.with_connection(CONNECTION_URL) do
|
38
54
|
example.run
|
39
55
|
end
|
40
56
|
end
|
41
57
|
|
42
|
-
include_examples '
|
43
|
-
|
44
|
-
context 'Sql Injection' do
|
45
|
-
it 'escapes strings to be inserted' do
|
46
|
-
evil_name = "my evil name' --"
|
47
|
-
record = Hyperion::API.save(:kind => 'testing', :name => evil_name)
|
48
|
-
found_record = Hyperion::API.find_by_key(record[:key])
|
49
|
-
found_record[:name].should == evil_name
|
50
|
-
end
|
58
|
+
include_examples 'Sql Transactions'
|
59
|
+
end
|
51
60
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
end
|
60
|
-
error_message.should include('relation "my_evil_name"___" does not exist')
|
61
|
-
end
|
61
|
+
context 'Sql Injection' do
|
62
|
+
it 'escapes strings to be inserted' do
|
63
|
+
evil_name = "my evil name' --"
|
64
|
+
record = Hyperion.save(:kind => 'testing', :name => evil_name)
|
65
|
+
found_record = Hyperion.find_by_key(record[:key])
|
66
|
+
found_record[:name].should == evil_name
|
67
|
+
end
|
62
68
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
end
|
71
|
-
error_message.should include('column "my_evil_name"___" of relation "testing" does not exist')
|
69
|
+
it 'escapes table names' do
|
70
|
+
evil_name = 'my evil name" --'
|
71
|
+
error_message = ""
|
72
|
+
begin
|
73
|
+
Hyperion.save(:kind => 'my evil name" --', :name => evil_name)
|
74
|
+
rescue Exception => e
|
75
|
+
error_message = e.message
|
72
76
|
end
|
77
|
+
error_message.should include('relation "my_evil_name"___" does not exist')
|
73
78
|
end
|
74
79
|
end
|
75
|
-
|
76
|
-
it_behaves_like 'Sql Transactions'
|
77
80
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hyperion-postgres
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
|
-
-
|
8
|
+
- Myles Megyesi
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-10-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
requirements:
|
35
35
|
- - '='
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: 0.
|
37
|
+
version: 0.1.0
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - '='
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 0.
|
45
|
+
version: 0.1.0
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: do_postgres
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -62,7 +62,6 @@ dependencies:
|
|
62
62
|
description: Postgres Datastore for Hyperion
|
63
63
|
email:
|
64
64
|
- myles@8thlight.com
|
65
|
-
- skim@8thlight.com
|
66
65
|
executables: []
|
67
66
|
extensions: []
|
68
67
|
extra_rdoc_files: []
|
@@ -88,9 +87,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
88
87
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
88
|
none: false
|
90
89
|
requirements:
|
91
|
-
- - ! '
|
90
|
+
- - ! '>='
|
92
91
|
- !ruby/object:Gem::Version
|
93
|
-
version:
|
92
|
+
version: '0'
|
94
93
|
requirements: []
|
95
94
|
rubyforge_project:
|
96
95
|
rubygems_version: 1.8.24
|