kaui 0.7.2 → 0.8.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.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +1 -2
  4. data/Gemfile.lock +59 -38
  5. data/README.md +12 -9
  6. data/Rakefile +9 -0
  7. data/{lib/generators/kaui/install/templates/app/assets/javascripts/kaui/all.js → app/assets/javascripts/application.js} +2 -5
  8. data/{lib/generators/kaui/install/templates/app/assets/stylesheets/kaui/all.css → app/assets/stylesheets/application.css} +0 -4
  9. data/app/assets/stylesheets/bootstrap_and_overrides.css +7 -0
  10. data/app/controllers/kaui/admin_allowed_users_controller.rb +48 -0
  11. data/app/controllers/kaui/admin_tenants_controller.rb +97 -0
  12. data/app/controllers/kaui/engine_controller.rb +28 -31
  13. data/app/controllers/kaui/engine_controller_util.rb +33 -0
  14. data/app/controllers/kaui/login_proxy_controller.rb +11 -0
  15. data/app/controllers/kaui/sessions_controller.rb +12 -0
  16. data/app/controllers/kaui/tenants_controller.rb +60 -0
  17. data/app/models/kaui/ability.rb +20 -3
  18. data/app/models/kaui/admin_tenant.rb +10 -0
  19. data/app/models/kaui/allowed_user.rb +8 -0
  20. data/app/models/kaui/allowed_user_tenant.rb +6 -0
  21. data/app/models/kaui/killbill_authenticatable.rb +5 -18
  22. data/app/models/kaui/tenant.rb +13 -0
  23. data/app/models/kaui/user.rb +14 -16
  24. data/app/views/kaui/admin_allowed_users/index.html.erb +23 -0
  25. data/app/views/kaui/admin_allowed_users/new.html.erb +22 -0
  26. data/app/views/kaui/admin_allowed_users/show.html.erb +53 -0
  27. data/app/views/kaui/admin_tenants/index.html.erb +25 -0
  28. data/app/views/kaui/admin_tenants/new.html.erb +32 -0
  29. data/app/views/kaui/admin_tenants/show.html.erb +68 -0
  30. data/app/views/kaui/invoices/show.html.erb +1 -1
  31. data/app/views/kaui/tenants/index.html.erb +17 -0
  32. data/config/initializers/killbill_authenticatable.rb +3 -5
  33. data/config/locales/en.bootstrap.yml +18 -0
  34. data/config/routes.rb +27 -1
  35. data/config/symmetric-encryption.yml +135 -0
  36. data/db/ddl.sql +33 -2
  37. data/db/migrate/20130812155313_devise_create_kaui_users.rb +1 -3
  38. data/db/migrate/20150109214021_create_kaui_tenants.rb +12 -0
  39. data/db/migrate/20150112232813_create_kaui_allowed_users.rb +19 -0
  40. data/kaui.gemspec +5 -3
  41. data/lib/kaui.rb +49 -1
  42. data/lib/kaui/version.rb +1 -1
  43. data/test/dummy/config/application.rb +3 -0
  44. data/test/dummy/config/database.yml +9 -0
  45. data/test/dummy/config/environments/development.rb +2 -2
  46. data/test/dummy/config/initializers/killbill_client.rb +2 -0
  47. data/test/dummy/config/symmetric-encryption.yml +135 -0
  48. data/test/dummy/db/migrate/{20130819152643_devise_create_kaui_users.kaui.rb → 20150116052157_devise_create_kaui_users.kaui.rb} +1 -3
  49. data/test/dummy/db/migrate/20150116052158_create_kaui_tenants.kaui.rb +13 -0
  50. data/test/dummy/db/migrate/20150116052159_create_kaui_allowed_users.kaui.rb +20 -0
  51. data/test/dummy/db/schema.rb +29 -3
  52. data/test/functional/kaui/admin_allowed_users_controller_test.rb +30 -0
  53. data/test/functional/kaui/admin_tenants_controller_test.rb +35 -0
  54. data/test/functional/kaui/functional_test_helper.rb +2 -50
  55. data/test/functional/kaui/functional_test_helper_nosetup.rb +53 -0
  56. data/test/functional/kaui/invoices_controller_test.rb +22 -0
  57. data/test/functional/kaui/tenants_controller_test.rb +60 -0
  58. data/test/integration/kaui/integration_test_helper.rb +2 -0
  59. data/test/integration/kaui/navigation_test.rb +1 -2
  60. data/test/killbill_test_helper.rb +46 -4
  61. data/test/test_helper.rb +1 -0
  62. data/test/unit/helpers/kaui/admin_allowed_users_helper_test.rb +6 -0
  63. data/test/unit/helpers/kaui/admin_tenants_helper_test.rb +6 -0
  64. data/test/unit/helpers/kaui/tenants_helper_test.rb +6 -0
  65. data/test/unit/kaui/allowed_user_test.rb +34 -0
  66. data/test/unit/kaui/tenant_test.rb +19 -0
  67. data/vendor/assets/javascripts/jquery.dataTables.min.js +155 -0
  68. metadata +86 -21
  69. data/app/assets/javascripts/kaui/analytics.js +0 -71
  70. data/app/assets/stylesheets/kaui/analytics.css +0 -30
  71. data/test/dummy/app/assets/javascripts/application.js +0 -21
  72. data/test/dummy/app/assets/stylesheets/application.css +0 -15
  73. data/test/dummy/app/views/layouts/application.html.erb +0 -48
  74. data/vendor/assets/javascripts/js/bootstrap-datepicker.cd46d38.js +0 -1211
  75. data/vendor/assets/javascripts/js/bootstrap.v2.2.1.min.js +0 -6
  76. data/vendor/assets/javascripts/js/jquery.dataTables.v1.9.3.min.js +0 -156
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fcfdad169627618fcedf7f8d57019705ddbd1fad
4
- data.tar.gz: ffb855fc7166ec29ff766a78b20bee6dc374011e
3
+ metadata.gz: b6a81e6e3a3619f778099f358dc74d3225cb53e8
4
+ data.tar.gz: 20c0ac946eeb47e2a1caf16b916b5d9541ec12ff
5
5
  SHA512:
6
- metadata.gz: 22c1fc01244a91e541c9037d314d0047e074ec2746931614094c8eb8b0ea4f09cb37b619255204a191c59c1dbf89bdf79d62e46d23c66f987f3de4120bd45343
7
- data.tar.gz: 775ec5703c332ca338732047d06b77e3be2cf964b5efbb50fd4d3b6eb272cd2d1aa719cc0f281cb326bb21e568f7db887208c30637a0a8dbba688c617be6853c
6
+ metadata.gz: 8e0c097898fc8ef1a2950043724888498061d9e4132bf0986e7060ef216098f8a575a98a84486580e2cd8039600543f793b5fa30f3fba8fe0e677feec723418b
7
+ data.tar.gz: d7e88959ca5f56094c30586856b3ead2d09dea34ca1620ee9029da414823950a3a03564b6d77d0426b701c2f8f0a08f6f20fe928dfc23c91da1764ea682c7107
data/.gitignore CHANGED
@@ -5,6 +5,7 @@ test/dummy/db/*.sqlite3
5
5
  test/dummy/log/*.log
6
6
  test/dummy/tmp/
7
7
  test/dummy/.sass-cache
8
+ test/dummy/public
8
9
  .idea
9
10
  sandbox
10
11
  foo
data/.travis.yml CHANGED
@@ -14,7 +14,6 @@ rvm:
14
14
  - jruby-head
15
15
 
16
16
  jdk:
17
- - openjdk6
18
17
  - openjdk7
19
18
  - oraclejdk7
20
19
 
@@ -23,7 +22,7 @@ before_script:
23
22
 
24
23
  script:
25
24
  - pushd test/dummy && RAILS_ENV=test bundle exec rake db:migrate --trace && RAILS_ENV=test bundle exec rake db:test:prepare && popd
26
- - bundle exec rake
25
+ - bundle exec rake test:units
27
26
 
28
27
  matrix:
29
28
  allow_failures:
data/Gemfile.lock CHANGED
@@ -1,25 +1,27 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kaui (0.7.2)
4
+ kaui (0.8.0)
5
5
  cancan (~> 1.6.10)
6
6
  carmen-rails (~> 1.0.0)
7
7
  d3_rails (~> 3.2.8)
8
8
  devise (~> 3.0.2)
9
9
  jquery-rails (~> 3.0.4)
10
- killbill-client (~> 0.8.1)
10
+ killbill-client (~> 0.10.1)
11
11
  money-rails (~> 0.8.1)
12
12
  rails (~> 3.2.14)
13
+ symmetric-encryption (~> 3.6.0)
14
+ twitter-bootstrap-rails (~> 2.2.8)
13
15
 
14
16
  GEM
15
17
  remote: http://rubygems.org/
16
18
  specs:
17
- actionmailer (3.2.19)
18
- actionpack (= 3.2.19)
19
+ actionmailer (3.2.21)
20
+ actionpack (= 3.2.21)
19
21
  mail (~> 2.5.4)
20
- actionpack (3.2.19)
21
- activemodel (= 3.2.19)
22
- activesupport (= 3.2.19)
22
+ actionpack (3.2.21)
23
+ activemodel (= 3.2.21)
24
+ activesupport (= 3.2.21)
23
25
  builder (~> 3.0.0)
24
26
  erubis (~> 2.7.0)
25
27
  journey (~> 1.0.4)
@@ -27,24 +29,27 @@ GEM
27
29
  rack-cache (~> 1.2)
28
30
  rack-test (~> 0.6.1)
29
31
  sprockets (~> 2.2.1)
30
- activemodel (3.2.19)
31
- activesupport (= 3.2.19)
32
+ activemodel (3.2.21)
33
+ activesupport (= 3.2.21)
32
34
  builder (~> 3.0.0)
33
- activerecord (3.2.19)
34
- activemodel (= 3.2.19)
35
- activesupport (= 3.2.19)
35
+ activerecord (3.2.21)
36
+ activemodel (= 3.2.21)
37
+ activesupport (= 3.2.21)
36
38
  arel (~> 3.0.2)
37
39
  tzinfo (~> 0.3.29)
38
- activeresource (3.2.19)
39
- activemodel (= 3.2.19)
40
- activesupport (= 3.2.19)
41
- activesupport (3.2.19)
40
+ activeresource (3.2.21)
41
+ activemodel (= 3.2.21)
42
+ activesupport (= 3.2.21)
43
+ activesupport (3.2.21)
42
44
  i18n (~> 0.6, >= 0.6.4)
43
45
  multi_json (~> 1.0)
44
46
  arel (3.0.3)
45
- bcrypt (3.1.7)
47
+ bcrypt (3.1.10)
48
+ bcrypt (3.1.10-java)
46
49
  bcrypt-ruby (3.1.5)
47
50
  bcrypt (>= 3.1.3)
51
+ bcrypt-ruby (3.1.5-java)
52
+ bcrypt (>= 3.1.3)
48
53
  builder (3.0.4)
49
54
  cancan (1.6.10)
50
55
  carmen (1.0.1)
@@ -52,8 +57,12 @@ GEM
52
57
  carmen-rails (1.0.1)
53
58
  carmen (~> 1.0.0)
54
59
  rails
60
+ coercible (1.0.0)
61
+ descendants_tracker (~> 0.0.1)
55
62
  d3_rails (3.2.8)
56
63
  railties (>= 3.1.0)
64
+ descendants_tracker (0.0.4)
65
+ thread_safe (~> 0.3, >= 0.3.1)
57
66
  devise (3.0.4)
58
67
  bcrypt-ruby (~> 3.0)
59
68
  orm_adapter (~> 0.1)
@@ -61,6 +70,7 @@ GEM
61
70
  warden (~> 1.2.3)
62
71
  docile (1.1.5)
63
72
  erubis (2.7.0)
73
+ execjs (2.3.0)
64
74
  fakeweb (1.3.0)
65
75
  hike (1.2.3)
66
76
  i18n (0.6.11)
@@ -68,8 +78,9 @@ GEM
68
78
  jquery-rails (3.0.4)
69
79
  railties (>= 3.0, < 5.0)
70
80
  thor (>= 0.14, < 2.0)
71
- json (1.8.1)
72
- killbill-client (0.8.1)
81
+ json (1.8.2)
82
+ json (1.8.2-java)
83
+ killbill-client (0.10.3)
73
84
  json (>= 1.2.0)
74
85
  mail (2.5.4)
75
86
  mime-types (~> 1.16)
@@ -81,8 +92,8 @@ GEM
81
92
  activesupport (>= 3.0)
82
93
  money (~> 5.1.0)
83
94
  railties (>= 3.0)
84
- multi_json (1.9.2)
85
- mysql2 (0.3.13)
95
+ multi_json (1.10.1)
96
+ mysql2 (0.3.17)
86
97
  orm_adapter (0.5.0)
87
98
  polyglot (0.3.5)
88
99
  rack (1.4.5)
@@ -90,48 +101,58 @@ GEM
90
101
  rack (>= 0.4)
91
102
  rack-ssl (1.3.4)
92
103
  rack
93
- rack-test (0.6.2)
104
+ rack-test (0.6.3)
94
105
  rack (>= 1.0)
95
- rails (3.2.19)
96
- actionmailer (= 3.2.19)
97
- actionpack (= 3.2.19)
98
- activerecord (= 3.2.19)
99
- activeresource (= 3.2.19)
100
- activesupport (= 3.2.19)
106
+ rails (3.2.21)
107
+ actionmailer (= 3.2.21)
108
+ actionpack (= 3.2.21)
109
+ activerecord (= 3.2.21)
110
+ activeresource (= 3.2.21)
111
+ activesupport (= 3.2.21)
101
112
  bundler (~> 1.0)
102
- railties (= 3.2.19)
103
- railties (3.2.19)
104
- actionpack (= 3.2.19)
105
- activesupport (= 3.2.19)
113
+ railties (= 3.2.21)
114
+ railties (3.2.21)
115
+ actionpack (= 3.2.21)
116
+ activesupport (= 3.2.21)
106
117
  rack-ssl (~> 1.3.2)
107
118
  rake (>= 0.8.7)
108
119
  rdoc (~> 3.4)
109
120
  thor (>= 0.14.6, < 2.0)
110
- rake (10.1.1)
121
+ rake (10.4.2)
111
122
  rdoc (3.12.2)
112
123
  json (~> 1.4)
113
- simplecov (0.9.0)
124
+ simplecov (0.9.1)
114
125
  docile (~> 1.1.0)
115
- multi_json
126
+ multi_json (~> 1.0)
116
127
  simplecov-html (~> 0.8.0)
117
128
  simplecov-html (0.8.0)
118
- sprockets (2.2.2)
129
+ sprockets (2.2.3)
119
130
  hike (~> 1.2)
120
131
  multi_json (~> 1.0)
121
132
  rack (~> 1.0)
122
133
  tilt (~> 1.1, != 1.3.0)
123
- sqlite3 (1.3.8)
134
+ sqlite3 (1.3.10)
135
+ symmetric-encryption (3.6.0)
136
+ coercible (>= 1.0.0)
124
137
  thor (0.19.1)
138
+ thread_safe (0.3.4)
139
+ thread_safe (0.3.4-java)
125
140
  tilt (1.4.1)
126
141
  treetop (1.4.15)
127
142
  polyglot
128
143
  polyglot (>= 0.3.1)
129
- tzinfo (0.3.41)
144
+ twitter-bootstrap-rails (2.2.8)
145
+ actionpack (>= 3.1)
146
+ execjs
147
+ rails (>= 3.1)
148
+ railties (>= 3.1)
149
+ tzinfo (0.3.43)
130
150
  unicode_utils (1.4.0)
131
151
  warden (1.2.3)
132
152
  rack (>= 1.0)
133
153
 
134
154
  PLATFORMS
155
+ java
135
156
  ruby
136
157
 
137
158
  DEPENDENCIES
data/README.md CHANGED
@@ -4,16 +4,19 @@
4
4
  Getting started
5
5
  ===============
6
6
 
7
- Running Kaui
8
- ------------
7
+ Running Kaui locally
8
+ ---------------------
9
9
 
10
- You can run Kaui locally by using the sandbox script:
11
-
12
- # Run the sandbox script
13
- bundle exec script/sandbox
14
- # Start the Rails app
15
- cd sandbox
16
- rails s
10
+ You can run Kaui locally by using the test/dummy app provided:
11
+ ```
12
+ > bundle install
13
+ > cd test/dummy
14
+ > export RAILS_ENV=development
15
+ > bundle install
16
+ > rake kaui:install:migrations
17
+ > rake db:migrate
18
+ > rails server
19
+ ```
17
20
 
18
21
 
19
22
  Mounting Kaui into your own Rails app
data/Rakefile CHANGED
@@ -19,5 +19,14 @@ Rake::TestTask.new(:test) do |t|
19
19
  t.verbose = false
20
20
  end
21
21
 
22
+ namespace :test do
23
+ desc 'Runs all the unit tests'
24
+ Rake::TestTask.new(:units) do |t|
25
+ t.libs << 'lib'
26
+ t.libs << 'test'
27
+ t.pattern = 'test/unit/**/*_test.rb'
28
+ t.verbose = false
29
+ end
30
+ end
22
31
 
23
32
  task :default => :test
@@ -7,10 +7,7 @@
7
7
  //= require jquery
8
8
  //= require jquery_ujs
9
9
  //= require d3
10
- //= require js/bootstrap.v2.2.1.min
11
- //= require js/bootstrap-datepicker.cd46d38
12
- //= require js/jquery.dataTables.v1.9.3.min
10
+ //= require twitter/bootstrap
11
+ //= require jquery.dataTables.min
13
12
  //= require kaui/bootstrap-tweaks
14
13
  //= require kaui/validation
15
- //= require kaui/analytics
16
- //= require_tree .
@@ -2,10 +2,6 @@
2
2
  * This is a manifest file that'll automatically include all the stylesheets available in this directory
3
3
  * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
4
4
  * the top of the compiled file, but it's generally better to create a new file per style scope.
5
- *
6
- *= require css/bootstrap.v2.2.1.min
7
- *= require css/bootstrap-datepicker.cd46d38
8
- *= require kaui/analytics
9
5
  *= require_self
10
6
  *= require_tree .
11
7
  */
@@ -0,0 +1,7 @@
1
+ /*
2
+ =require twitter-bootstrap-static/bootstrap
3
+
4
+ Use Font Awesome icons (default)
5
+ To use Glyphicons sprites instead of Font Awesome, replace with "require twitter-bootstrap-static/sprites"
6
+ =require twitter-bootstrap-static/fontawesome
7
+ */
@@ -0,0 +1,48 @@
1
+ module Kaui
2
+ class AdminAllowedUsersController < Kaui::EngineController
3
+
4
+ skip_before_filter :check_for_redirect_to_tenant_screen
5
+
6
+ def index
7
+ @allowed_users = Kaui::AllowedUser.all
8
+ end
9
+
10
+ def new
11
+ @allowed_user = Kaui::AllowedUser.new
12
+ end
13
+
14
+ def create
15
+
16
+ param_allowed_user = params[:allowed_user]
17
+ existing_user = Kaui::AllowedUser.find_by_kb_username(param_allowed_user[:kb_username])
18
+ if existing_user
19
+ flash[:error] = "Allowed User with name #{param_allowed_user[:kb_username]} already exists!"
20
+ redirect_to admin_allowed_users_path and return
21
+ end
22
+
23
+ new_user = Kaui::AllowedUser.new
24
+ new_user.kb_username = param_allowed_user[:kb_username]
25
+ new_user.description = param_allowed_user[:description]
26
+ new_user.save!
27
+
28
+ redirect_to admin_allowed_user_path(new_user[:id]), :notice => 'Allowed User was successfully configured'
29
+ end
30
+
31
+ def show
32
+ @allowed_user = Kaui::AllowedUser.find(params[:id])
33
+ @tenants = Kaui::Tenant.all
34
+ render
35
+ end
36
+
37
+ def add_tenant
38
+
39
+ allowed_user_id = params[:allowed_user][:id]
40
+ allowed_user = Kaui::AllowedUser.find(allowed_user_id)
41
+ tenant = Kaui::Tenant.find_by_id(params[:tenant_id])
42
+ # Add new tenant for that user
43
+ allowed_user.kaui_tenants << tenant
44
+
45
+ redirect_to admin_allowed_user_path(allowed_user_id), :notice => 'Successfully added tenant'
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,97 @@
1
+ module Kaui
2
+ class AdminTenantsController < Kaui::EngineController
3
+
4
+ skip_before_filter :check_for_redirect_to_tenant_screen
5
+
6
+ def index
7
+ # Display the configured tenants in KAUI (which could be different than the existing tenants known by Kill Bill)
8
+ @tenants = Kaui::Tenant.all
9
+ render
10
+ end
11
+
12
+ def new
13
+ @tenant = Kaui::Tenant.new
14
+ end
15
+
16
+ def create
17
+ param_tenant = params[:tenant]
18
+ old_tenant = Kaui::Tenant.find_by_name(param_tenant[:name])
19
+ if old_tenant
20
+ flash[:error] = "Tenant with name #{param_tenant[:name]} already exists!"
21
+ redirect_to admin_tenants_path and return
22
+ end
23
+
24
+ begin
25
+ # Create the tenant in Kill Bill
26
+ new_tenant = Kaui::AdminTenant.new
27
+ new_tenant.external_key = param_tenant[:name]
28
+ new_tenant.api_key = param_tenant[:api_key]
29
+ new_tenant.api_secret = param_tenant[:api_secret]
30
+
31
+ options = tenant_options_for_client
32
+ new_tenant = new_tenant.create(options[:username], nil, comment, options)
33
+
34
+ # Transform object to Kaui model
35
+ tenant_model = Kaui::Tenant.new
36
+ tenant_model.name = new_tenant.external_key
37
+ tenant_model.kb_tenant_id = new_tenant.tenant_id
38
+ tenant_model.api_key = new_tenant.api_key
39
+ tenant_model.api_secret = param_tenant[:api_secret]
40
+
41
+ # Save in KAUI tables
42
+ tenant_model.save!
43
+ rescue => e
44
+ flash[:error] = "Failed to create the tenant : #{as_string(e)}"
45
+ redirect_to admin_tenants_path and return
46
+ end
47
+
48
+ redirect_to admin_tenant_path(tenant_model[:id]), :notice => 'Tenant was successfully configured'
49
+ end
50
+
51
+ def show
52
+ @tenant = Kaui::Tenant.find(params[:id])
53
+ render
54
+ end
55
+
56
+ def upload_catalog
57
+
58
+ current_tenant = Kaui::Tenant.find_by_id(params[:id])
59
+
60
+ options = tenant_options_for_client
61
+ options[:api_key] = current_tenant.api_key
62
+ options[:api_secret] = current_tenant.api_secret
63
+
64
+ uploaded_catalog = params[:catalog]
65
+ catalog_xml = uploaded_catalog.read
66
+
67
+ Kaui::AdminTenant.upload_catalog(catalog_xml, options[:username], nil, comment, options)
68
+
69
+ redirect_to admin_tenants_path, :notice => 'Catalog was successfully uploaded'
70
+ end
71
+
72
+
73
+ def remove_allowed_user
74
+
75
+ current_tenant = Kaui::Tenant.find_by_id(params[:id])
76
+ au = Kaui::AllowedUser.find(params[:allowed_user][:id])
77
+ # remove the association
78
+ au.kaui_tenants.delete current_tenant
79
+ render :json => '{}', :status => 200
80
+ end
81
+
82
+ private
83
+
84
+ def tenant_options_for_client
85
+ user = current_user
86
+ {
87
+ :username => user.kb_username,
88
+ :password => user.password,
89
+ :session_id => user.kb_session_id
90
+ }
91
+ end
92
+
93
+ def comment
94
+ 'Multi-tenant Administrative operation'
95
+ end
96
+ end
97
+ end