kinokero 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (187) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +44 -0
  3. data/.ruby-gemset +1 -0
  4. data/.ruby-version +1 -0
  5. data/Gemfile +6 -0
  6. data/Gemfile.lock +49 -0
  7. data/Gemfile_mock +8 -0
  8. data/LICENSE +20 -0
  9. data/README.md +955 -0
  10. data/Rakefile +1 -0
  11. data/console/.ruby-gemset +1 -0
  12. data/console/.ruby-version +1 -0
  13. data/console/Gemfile +6 -0
  14. data/console/Gemfile.lock +63 -0
  15. data/console/README.md +34 -0
  16. data/console/config/application_configuration.rb +39 -0
  17. data/console/config/gcp_seed.yml +73 -0
  18. data/console/config/kinokero_initializer_template.rb +108 -0
  19. data/console/console +2 -0
  20. data/console/irb_console +2 -0
  21. data/console/lib/appliance_common.rb +73 -0
  22. data/console/twiga.rb +579 -0
  23. data/hp-check.log +244 -0
  24. data/kinokero.gemspec +35 -0
  25. data/lib/kinokero.rb +183 -0
  26. data/lib/kinokero/blank.rb +105 -0
  27. data/lib/kinokero/cloudprint.rb +1159 -0
  28. data/lib/kinokero/device.rb +6 -0
  29. data/lib/kinokero/jingle.rb +176 -0
  30. data/lib/kinokero/log.rb +157 -0
  31. data/lib/kinokero/printer.rb +313 -0
  32. data/lib/kinokero/proxy.rb +341 -0
  33. data/lib/kinokero/ruby_extensions.rb +21 -0
  34. data/lib/kinokero/sasl_xoauth2.rb +164 -0
  35. data/lib/kinokero/version.rb +3 -0
  36. data/lib/proto/cloud_device_description.proto +18 -0
  37. data/lib/proto/cloud_device_state.proto +30 -0
  38. data/lib/proto/cloud_device_state_type.proto +20 -0
  39. data/lib/proto/cloud_device_ui_state.proto +42 -0
  40. data/lib/proto/cloud_device_ui_state_severity.proto +12 -0
  41. data/lib/proto/cloud_job_ticket.proto +18 -0
  42. data/lib/proto/collate.proto +4 -0
  43. data/lib/proto/collate_ticket_item.proto +5 -0
  44. data/lib/proto/color.proto +42 -0
  45. data/lib/proto/color_ticket_item.proto +12 -0
  46. data/lib/proto/copies.proto +6 -0
  47. data/lib/proto/copies_ticket_item.proto +5 -0
  48. data/lib/proto/cover.proto +31 -0
  49. data/lib/proto/cover_state.proto +25 -0
  50. data/lib/proto/device_action_cause.proto +19 -0
  51. data/lib/proto/dpi.proto +27 -0
  52. data/lib/proto/dpi_ticket_item.proto +13 -0
  53. data/lib/proto/duplex.proto +15 -0
  54. data/lib/proto/duplex_ticket_item.proto +8 -0
  55. data/lib/proto/fit_to_page.proto +20 -0
  56. data/lib/proto/fit_to_page_ticket_item.proto +8 -0
  57. data/lib/proto/input_tray_state.proto +31 -0
  58. data/lib/proto/input_tray_unit.proto +35 -0
  59. data/lib/proto/job_state.proto +143 -0
  60. data/lib/proto/local_settings.proto +36 -0
  61. data/lib/proto/localized_string.proto +119 -0
  62. data/lib/proto/margins.proto +33 -0
  63. data/lib/proto/margins_ticket_item.proto +14 -0
  64. data/lib/proto/marker.proto +62 -0
  65. data/lib/proto/marker_state.proto +31 -0
  66. data/lib/proto/media_path.proto +6 -0
  67. data/lib/proto/media_path_state.proto +25 -0
  68. data/lib/proto/media_size.proto +216 -0
  69. data/lib/proto/media_size_ticket_item.proto +17 -0
  70. data/lib/proto/output_bin_state.proto +31 -0
  71. data/lib/proto/output_bin_unit.proto +32 -0
  72. data/lib/proto/page_orientation.proto +16 -0
  73. data/lib/proto/page_orientation_ticket_item.proto +9 -0
  74. data/lib/proto/page_range.proto +15 -0
  75. data/lib/proto/page_range_ticket_item.proto +7 -0
  76. data/lib/proto/print_job_state.proto +18 -0
  77. data/lib/proto/print_job_state_diff.proto +13 -0
  78. data/lib/proto/print_job_ui_state.proto +24 -0
  79. data/lib/proto/print_ticket_section.proto +30 -0
  80. data/lib/proto/printer_description_section.proto +107 -0
  81. data/lib/proto/printer_state_section.proto +49 -0
  82. data/lib/proto/printer_ui_state_section.proto +39 -0
  83. data/lib/proto/printing_speed.proto +35 -0
  84. data/lib/proto/pwg_raster_config.proto +176 -0
  85. data/lib/proto/range_capability.proto +14 -0
  86. data/lib/proto/reverse_order.proto +5 -0
  87. data/lib/proto/reverse_order_ticket_item.proto +5 -0
  88. data/lib/proto/scanner_description_section.proto +5 -0
  89. data/lib/proto/scanner_state_section.proto +25 -0
  90. data/lib/proto/select_capability.proto +31 -0
  91. data/lib/proto/supported_content_type.proto +12 -0
  92. data/lib/proto/typed_value_capability.proto +15 -0
  93. data/lib/proto/vendor_capability.proto +40 -0
  94. data/lib/proto/vendor_state.proto +26 -0
  95. data/lib/proto/vendor_ticket_item.proto +9 -0
  96. data/lib/proto_lib/cloud_device_state.pb.rb +21 -0
  97. data/lib/proto_lib/cloud_device_state_type.pb.rb +16 -0
  98. data/lib/proto_lib/cloud_device_ui_state.pb.rb +22 -0
  99. data/lib/proto_lib/cloud_device_ui_state_severity.pb.rb +17 -0
  100. data/lib/proto_lib/collate.pb.rb +11 -0
  101. data/lib/proto_lib/color.pb.rb +31 -0
  102. data/lib/proto_lib/copies.pb.rb +12 -0
  103. data/lib/proto_lib/cover.pb.rb +21 -0
  104. data/lib/proto_lib/cover_state.pb.rb +27 -0
  105. data/lib/proto_lib/device_action_cause.pb.rb +18 -0
  106. data/lib/proto_lib/dpi.pb.rb +27 -0
  107. data/lib/proto_lib/duplex.pb.rb +26 -0
  108. data/lib/proto_lib/fit_to_page.pb.rb +28 -0
  109. data/lib/proto_lib/input_tray_state.pb.rb +30 -0
  110. data/lib/proto_lib/input_tray_unit.pb.rb +25 -0
  111. data/lib/proto_lib/job_state.pb.rb +99 -0
  112. data/lib/proto_lib/localized_string.pb.rb +118 -0
  113. data/lib/proto_lib/margins.pb.rb +30 -0
  114. data/lib/proto_lib/marker.pb.rb +45 -0
  115. data/lib/proto_lib/marker_state.pb.rb +30 -0
  116. data/lib/proto_lib/media_path.pb.rb +11 -0
  117. data/lib/proto_lib/media_path_state.pb.rb +27 -0
  118. data/lib/proto_lib/media_size.pb.rb +198 -0
  119. data/lib/proto_lib/output_bin_state.pb.rb +30 -0
  120. data/lib/proto_lib/output_bin_unit.pb.rb +22 -0
  121. data/lib/proto_lib/page_orientation.pb.rb +26 -0
  122. data/lib/proto_lib/page_range.pb.rb +20 -0
  123. data/lib/proto_lib/print_job_state_diff.pb.rb +12 -0
  124. data/lib/proto_lib/printer_description_section.pb.rb +30 -0
  125. data/lib/proto_lib/printer_state_section.pb.rb +23 -0
  126. data/lib/proto_lib/printer_ui_state_section.pb.rb +28 -0
  127. data/lib/proto_lib/printing_speed.pb.rb +21 -0
  128. data/lib/proto_lib/pwg_raster_config.pb.rb +103 -0
  129. data/lib/proto_lib/range_capability.pb.rb +19 -0
  130. data/lib/proto_lib/reverse_order.pb.rb +11 -0
  131. data/lib/proto_lib/scanner_description_section.pb.rb +10 -0
  132. data/lib/proto_lib/scanner_state_section.pb.rb +17 -0
  133. data/lib/proto_lib/select_capability.pb.rb +22 -0
  134. data/lib/proto_lib/supported_content_type.pb.rb +13 -0
  135. data/lib/proto_lib/typed_value_capability.pb.rb +19 -0
  136. data/lib/proto_lib/vendor_capability.pb.rb +23 -0
  137. data/lib/proto_lib/vendor_state.pb.rb +27 -0
  138. data/test/.ruby-gemset +1 -0
  139. data/test/.ruby-version +1 -0
  140. data/test/Gemfile +68 -0
  141. data/test/Gemfile.lock +269 -0
  142. data/test/README.md +2 -0
  143. data/test/Rakefile +6 -0
  144. data/test/app/assets/javascripts/application.js +16 -0
  145. data/test/app/assets/stylesheets/application.css +13 -0
  146. data/test/app/controllers/application_controller.rb +13 -0
  147. data/test/app/controllers/home_controller.rb +10 -0
  148. data/test/app/helpers/application_helper.rb +2 -0
  149. data/test/app/views/home/index.html.erb +2 -0
  150. data/test/app/views/home/show.html.erb +2 -0
  151. data/test/app/views/layouts/application.html.erb +14 -0
  152. data/test/bin/bundle +3 -0
  153. data/test/bin/rails +4 -0
  154. data/test/bin/rake +4 -0
  155. data/test/config/application.rb +29 -0
  156. data/test/config/boot.rb +4 -0
  157. data/test/config/database.yml +25 -0
  158. data/test/config/environment.rb +5 -0
  159. data/test/config/environments/development.rb +48 -0
  160. data/test/config/environments/production.rb +95 -0
  161. data/test/config/environments/test.rb +42 -0
  162. data/test/config/initializers/backtrace_silencers.rb +7 -0
  163. data/test/config/initializers/filter_parameter_logging.rb +4 -0
  164. data/test/config/initializers/inflections.rb +16 -0
  165. data/test/config/initializers/mime_types.rb +5 -0
  166. data/test/config/initializers/secret_token.rb +12 -0
  167. data/test/config/initializers/session_store.rb +3 -0
  168. data/test/config/initializers/wrap_parameters.rb +14 -0
  169. data/test/config/locales/en.yml +23 -0
  170. data/test/config/routes.rb +65 -0
  171. data/test/db/development.sqlite3 +0 -0
  172. data/test/db/migrate/20111012050200_add_sessions_table.rb +12 -0
  173. data/test/db/schema.rb +26 -0
  174. data/test/db/seeds.rb +7 -0
  175. data/test/db/test.sqlite3 +0 -0
  176. data/test/log/development.log +0 -0
  177. data/test/log/test.log +0 -0
  178. data/test/test/controllers/home_controller_test.rb +133 -0
  179. data/test/test/ctlr_test_helper.rb +7 -0
  180. data/test/test/fixtures/gcp_seed.yml +51 -0
  181. data/test/test/models/cloudprint_test.rb +186 -0
  182. data/test/test/models/jingle_test.rb +44 -0
  183. data/test/test/models/printer_test.rb +99 -0
  184. data/test/test/models/proxy_test.rb +102 -0
  185. data/test/test/test_helper.rb +31 -0
  186. data/test/test/test_kinokero.rb +234 -0
  187. metadata +462 -0
@@ -0,0 +1,23 @@
1
+ # Files in the config/locales directory are used for internationalization
2
+ # and are automatically loaded by Rails. If you want to use locales other
3
+ # than English, add the necessary files in this directory.
4
+ #
5
+ # To use the locales, use `I18n.t`:
6
+ #
7
+ # I18n.t 'hello'
8
+ #
9
+ # In views, this is aliased to just `t`:
10
+ #
11
+ # <%= t('hello') %>
12
+ #
13
+ # To use a different locale, set it with `I18n.locale`:
14
+ #
15
+ # I18n.locale = :es
16
+ #
17
+ # This would use the information in config/locales/es.yml.
18
+ #
19
+ # To learn more, please read the Rails Internationalization guide
20
+ # available at http://guides.rubyonrails.org/i18n.html.
21
+
22
+ en:
23
+ hello: "Hello world"
@@ -0,0 +1,65 @@
1
+ Kinokerotest::Application.routes.draw do
2
+ get "home/welcome", :as => :welcome
3
+
4
+ get "home/index"
5
+ get "home/show"
6
+ root :to => "home#index"
7
+
8
+
9
+
10
+
11
+ # The priority is based upon order of creation: first created -> highest priority.
12
+ # See how all your routes lay out with "rake routes".
13
+
14
+ # You can have the root of your site routed with "root"
15
+ # root 'welcome#index'
16
+
17
+ # Example of regular route:
18
+ # get 'products/:id' => 'catalog#view'
19
+
20
+ # Example of named route that can be invoked with purchase_url(id: product.id)
21
+ # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
22
+
23
+ # Example resource route (maps HTTP verbs to controller actions automatically):
24
+ # resources :products
25
+
26
+ # Example resource route with options:
27
+ # resources :products do
28
+ # member do
29
+ # get 'short'
30
+ # post 'toggle'
31
+ # end
32
+ #
33
+ # collection do
34
+ # get 'sold'
35
+ # end
36
+ # end
37
+
38
+ # Example resource route with sub-resources:
39
+ # resources :products do
40
+ # resources :comments, :sales
41
+ # resource :seller
42
+ # end
43
+
44
+ # Example resource route with more complex sub-resources:
45
+ # resources :products do
46
+ # resources :comments
47
+ # resources :sales do
48
+ # get 'recent', on: :collection
49
+ # end
50
+ # end
51
+
52
+ # Example resource route with concerns:
53
+ # concern :toggleable do
54
+ # post 'toggle'
55
+ # end
56
+ # resources :posts, concerns: :toggleable
57
+ # resources :photos, concerns: :toggleable
58
+
59
+ # Example resource route within a namespace:
60
+ # namespace :admin do
61
+ # # Directs /admin/products/* to Admin::ProductsController
62
+ # # (app/controllers/admin/products_controller.rb)
63
+ # resources :products
64
+ # end
65
+ end
@@ -0,0 +1,12 @@
1
+ class AddSessionsTable < ActiveRecord::Migration
2
+ def change
3
+ create_table :sessions do |t|
4
+ t.string :session_id, :null => false
5
+ t.text :data
6
+ t.timestamps
7
+ end
8
+
9
+ add_index :sessions, :session_id, :unique => true
10
+ add_index :sessions, :updated_at
11
+ end
12
+ end
@@ -0,0 +1,26 @@
1
+ # encoding: UTF-8
2
+ # This file is auto-generated from the current state of the database. Instead
3
+ # of editing this file, please use the migrations feature of Active Record to
4
+ # incrementally modify your database, and then regenerate this schema definition.
5
+ #
6
+ # Note that this schema.rb definition is the authoritative source for your
7
+ # database schema. If you need to create the application database on another
8
+ # system, you should be using db:schema:load, not running all the migrations
9
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
11
+ #
12
+ # It's strongly recommended that you check this file into your version control system.
13
+
14
+ ActiveRecord::Schema.define(version: 20111012050200) do
15
+
16
+ create_table "sessions", force: true do |t|
17
+ t.string "session_id", null: false
18
+ t.text "data"
19
+ t.datetime "created_at"
20
+ t.datetime "updated_at"
21
+ end
22
+
23
+ add_index "sessions", ["session_id"], name: "index_sessions_on_session_id", unique: true
24
+ add_index "sessions", ["updated_at"], name: "index_sessions_on_updated_at"
25
+
26
+ end
@@ -0,0 +1,7 @@
1
+ # This file should contain all the record creation needed to seed the database with its default values.
2
+ # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3
+ #
4
+ # Examples:
5
+ #
6
+ # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
7
+ # Mayor.create(name: 'Emanuel', city: cities.first)
Binary file
File without changes
File without changes
@@ -0,0 +1,133 @@
1
+ require 'ctlr_test_helper'
2
+
3
+ class HomeControllerTest < ActionController::TestCase
4
+
5
+ context 'home ctlr' do
6
+ setup do
7
+ Tenant.set_current_tenant( tenants( :tenant_1 ).id )
8
+ end
9
+
10
+ should "get index" do
11
+ get :index
12
+ assert_response :success
13
+ end
14
+
15
+ should "get show with login" do
16
+ sign_in( users( :quentin ) )
17
+ get :show
18
+ assert_response :success
19
+ sign_out( users( :quentin ) )
20
+ end # should do
21
+
22
+ should 'not get show without login' do
23
+ assert_raise(ArgumentError, 'uncaught throw :warden'){
24
+ get :show
25
+ }
26
+ assert_response :success
27
+ end # should do
28
+
29
+ should 'reset tenant' do
30
+ assert Tenant.current_tenant_id
31
+ @controller.__milia_reset_tenant! # invoke the private method
32
+ assert_nil Tenant.current_tenant_id
33
+
34
+ end # should do
35
+
36
+ should 'change tenant' do
37
+ assert_equal 1,Tenant.current_tenant_id
38
+ @controller.__milia_change_tenant!(2) # invoke the private method
39
+ assert_equal 2,Tenant.current_tenant_id
40
+ end # should do
41
+
42
+ should 'trace tenanting' do
43
+ ::Milia.trace_on = true
44
+ @controller.trace_tenanting( "wild blue" )
45
+ ::Milia.trace_on = false
46
+ @controller.trace_tenanting( "duck walk" )
47
+ end # should do
48
+
49
+ should 'initiate tenant' do
50
+ @controller.initiate_tenant( tenants(:tenant_2) )
51
+ assert_equal 2,Tenant.current_tenant_id
52
+ end # should do
53
+
54
+ should 'redirect back' do
55
+ # alter the code to invoke redirect_back
56
+ @controller.class.module_eval(
57
+ %q{
58
+ def index()
59
+ redirect_back
60
+ end
61
+ }
62
+ )
63
+
64
+ # now test it
65
+ get :index
66
+ assert_response :redirect
67
+ assert_redirected_to root_url()
68
+
69
+ end # should do
70
+
71
+ should 'prep signup view' do
72
+ assert_nil @controller.instance_eval( "@tenant" )
73
+ @controller.prep_signup_view(
74
+ { name: 'Mangoland' },
75
+ {email: 'billybob@bob.com', password: 'monkeymocha', password_confirmation: 'monkeymocha'}
76
+ )
77
+ assert_equal 'Mangoland', @controller.instance_eval( "@tenant" ).name
78
+ end # should do
79
+
80
+ should 'handle max_tenants exception' do
81
+ # alter the code to invoke redirect_back
82
+ @controller.class.module_eval(
83
+ %q{
84
+ def index()
85
+ max_tenants
86
+ end
87
+ }
88
+ )
89
+
90
+ # now test it
91
+ get :index, { user: { email: 'billybob@bob.com' }, tenant: {name: 'Mangoland'} }
92
+ assert_response :redirect
93
+ assert_redirected_to root_url()
94
+
95
+ end # should do
96
+
97
+
98
+ should 'set current tenant - user not signed in' do
99
+ assert @controller.set_current_tenant( 2 )
100
+ assert_nil Tenant.current_tenant_id
101
+ end # should do
102
+
103
+
104
+ should 'set current tenant - user signed in; tid not nil; valid for user' do
105
+ sign_in( users( :quentin ) )
106
+ assert @controller.set_current_tenant( 2 )
107
+ assert_equal 2,Tenant.current_tenant_id
108
+ end # should do
109
+
110
+ should 'set current tenant - user signed in; tid not nil; invalid for user' do
111
+ sign_in( users( :quentin ) )
112
+ assert_raise(Milia::Control::InvalidTenantAccess){
113
+ @controller.set_current_tenant( 3 )
114
+ }
115
+ assert_equal 1,Tenant.current_tenant_id # should be unchanged
116
+ end # should do
117
+
118
+
119
+ should 'authenticate tenant - 1' do
120
+
121
+ @controller.set_current_tenant( )
122
+ sign_in( users( :quentin ) )
123
+ @controller.authenticate_tenant!
124
+ assert_response :success
125
+ assert_equal 1,Tenant.current_tenant_id
126
+
127
+ end # should do
128
+
129
+
130
+
131
+ end # context
132
+
133
+ end # end class test
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class ActiveSupport::TestCase
4
+
5
+
6
+ end # class
7
+
@@ -0,0 +1,51 @@
1
+ ---
2
+ test:
3
+ printer_id: 0
4
+ item: test
5
+ cups_alias: lp_null
6
+ is_active: false
7
+ virgin_access: false
8
+ gcp_xmpp_jid: 345e2_garbagegarbagegarbagegarbage_c7@cloudprint.googleusercontent.com
9
+ gcp_confirmation_url: https://www.google.com/cloudprint/regconfirmpage?printername=gcp_test_printer&email=sample_owner@gmail.com&dpi=300&pagesize=215900,279400
10
+ gcp_owner_email: sample_owner@gmail.com
11
+ gcp_printer_name: gcp_test_printer
12
+ gcp_printerid: d0510370-_garbagegarbagegarbagegarbage_-f93c0756a5d9
13
+ gcp_access_token: ya29.UwCf_garbagegarbagegarbage_garbagegarbagegarbagegarbage_xUYXpBXqEw
14
+ gcp_refresh_token: 1/MPXAGbW_garbagegarbagegarbagegarbage_d5aU_w
15
+ gcp_token_type: Bearer
16
+ gcp_token_expiry_time: 2014-07-31 16:35:00.538511653 -07:00
17
+ capability_ppd: /etc/cups/ppd/laserjet_1102w.ppd
18
+ capability_cdd: /etc/cups/cdd/laserjet_1102w.cdd
19
+ gcp_uuid: VND3R11877
20
+ gcp_manufacturer: Hewlett-Packard
21
+ gcp_model: LaserJet P1102w
22
+ gcp_setup_url: http://www8.hp.com/us/en/campaigns/wireless-printing-center/printer-setup-help.html
23
+ gcp_support_url: http://h10025.www1.hp.com/ewfrf/wc/product?product=4110396&lc=en&cc=us&dlc=en&lang=en&cc=us
24
+ gcp_update_url: http://h10025.www1.hp.com/ewfrf/wc/product?product=4110396&lc=en&cc=us&dlc=en&lang=en&cc=us
25
+ gcp_firmware: '20130703'
26
+
27
+ # item: lime is expected to be not registered anymore and not active
28
+ lime:
29
+ gcp_xmpp_jid: 3e0163e6_garbagegarbagegarbagegarbage_929@cloudprint.googleusercontent.com
30
+ gcp_confirmation_url: https://www.google.com/cloudprint/regconfirmpage?printername=gcp_lime_printer&email=dsanderson77@gmail.com&dpi=300&pagesize=215900,279400
31
+ gcp_owner_email: sample_owner@gmail.com
32
+ gcp_printer_name: gcp_lime_printer
33
+ gcp_printerid: 8231517c-716d-4b0a-f721-83fdbe52a05d
34
+ gcp_access_token: ya29.UgA-fX_garbagegarbagegarbagegarbage_F2a1vhEQa4G4_QSltFK_g
35
+ gcp_refresh_token: 1/NjwUJ_garbagegarbagegarbagegarbage_usRPkLH0
36
+ gcp_token_type: Bearer
37
+ gcp_token_expiry_time: 2014-07-30 10:27:22.592090444 -07:00
38
+ is_active: false
39
+ virgin_access: false
40
+ printer_id: 0
41
+ item: lime
42
+ cups_alias: lp_null
43
+ capability_ppd: /etc/cups/ppd/laserjet_1102w.ppd
44
+ capability_cdd: /etc/cups/cdd/laserjet_1102w.cdd
45
+ gcp_uuid: VND3R11877
46
+ gcp_manufacturer: Hewlett-Packard
47
+ gcp_model: LaserJet P1102w
48
+ gcp_setup_url: http://www8.hp.com/us/en/campaigns/wireless-printing-center/printer-setup-help.html
49
+ gcp_support_url: http://h10025.www1.hp.com/ewfrf/wc/product?product=4110396&lc=en&cc=us&dlc=en&lang=en&cc=us
50
+ gcp_update_url: http://h10025.www1.hp.com/ewfrf/wc/product?product=4110396&lc=en&cc=us&dlc=en&lang=en&cc=us
51
+ gcp_firmware: '20130703'
@@ -0,0 +1,186 @@
1
+ require 'test_helper'
2
+ require 'test_kinokero'
3
+
4
+ class CloudprintTest < ActiveSupport::TestCase
5
+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6
+ setup :setup_jig
7
+ teardown :teardown_jig
8
+
9
+ context "cloudprint" do
10
+
11
+ should 'get printer list' do
12
+ list_result = @proxy.my_devices['test'].cloudprint.gcp_get_printer_list
13
+ assert list_result['success'] # should always return success even if no printers
14
+
15
+ if @proxy.my_devices['test'].gcp_printer_control[:is_active] # for an active printer
16
+ assert !list_result["printers"].empty?
17
+ printerid = @proxy.my_devices['test'].gcp_printer_control[:gcp_printerid]
18
+ assert list_result["printers"].any? { |p| p["id"] == printerid }
19
+ else # for inactive printer
20
+ assert list_result["printers"].empty?
21
+ end
22
+ end # end should test
23
+
24
+ should 'refresh tokens' do
25
+ if @proxy.my_devices['test'].gcp_printer_control[:is_active] # for an active printer
26
+ refresh_result =@proxy.my_devices['test'].cloudprint.gcp_refresh_tokens
27
+ assert refresh_result['success']
28
+ end
29
+ end # end should test
30
+
31
+ should 'update device status' do
32
+
33
+ if @proxy.my_devices['test'].gcp_printer_control[:is_active] # for an active printer
34
+
35
+ update_result = @proxy.my_devices['test'].cloudprint.gcp_ready_state_changed(
36
+ true, # shows ready for jobs
37
+ 0, # waiting for work
38
+ '' # no reason description needed
39
+ )
40
+
41
+ assert !update_result['success'] # should fail cuz printer not connected & ready
42
+
43
+ end # if active
44
+
45
+ end # end should test
46
+
47
+ # *****************************************************************************
48
+ # The following tests are primarily testing the setup and server calls to GCP
49
+ # Because the test printer in the fixture is 'old' or off-line, all of the calls
50
+ # will fail ... but at least we can test that the set up and call occurred and
51
+ # returned an unsuccessful result.
52
+ # *****************************************************************************
53
+
54
+ should 'register offshoot printer' do
55
+
56
+ item = 'wildblue'
57
+
58
+ # build an offshoot request list
59
+ new_request = build_gcp_request( item )
60
+
61
+ response = Kinokero::Cloudprint.register_anonymous_printer( new_request ) do |gcp_ctl|
62
+
63
+ # wrap the newly registered printer in a device object
64
+ # new_device = Kinokero::Printer.new( gcp_ctl, new_request)
65
+
66
+ # create a cloudprint object to manage the protocols
67
+ # cloudprint =
68
+ # Kinokero::Cloudprint.new( gcp_ctl, {} )
69
+
70
+ end # handle new printer information
71
+
72
+ assert response[:success]
73
+
74
+ end # end should test
75
+
76
+ should 'fail to poll an old printer id claim' do
77
+
78
+ poll_url = "https://www.google.com/cloudprint/getauthcode?printerid=#{@proxy.my_devices['test'].gcp_printer_control[:printer_id]}&oauth_client_id=" + Kinokero.proxy_client_id
79
+ poll_response = Kinokero::Cloudprint.gcp_poll_request( poll_url )
80
+ assert !poll_response.body['success'] # should have failed
81
+
82
+ end # end should test
83
+
84
+
85
+ should 'form a jingle auth token' do
86
+
87
+ @proxy.my_devices['test'].gcp_printer_control[:virgin_access] = true # force logic
88
+ token = @proxy.my_devices['test'].cloudprint.gcp_form_jingle_auth_token()
89
+
90
+ assert_kind_of String,token
91
+ assert_not_equal '',token
92
+
93
+ end # end should test
94
+
95
+
96
+ should 'form an auth token' do
97
+
98
+ token = @proxy.my_devices['test'].cloudprint.gcp_form_auth_token()
99
+
100
+ assert_kind_of String,token
101
+ assert_not_equal '',token
102
+
103
+ end # end should test
104
+
105
+ should 'fail to get oauth2 token using an old token' do
106
+
107
+ old_token = "4/efjvnDKE7-fklBzH8G7KZVQ3S1V7.ckxazuujaQMWshQV0ieZDArE9o5tjAI"
108
+ oauth_response = Kinokero::Cloudprint.gcp_get_oauth2_tokens( old_token ).body
109
+ assert !oauth_response['success'] # should fail on old data
110
+
111
+ end # end should test
112
+
113
+ should 'fail to get job file' do
114
+
115
+ file_url = 'https://www.google.com/cloudprint/download?id=d8f3fe33-a07f-c554-7f9b-ab80c7103030'
116
+ assert_nil @proxy.my_devices['test'].cloudprint.gcp_get_job_file( file_url )
117
+
118
+ end # end should test
119
+
120
+ should 'fail to get printer job queue fetch' do
121
+
122
+ fetch_response = @proxy.my_devices['test'].cloudprint.gcp_get_printer_fetch(
123
+ @proxy.my_devices['test'].gcp_printer_control[:printer_id]
124
+ )
125
+ assert !fetch_response['success'] # should fail on old data
126
+
127
+ end # end should test
128
+
129
+ should 'determine test printer is still active' do
130
+
131
+ assert @proxy.my_devices['test'].cloudprint.printer_still_active?
132
+
133
+ end # end should test
134
+
135
+ should 'fail job status change' do
136
+
137
+ jobid = 'd8f3fe33-a07f-c554-7f9b-ab80c7103030'
138
+ status_response = @proxy.my_devices['test'].cloudprint.gcp_job_status(
139
+ jobid,
140
+ ::Kinokero::Cloudprint::GCP_JOBSTATE_DONE,
141
+ 1
142
+ )
143
+ assert !status_response['success'] # should fail on old data
144
+
145
+ end # end should test
146
+
147
+
148
+ should 'fail job status abort' do
149
+
150
+ jobid = 'd8f3fe33-a07f-c554-7f9b-ab80c7103030'
151
+ status_response = @proxy.my_devices['test'].cloudprint.gcp_job_status_abort(
152
+ jobid,
153
+ 0, # currently not used
154
+ 0
155
+ )
156
+ assert !status_response['success'] # should fail on old data
157
+
158
+ end # end should test
159
+
160
+
161
+ should 'fail ready state changed' do
162
+
163
+ status_response = @proxy.my_devices['test'].cloudprint.gcp_ready_state_changed(
164
+ true, # shows ready for jobs
165
+ 0, # waiting for work
166
+ 'wild blue' # reason
167
+ )
168
+ assert !status_response['success'] # should fail on old data
169
+
170
+ end # end should test
171
+
172
+
173
+ should 'fail to delete printer' do
174
+
175
+ delete_response = @proxy.my_devices['lime'].cloudprint.gcp_delete_printer( )
176
+ assert !delete_response['success'] # should fail on old data
177
+
178
+ end # end should test
179
+
180
+
181
+
182
+ end # context post
183
+
184
+ # _____________________________________________________________________________
185
+
186
+ end # class test