ugv 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ OTk0OGVhMThmNjEzZTk4NzlmZmU1YjI3MmZlMGY3MDlmZjU0YmRiMw==
5
+ data.tar.gz: !binary |-
6
+ NjE1YTQ2ZjE1MzBlMmFlODYyMzQ3ZjljZDA5MDg0ZWE2ZWY3MzM5OQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ MTY2YTQ5MTJlNTM2MDlkYTVjOTBlZmQzYjEwMjljZDdmNGM1NTVkOWE2NTUz
10
+ ZGQ1ZGY2MDlmNmRlYTU5MjVhYzg0NmE1MTgzNGIwNzVhZjI4ZTg3Mjk5ZTZj
11
+ OThhNjlhMGY5Y2FjNTdkMzljZjZiMDkyMGRlN2ZiMmQ2MDg4OGQ=
12
+ data.tar.gz: !binary |-
13
+ OTQ5MTNmODhlY2NiMzZjMDg1ZTg4Y2IyZDllYmI5YzRkOTcwNzFjZTlhNTZm
14
+ MDIzMGM5YTUzMGFlZDRjZDNiNjQ5M2ZkMmM3OTZmN2Y3Mzc4YWUxNWIxYWVk
15
+ ZGNiOTJlOGFlYzVjM2YyYzI5YmQ0YzdjZWE3ODIwMTg5YzBlZDk=
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .idea/**
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
4
+ </project>
5
+
data/.idea/misc.xml ADDED
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectRootManager" version="2" project-jdk-name="RVM: ruby-1.9.3-p448" project-jdk-type="RUBY_SDK" />
4
+ </project>
5
+
data/.idea/modules.xml ADDED
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/ug-validation.iml" filepath="$PROJECT_DIR$/.idea/ug-validation.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
9
+
@@ -0,0 +1,5 @@
1
+ <component name="DependencyValidationManager">
2
+ <state>
3
+ <option name="SKIP_IMPORT_STATEMENTS" value="false" />
4
+ </state>
5
+ </component>
@@ -0,0 +1,26 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="RUBY_MODULE" version="4">
3
+ <component name="FacetManager">
4
+ <facet type="gem" name="Gem">
5
+ <configuration>
6
+ <option name="GEM_APP_ROOT_PATH" value="$MODULE_DIR$" />
7
+ <option name="GEM_APP_TEST_PATH" value="" />
8
+ <option name="GEM_APP_LIB_PATH" value="$MODULE_DIR$/lib" />
9
+ </configuration>
10
+ </facet>
11
+ </component>
12
+ <component name="NewModuleRootManager">
13
+ <content url="file://$MODULE_DIR$" />
14
+ <orderEntry type="inheritedJdk" />
15
+ <orderEntry type="sourceFolder" forTests="false" />
16
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v1.3.5, RVM: ruby-1.9.3-p448) [gem]" level="application" />
17
+ <orderEntry type="library" scope="PROVIDED" name="gli (v2.8.1, RVM: ruby-1.9.3-p448) [gem]" level="application" />
18
+ <orderEntry type="library" scope="PROVIDED" name="json (v1.8.0, RVM: ruby-1.9.3-p448) [gem]" level="application" />
19
+ <orderEntry type="library" scope="PROVIDED" name="mime-types (v1.25, RVM: ruby-1.9.3-p448) [gem]" level="application" />
20
+ <orderEntry type="library" scope="PROVIDED" name="multi_json (v1.8.1, RVM: ruby-1.9.3-p448) [gem]" level="application" />
21
+ <orderEntry type="library" scope="PROVIDED" name="rake (v10.1.0, RVM: ruby-1.9.3-p448) [gem]" level="application" />
22
+ <orderEntry type="library" scope="PROVIDED" name="rest-client (v1.6.7, RVM: ruby-1.9.3-p448) [gem]" level="application" />
23
+ <orderEntry type="library" scope="PROVIDED" name="usergrid_iron (v0.9.2, RVM: ruby-1.9.3-p448) [gem]" level="application" />
24
+ </component>
25
+ </module>
26
+
data/.idea/vcs.xml ADDED
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+ </component>
6
+ </project>
7
+
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ugv-validation.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Todd Nine
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Ug::Validation
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'ug-validation'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install ug-validation
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/ugv ADDED
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'gli'
4
+ require 'usergrid_iron'
5
+ #require 'ugv'
6
+ include GLI::App
7
+
8
+ program_desc 'Usergrid Validation Tools'
9
+ version Ugv::VERSION
10
+
11
+ desc 'verbose'
12
+ switch [:v,:verbose], negatable: false
13
+
14
+ desc 'management'
15
+ switch [:m,:management], negatable: false
16
+
17
+ desc 'show curl equivalent (does not execute)'
18
+ switch [:c,:curl], negatable: false
19
+
20
+ desc 'draw table border'
21
+ default_value true
22
+ switch [:border]
23
+
24
+ desc 'settings directory'
25
+ arg_name 'settings directory'
26
+ default_value File.join(ENV['HOME'], '.ugc')
27
+ flag [:s,:settings]
28
+
29
+ # load helpers && commands
30
+ commands_from '../lib/ugv/commands'
31
+
32
+ pre do |global_options,command,options,args|
33
+ if global_options[:verbose]
34
+ RestClient.log=Logger.new(STDOUT)
35
+ else
36
+ Usergrid::LOG.level = Logger::WARN
37
+ end
38
+ end
39
+
40
+ post do |global_options,command,options,args|
41
+ # post-run logic here
42
+ end
43
+
44
+ on_error do |e|
45
+ # return false to skip default error handling
46
+ if e.is_a? RestClient::Exception
47
+ begin
48
+ puts "#{e.http_code} error: #{e.response.data['error_description']}"
49
+ if e.http_code == 401 and not $settings.logged_in?
50
+ puts "(Hint: You may need to log in.)"
51
+ end
52
+ rescue MultiJson::DecodeError
53
+ puts e.response
54
+ end
55
+ false
56
+ else
57
+ true
58
+ end
59
+ end
60
+
61
+ exit run(ARGV)
data/lib/ugv/client.rb ADDED
@@ -0,0 +1,127 @@
1
+ require 'usergrid_iron'
2
+ require 'json'
3
+
4
+ module Ugv
5
+ class Client
6
+
7
+ FIRST_ENTITY = {:index => 1, :name => 'test1'}
8
+ SECOND_ENTITY = {:index => 2, :name => 'test2'}
9
+ EMPTY = {}
10
+
11
+
12
+ def initialize(api, adminUser, adminPassword, orgName, appName)
13
+ @api = api
14
+ @adminUser = adminUser
15
+ @adminPassword = adminPassword
16
+ @orgName = orgName
17
+ @appName = appName
18
+
19
+ end
20
+
21
+ def validate
22
+ return !@api.nil? && !@adminUser.nil? && !@adminPassword.nil? && !@orgName.nil? && !@appName.nil?
23
+ end
24
+
25
+
26
+ ###
27
+ # Login and /or create the org admin and app
28
+ ##
29
+ def setup
30
+
31
+ puts "Attempting to log in with username #{@adminUser} and password #{@adminPassword}"
32
+
33
+ @management = Usergrid::Management.new @api
34
+
35
+
36
+ @management.login @adminUser, @adminPassword
37
+
38
+ response = JSON.parse(@management[:users][@adminUser][:orgs].get)
39
+
40
+ puts "Response is #{response}"
41
+
42
+ #No org, create it
43
+ if response.nil? || response["data"][@orgName].nil?
44
+ puts "No organization #{@orgName} found. Creating it"
45
+ @management[:users][@adminUser][:orgs].post({:organization => @orgName})
46
+ end
47
+
48
+ #Now check to see if the app exists
49
+
50
+ response = JSON.parse(@management[:orgs][@orgName][:applications].get)
51
+
52
+ #puts "Found organization #{organization}"
53
+
54
+ #We have to account for the orgname/appname format
55
+ if response.nil? || response["data"]["#{@orgName}/#{@appName}"].nil?
56
+ puts "No application #{@appName} found. Creating it"
57
+ @management[:orgs][@orgName][:applications].post({:name => @appName})
58
+ end
59
+
60
+ @application = @management.application @orgName, @appName
61
+
62
+ end
63
+
64
+
65
+ def create
66
+
67
+ puts "Writing entity #{FIRST_ENTITY[:name]}"
68
+
69
+ @application[:tests][FIRST_ENTITY[:name]].put FIRST_ENTITY
70
+
71
+ puts "Writing entity #{SECOND_ENTITY[:name]}"
72
+
73
+ @application[:tests][SECOND_ENTITY[:name]].put SECOND_ENTITY
74
+
75
+ puts "Creating a connection from #{FIRST_ENTITY[:name]} to #{SECOND_ENTITY[:name]}"
76
+
77
+ @application[:tests][FIRST_ENTITY[:name]][:connection][:tests][SECOND_ENTITY[:name]].post EMPTY
78
+
79
+ end
80
+
81
+
82
+ def verify
83
+
84
+
85
+ puts "Verifying entity #{FIRST_ENTITY[:name]}"
86
+
87
+
88
+ entity = @application[:tests][FIRST_ENTITY[:name]].get.entity
89
+
90
+ raise "Entity #{FIRST_ENTITY[:name]} not found" if entity.nil?
91
+
92
+ raise "Entity index mismatch. Expected #{FIRST_ENTITY[:index]} but was #{entity['index']}" unless FIRST_ENTITY[:index] == entity['index']
93
+
94
+ raise "Entity name mismatch. Expected #{FIRST_ENTITY[:name]} but was #{entity['name']}" unless FIRST_ENTITY[:name] == entity['name']
95
+
96
+
97
+
98
+ puts "Verifying entity #{SECOND_ENTITY[:name]}"
99
+
100
+ entity = @application[:tests][SECOND_ENTITY[:name]].get.entity
101
+
102
+ raise "Entity #{SECOND_ENTITY[:name]} not found" if entity.nil?
103
+
104
+ raise "Entity index mismatch. Expected #{SECOND_ENTITY[:index]} but was #{ entity[:'index']}" unless SECOND_ENTITY[:index] == entity['index']
105
+
106
+ raise "Entity name mismatch. Expected #{SECOND_ENTITY[:name]} but was #{entity['name']}" unless SECOND_ENTITY[:name] == entity['name']
107
+
108
+
109
+
110
+
111
+ puts "Verifying a connection from #{FIRST_ENTITY[:name]} to #{SECOND_ENTITY[:name]}"
112
+
113
+ #verify the connection
114
+ entity = @application[:tests][FIRST_ENTITY[:name]][:connection][:tests][SECOND_ENTITY[:name]].get.entity
115
+
116
+
117
+ raise "Entity #{SECOND_ENTITY[:name]} not found on connection #{:connection}" if entity.nil?
118
+
119
+ raise "Entity index mismatch. Expected #{SECOND_ENTITY[:index]} but was #{entity['index']}" unless SECOND_ENTITY[:index] == entity['index']
120
+
121
+ raise "Entity name mismatch. Expected #{SECOND_ENTITY[:name]} but was #{entity['name']}" unless SECOND_ENTITY[:name] == entity['name']
122
+
123
+
124
+ puts 'Verification complete. All entities and connections are correct'
125
+ end
126
+ end
127
+ end
@@ -0,0 +1,19 @@
1
+ require 'ugv/client'
2
+
3
+ desc "Read our data back, and validate it's correct"
4
+ arg_name '[api] [adminuser] [adminpassword] [orgname] [appname]'
5
+
6
+ command :verify do |c|
7
+ c.action do |global_options,options,args|
8
+ help_now! unless args.length == 5
9
+ setup = Ugv::Client.new(args[0], args[1], args[2], args[3], args[4])
10
+ help_now! unless setup.validate
11
+
12
+ setup.setup
13
+ setup.verify
14
+
15
+
16
+
17
+ end
18
+
19
+ end
@@ -0,0 +1,19 @@
1
+ require 'ugv/client'
2
+
3
+ desc "Read our data back, and validate it's correct"
4
+ arg_name '[api] [adminuser] [adminpassword] [orgname] [appname]'
5
+
6
+ command :write do |c|
7
+ c.action do |global_options, options, args|
8
+ help_now! unless args.length == 5
9
+ setup = Ugv::Client.new(args[0], args[1], args[2], args[3], args[4])
10
+ help_now! unless setup.validate
11
+ #
12
+ setup.setup
13
+ setup.create
14
+
15
+
16
+
17
+ end
18
+
19
+ end
@@ -0,0 +1,3 @@
1
+ module Ugv
2
+ VERSION = "0.0.1"
3
+ end
data/lib/ugv.rb ADDED
@@ -0,0 +1,2 @@
1
+ require 'ugv/version.rb'
2
+ require 'ugv/client.rb'
data/ugv.gemspec ADDED
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ugv/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ugv"
8
+ spec.version = Ugv::VERSION
9
+ spec.authors = ["Todd Nine"]
10
+ spec.email = ["tnine@apigee.com"]
11
+ spec.description = %q{Writes data to an org/app, then verifies it}
12
+ spec.summary = %q{Writes and verifies data in a UG system}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables << 'ugv'
18
+ spec.require_paths = ["lib"]
19
+
20
+
21
+ spec.add_runtime_dependency('gli', '>= 2.6')
22
+ spec.add_runtime_dependency('usergrid_iron','>= 0.9.1')
23
+ spec.add_runtime_dependency('json', '>=1.8.0')
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.3"
26
+ spec.add_development_dependency "rake"
27
+
28
+ end
metadata ADDED
@@ -0,0 +1,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ugv
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Todd Nine
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-10-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: gli
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '2.6'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '2.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: usergrid_iron
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: 0.9.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: 0.9.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: json
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: 1.8.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 1.8.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.3'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '1.3'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Writes data to an org/app, then verifies it
84
+ email:
85
+ - tnine@apigee.com
86
+ executables:
87
+ - ugv
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - .gitignore
92
+ - .idea/encodings.xml
93
+ - .idea/misc.xml
94
+ - .idea/modules.xml
95
+ - .idea/scopes/scope_settings.xml
96
+ - .idea/ug-validation.iml
97
+ - .idea/vcs.xml
98
+ - Gemfile
99
+ - LICENSE.txt
100
+ - README.md
101
+ - Rakefile
102
+ - bin/ugv
103
+ - lib/ugv.rb
104
+ - lib/ugv/client.rb
105
+ - lib/ugv/commands/verify.rb
106
+ - lib/ugv/commands/write.rb
107
+ - lib/ugv/version.rb
108
+ - ugv.gemspec
109
+ homepage: ''
110
+ licenses:
111
+ - MIT
112
+ metadata: {}
113
+ post_install_message:
114
+ rdoc_options: []
115
+ require_paths:
116
+ - lib
117
+ required_ruby_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ! '>='
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ! '>='
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ requirements: []
128
+ rubyforge_project:
129
+ rubygems_version: 2.1.8
130
+ signing_key:
131
+ specification_version: 4
132
+ summary: Writes and verifies data in a UG system
133
+ test_files: []