deployment_test 0.0.1
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/CHANGELOG.rdoc +8 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +39 -0
- data/MIT-LICENSE +20 -0
- data/Manifest +11 -0
- data/README +3 -0
- data/Rakefile +25 -0
- data/deployment_test.gemspec +32 -0
- data/lib/deployment_test/postgres.rb +43 -0
- data/lib/deployment_test/version.rb +9 -0
- data/lib/deployment_test.rb +1 -0
- data/spec/deployment_test/postgres_spec.rb +56 -0
- metadata +78 -0
data/CHANGELOG.rdoc
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
allison (2.0.3)
|
5
|
+
diff-lcs (1.1.3)
|
6
|
+
echoe (4.6.3)
|
7
|
+
allison (>= 2.0.3)
|
8
|
+
gemcutter (>= 0.7.0)
|
9
|
+
rake (>= 0.9.2)
|
10
|
+
rdoc (>= 3.6.1)
|
11
|
+
rubyforge (>= 2.0.4)
|
12
|
+
gemcutter (0.7.1)
|
13
|
+
json (1.6.3)
|
14
|
+
json_pure (1.6.3)
|
15
|
+
pg (0.12.0)
|
16
|
+
rake-compiler (~> 0.7)
|
17
|
+
rake (0.9.2.2)
|
18
|
+
rake-compiler (0.7.9)
|
19
|
+
rake
|
20
|
+
rdoc (3.11)
|
21
|
+
json (~> 1.4)
|
22
|
+
rspec (2.7.0)
|
23
|
+
rspec-core (~> 2.7.0)
|
24
|
+
rspec-expectations (~> 2.7.0)
|
25
|
+
rspec-mocks (~> 2.7.0)
|
26
|
+
rspec-core (2.7.1)
|
27
|
+
rspec-expectations (2.7.0)
|
28
|
+
diff-lcs (~> 1.1.2)
|
29
|
+
rspec-mocks (2.7.0)
|
30
|
+
rubyforge (2.0.4)
|
31
|
+
json_pure (>= 1.1.7)
|
32
|
+
|
33
|
+
PLATFORMS
|
34
|
+
ruby
|
35
|
+
|
36
|
+
DEPENDENCIES
|
37
|
+
echoe
|
38
|
+
pg
|
39
|
+
rspec
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 DoubleDrones
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Manifest
ADDED
data/README
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
begin
|
2
|
+
require 'echoe'
|
3
|
+
rescue LoadError
|
4
|
+
abort "You'll need to have `echoe' installed to use deployment_test's Rakefile"
|
5
|
+
end
|
6
|
+
|
7
|
+
require "./lib/deployment_test/version"
|
8
|
+
|
9
|
+
version = DeploymentTest::Version::STRING.dup
|
10
|
+
if ENV['SNAPSHOT'].to_i == 1
|
11
|
+
version << "." << Time.now.utc.strftime("%Y%m%d%H%M%S")
|
12
|
+
end
|
13
|
+
|
14
|
+
Echoe.new('deployment_test', version) do |p|
|
15
|
+
p.changelog = "CHANGELOG.rdoc"
|
16
|
+
|
17
|
+
p.author = "Marcin Nowicki"
|
18
|
+
p.email = "pr0d1r2@gmail.com"
|
19
|
+
p.summary = "Gem to perform common deployment testing"
|
20
|
+
p.url = "https://github.com/doubledrones/deployment_test"
|
21
|
+
|
22
|
+
p.need_zip = true
|
23
|
+
|
24
|
+
p.dependencies = ["pg >=0.11.0"]
|
25
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{deployment_test}
|
5
|
+
s.version = "0.0.1"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = [%q{Marcin Nowicki}]
|
9
|
+
s.date = %q{2011-12-12}
|
10
|
+
s.description = %q{Gem to perform common deployment testing}
|
11
|
+
s.email = %q{pr0d1r2@gmail.com}
|
12
|
+
s.extra_rdoc_files = [%q{CHANGELOG.rdoc}, %q{README}, %q{lib/deployment_test.rb}, %q{lib/deployment_test/postgres.rb}, %q{lib/deployment_test/version.rb}]
|
13
|
+
s.files = [%q{CHANGELOG.rdoc}, %q{Gemfile}, %q{Gemfile.lock}, %q{MIT-LICENSE}, %q{Manifest}, %q{README}, %q{Rakefile}, %q{lib/deployment_test.rb}, %q{lib/deployment_test/postgres.rb}, %q{lib/deployment_test/version.rb}, %q{spec/deployment_test/postgres_spec.rb}, %q{deployment_test.gemspec}]
|
14
|
+
s.homepage = %q{https://github.com/doubledrones/deployment_test}
|
15
|
+
s.rdoc_options = [%q{--line-numbers}, %q{--inline-source}, %q{--title}, %q{Deployment_test}, %q{--main}, %q{README}]
|
16
|
+
s.require_paths = [%q{lib}]
|
17
|
+
s.rubyforge_project = %q{deployment_test}
|
18
|
+
s.rubygems_version = %q{1.8.6}
|
19
|
+
s.summary = %q{Gem to perform common deployment testing}
|
20
|
+
|
21
|
+
if s.respond_to? :specification_version then
|
22
|
+
s.specification_version = 3
|
23
|
+
|
24
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
25
|
+
s.add_runtime_dependency(%q<pg>, [">= 0.11.0"])
|
26
|
+
else
|
27
|
+
s.add_dependency(%q<pg>, [">= 0.11.0"])
|
28
|
+
end
|
29
|
+
else
|
30
|
+
s.add_dependency(%q<pg>, [">= 0.11.0"])
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'pg'
|
2
|
+
|
3
|
+
module DeploymentTest
|
4
|
+
class Postgres
|
5
|
+
|
6
|
+
def initialize(options = {})
|
7
|
+
@options = {
|
8
|
+
:host => "127.0.0.1",
|
9
|
+
:dbname => 'postgres',
|
10
|
+
:user => 'postgres',
|
11
|
+
:password => 'postgres'
|
12
|
+
}.merge(options)
|
13
|
+
end
|
14
|
+
|
15
|
+
def user_exist?(name)
|
16
|
+
user_count(name).entries[0]['count'] != '0'
|
17
|
+
end
|
18
|
+
|
19
|
+
def user_can_login?(name, password)
|
20
|
+
begin
|
21
|
+
PGconn.connect(@options.merge(:user=>name, :password => password))
|
22
|
+
true
|
23
|
+
rescue PGError
|
24
|
+
false
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def postgres_connection
|
31
|
+
@postgres_connection ||= PGconn.connect(@options)
|
32
|
+
end
|
33
|
+
|
34
|
+
def postgres_exec(query)
|
35
|
+
postgres_connection.exec(query)
|
36
|
+
end
|
37
|
+
|
38
|
+
def user_count(name)
|
39
|
+
postgres_exec("SELECT COUNT(*) FROM pg_user WHERE usename='#{name}'")
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require_relative 'deployment_test/postgres'
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'deployment_test'
|
2
|
+
|
3
|
+
describe DeploymentTest::Postgres do
|
4
|
+
|
5
|
+
let(:the_class) { DeploymentTest::Postgres }
|
6
|
+
let(:the_object) do
|
7
|
+
# you need local admin user for testing
|
8
|
+
the_class.new(:user => 'deployment_test', :password =>'deployment_test')
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#user_exist?" do
|
12
|
+
subject { the_object.user_exist?(user_name) }
|
13
|
+
|
14
|
+
context "when user exist" do
|
15
|
+
let(:user_name) { "postgres" }
|
16
|
+
|
17
|
+
it { should be_true }
|
18
|
+
end
|
19
|
+
|
20
|
+
context "when user not exist" do
|
21
|
+
let(:user_name) { "example_not_existing_user" }
|
22
|
+
|
23
|
+
it { should be_false }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#user_can_login?" do
|
28
|
+
subject { the_object.user_can_login?(user_name, user_password) }
|
29
|
+
|
30
|
+
let(:existing_user_name) do
|
31
|
+
begin
|
32
|
+
the_object.send(:postgres_exec, "CREATE ROLE deployment_test_example;")
|
33
|
+
rescue PGError
|
34
|
+
end
|
35
|
+
"deployment_test_example"
|
36
|
+
end
|
37
|
+
|
38
|
+
context "when user exist with password" do
|
39
|
+
let(:user_name) { existing_user_name }
|
40
|
+
let(:user_password) do
|
41
|
+
the_object.send(:postgres_exec, "ALTER ROLE #{existing_user_name} ENCRYPTED PASSWORD 'xxx';")
|
42
|
+
'xxx'
|
43
|
+
end
|
44
|
+
|
45
|
+
it { should be_true }
|
46
|
+
end
|
47
|
+
|
48
|
+
context "then user not exist" do
|
49
|
+
let(:user_name) { "deployment_test_not_existing" }
|
50
|
+
let(:user_password) { "deployment_test_example_password" }
|
51
|
+
|
52
|
+
it { should be_false }
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
metadata
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: deployment_test
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Marcin Nowicki
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-12-12 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: pg
|
16
|
+
requirement: &70340366915380 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.11.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70340366915380
|
25
|
+
description: Gem to perform common deployment testing
|
26
|
+
email: pr0d1r2@gmail.com
|
27
|
+
executables: []
|
28
|
+
extensions: []
|
29
|
+
extra_rdoc_files:
|
30
|
+
- CHANGELOG.rdoc
|
31
|
+
- README
|
32
|
+
- lib/deployment_test.rb
|
33
|
+
- lib/deployment_test/postgres.rb
|
34
|
+
- lib/deployment_test/version.rb
|
35
|
+
files:
|
36
|
+
- CHANGELOG.rdoc
|
37
|
+
- Gemfile
|
38
|
+
- Gemfile.lock
|
39
|
+
- MIT-LICENSE
|
40
|
+
- Manifest
|
41
|
+
- README
|
42
|
+
- Rakefile
|
43
|
+
- lib/deployment_test.rb
|
44
|
+
- lib/deployment_test/postgres.rb
|
45
|
+
- lib/deployment_test/version.rb
|
46
|
+
- spec/deployment_test/postgres_spec.rb
|
47
|
+
- deployment_test.gemspec
|
48
|
+
homepage: https://github.com/doubledrones/deployment_test
|
49
|
+
licenses: []
|
50
|
+
post_install_message:
|
51
|
+
rdoc_options:
|
52
|
+
- --line-numbers
|
53
|
+
- --inline-source
|
54
|
+
- --title
|
55
|
+
- Deployment_test
|
56
|
+
- --main
|
57
|
+
- README
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ! '>='
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '1.2'
|
72
|
+
requirements: []
|
73
|
+
rubyforge_project: deployment_test
|
74
|
+
rubygems_version: 1.8.6
|
75
|
+
signing_key:
|
76
|
+
specification_version: 3
|
77
|
+
summary: Gem to perform common deployment testing
|
78
|
+
test_files: []
|