maestrano-connector-rails 2.0.2.pre.RC6 → 2.0.2.pre.RC7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +6 -0
- data/DEVELOPER.md +1 -4
- data/Gemfile +2 -32
- data/Rakefile +6 -30
- data/app/models/maestrano/connector/rails/concerns/entity.rb +12 -0
- data/app/models/maestrano/connector/rails/concerns/sub_entity_base.rb +3 -2
- data/app/models/maestrano/connector/rails/id_map.rb +1 -0
- data/app/models/maestrano/connector/rails/services/data_consolidator.rb +4 -4
- data/db/migrate/20170315032224_add_metadata_to_id_map.rb +5 -0
- data/lib/maestrano/connector/rails/version.rb +7 -0
- data/lib/maestrano_connector_rails/factories.rb +1 -0
- data/maestrano-connector-rails.gemspec +44 -308
- metadata +13 -151
- data/VERSION +0 -1
- data/spec/controllers/connec_controller_spec.rb +0 -179
- data/spec/controllers/dependancies_controller_spec.rb +0 -31
- data/spec/controllers/group_users_controller_spec.rb +0 -39
- data/spec/controllers/groups_controller_spec.rb +0 -36
- data/spec/controllers/synchronizations_controller_spec.rb +0 -211
- data/spec/controllers/version_controller_spec.rb +0 -17
- data/spec/dummy/README.md +0 -1
- data/spec/dummy/Rakefile +0 -6
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +0 -13
- data/spec/dummy/app/assets/stylesheets/application.css +0 -15
- data/spec/dummy/app/controllers/application_controller.rb +0 -8
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/helpers/application_helper.rb +0 -2
- data/spec/dummy/app/mailers/.keep +0 -0
- data/spec/dummy/app/models/.keep +0 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/models/entities/.keep +0 -0
- data/spec/dummy/app/views/home/index.html.erb +0 -1
- data/spec/dummy/app/views/layouts/application.html.erb +0 -14
- data/spec/dummy/bin/bundle +0 -3
- data/spec/dummy/bin/rails +0 -4
- data/spec/dummy/bin/rake +0 -4
- data/spec/dummy/bin/setup +0 -29
- data/spec/dummy/config.ru +0 -4
- data/spec/dummy/config/application.rb +0 -26
- data/spec/dummy/config/boot.rb +0 -5
- data/spec/dummy/config/database.yml +0 -25
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -41
- data/spec/dummy/config/environments/production.rb +0 -79
- data/spec/dummy/config/environments/test.rb +0 -39
- data/spec/dummy/config/initializers/assets.rb +0 -11
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/cookies_serializer.rb +0 -3
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/spec/dummy/config/initializers/inflections.rb +0 -16
- data/spec/dummy/config/initializers/maestrano.rb +0 -2
- data/spec/dummy/config/initializers/mime_types.rb +0 -4
- data/spec/dummy/config/initializers/session_store.rb +0 -3
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/spec/dummy/config/locales/en.yml +0 -23
- data/spec/dummy/config/routes.rb +0 -9
- data/spec/dummy/config/secrets.yml +0 -22
- data/spec/dummy/config/settings.yml +0 -2
- data/spec/dummy/config/settings/development.yml +0 -12
- data/spec/dummy/config/settings/production.yml +0 -1
- data/spec/dummy/config/settings/test.yml +0 -12
- data/spec/dummy/config/settings/uat.yml +0 -1
- data/spec/dummy/db/schema.rb +0 -102
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/public/404.html +0 -67
- data/spec/dummy/public/422.html +0 -67
- data/spec/dummy/public/500.html +0 -66
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/tmp/cache/.gitkeep +0 -0
- data/spec/integration/complex_id_references_spec.rb +0 -249
- data/spec/integration/complex_naming_spec.rb +0 -192
- data/spec/integration/complex_spec.rb +0 -578
- data/spec/integration/connec_to_external_spec.rb +0 -327
- data/spec/integration/external_to_connec_spec.rb +0 -159
- data/spec/integration/id_references_spec.rb +0 -584
- data/spec/integration/singleton_spec.rb +0 -297
- data/spec/jobs/all_synchronizations_job_spec.rb +0 -24
- data/spec/jobs/push_to_connec_job_spec.rb +0 -111
- data/spec/jobs/push_to_connec_worker_spec.rb +0 -37
- data/spec/jobs/synchronization_job_spec.rb +0 -216
- data/spec/models/complex_entity_spec.rb +0 -407
- data/spec/models/connec_helper_spec.rb +0 -588
- data/spec/models/connector_logger_spec.rb +0 -26
- data/spec/models/entity_base_spec.rb +0 -20
- data/spec/models/entity_spec.rb +0 -1078
- data/spec/models/external_spec.rb +0 -27
- data/spec/models/id_map_spec.rb +0 -12
- data/spec/models/organization_spec.rb +0 -243
- data/spec/models/sub_entity_base_spec.rb +0 -155
- data/spec/models/synchronization_spec.rb +0 -106
- data/spec/models/user_organization_rel_spec.rb +0 -14
- data/spec/models/user_spec.rb +0 -15
- data/spec/routing/connec_routing_spec.rb +0 -12
- data/spec/spec_helper.rb +0 -34
- data/template/Procfile +0 -2
- data/template/application-sample.yml +0 -13
- data/template/database.yml +0 -31
- data/template/gitignore +0 -23
- data/template/maestrano.rb +0 -2
- data/template/maestrano_connector_template.rb +0 -135
- data/template/routes.rb +0 -25
- data/template/rubocop.yml +0 -55
- data/template/settings/development.yml +0 -0
- data/template/settings/production.yml +0 -0
- data/template/settings/settings.yml +0 -2
- data/template/settings/test.yml +0 -0
- data/template/settings/uat.yml +0 -0
- data/template/sidekiq.rb +0 -9
- data/template/sidekiq.yml +0 -4
- data/template/spec_helper.rb +0 -24
@@ -1,39 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Maestrano::Account::GroupUsersController, type: :controller do
|
4
|
-
routes { Maestrano::Connector::Rails::Engine.routes }
|
5
|
-
|
6
|
-
describe "destroy" do
|
7
|
-
let!(:organization) { create(:organization, uid: 'cld-abc', tenant: 'abc') }
|
8
|
-
let!(:user) { create(:user, tenant: 'abc', uid: 'usr-nnc') }
|
9
|
-
let(:params) { {tenant: organization.tenant, group_id: organization.uid, id: user.uid} }
|
10
|
-
subject { delete :destroy, params }
|
11
|
-
|
12
|
-
before {
|
13
|
-
controller.class.skip_before_filter :authenticate_maestrano!
|
14
|
-
organization.add_member(user)
|
15
|
-
}
|
16
|
-
|
17
|
-
it 'is successful' do
|
18
|
-
subject
|
19
|
-
expect(response).to be_success
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'destroys the user_organization_rels' do
|
23
|
-
expect{ subject }.to change{ Maestrano::Connector::Rails::UserOrganizationRel.count }.by(-1)
|
24
|
-
end
|
25
|
-
|
26
|
-
context 'with default tenant' do
|
27
|
-
before {
|
28
|
-
organization.update(tenant: 'default')
|
29
|
-
user.update(tenant: 'default')
|
30
|
-
}
|
31
|
-
let(:params) { {group_id: organization.uid, id: user.uid} }
|
32
|
-
|
33
|
-
it 'destroys the organization' do
|
34
|
-
expect{ subject }.to change{ Maestrano::Connector::Rails::UserOrganizationRel.count }.by(-1)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Maestrano::Account::GroupsController, type: :controller do
|
4
|
-
routes { Maestrano::Connector::Rails::Engine.routes }
|
5
|
-
|
6
|
-
describe "destroy" do
|
7
|
-
let!(:organization) { create(:organization, uid: 'cld-abc', tenant: 'abc') }
|
8
|
-
let(:params) { {tenant: organization.tenant, id: organization.uid} }
|
9
|
-
subject { delete :destroy, params }
|
10
|
-
|
11
|
-
before {
|
12
|
-
controller.class.skip_before_filter :authenticate_maestrano!
|
13
|
-
}
|
14
|
-
|
15
|
-
it 'is successful' do
|
16
|
-
subject
|
17
|
-
expect(response).to be_success
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'destroys the organization' do
|
21
|
-
expect{ subject }.to change{ Maestrano::Connector::Rails::Organization.count }.by(-1)
|
22
|
-
end
|
23
|
-
|
24
|
-
context 'with default tenant' do
|
25
|
-
before {
|
26
|
-
organization.update(tenant: 'default')
|
27
|
-
}
|
28
|
-
let(:params) { {id: organization.uid} }
|
29
|
-
|
30
|
-
it 'destroys the organization' do
|
31
|
-
expect{ subject }.to change{ Maestrano::Connector::Rails::Organization.count }.by(-1)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
@@ -1,211 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Maestrano::SynchronizationsController, type: :controller do
|
4
|
-
|
5
|
-
routes { Maestrano::Connector::Rails::Engine.routes }
|
6
|
-
|
7
|
-
let(:uid) { 'cld-aaaa' }
|
8
|
-
let(:tenant) { 'default' }
|
9
|
-
|
10
|
-
describe 'show' do
|
11
|
-
subject { get :show, id: uid, tenant: tenant }
|
12
|
-
|
13
|
-
|
14
|
-
context 'without authentication' do
|
15
|
-
before {
|
16
|
-
controller.class.before_filter :authenticate_maestrano!
|
17
|
-
}
|
18
|
-
|
19
|
-
it 'respond with unauthorized' do
|
20
|
-
subject
|
21
|
-
expect(response.status).to eq(401)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
context 'with authentication' do
|
26
|
-
before {
|
27
|
-
controller.class.skip_before_filter :authenticate_maestrano!
|
28
|
-
}
|
29
|
-
|
30
|
-
context 'when organization is not found' do
|
31
|
-
context 'bad uid' do
|
32
|
-
let!(:organization) { create(:organization, uid: 'cld-bbbb') }
|
33
|
-
|
34
|
-
it 'is a 404' do
|
35
|
-
subject
|
36
|
-
expect(response.status).to eq(404)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
context 'bad tenant' do
|
41
|
-
let!(:organization) { create(:organization, uid: uid, tenant: 'another_tenant') }
|
42
|
-
|
43
|
-
it 'is a 404' do
|
44
|
-
subject
|
45
|
-
expect(response.status).to eq(404)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
context 'when organization is found' do
|
51
|
-
let!(:organization) { create(:organization, uid: uid) }
|
52
|
-
|
53
|
-
it 'is a success' do
|
54
|
-
subject
|
55
|
-
expect(response.status).to eq(200)
|
56
|
-
end
|
57
|
-
|
58
|
-
context 'with no last sync' do
|
59
|
-
it 'renders a partial json' do
|
60
|
-
subject
|
61
|
-
expect(JSON.parse(response.body)).to eql(
|
62
|
-
JSON.parse({
|
63
|
-
group_id: organization.uid,
|
64
|
-
sync_enabled: organization.sync_enabled,
|
65
|
-
status: 'DISABLED'
|
66
|
-
}.to_json)
|
67
|
-
)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
context 'with a last sync' do
|
72
|
-
let!(:sync1) { create(:synchronization, organization: organization) }
|
73
|
-
let!(:sync2) { create(:synchronization, organization: organization, message: 'msg') }
|
74
|
-
|
75
|
-
it 'renders a full json' do
|
76
|
-
subject
|
77
|
-
expect(JSON.parse(response.body)).to eql(
|
78
|
-
JSON.parse({
|
79
|
-
group_id: organization.uid,
|
80
|
-
sync_enabled: organization.sync_enabled,
|
81
|
-
status: sync2.status,
|
82
|
-
message: sync2.message,
|
83
|
-
updated_at: sync2.updated_at
|
84
|
-
}.to_json)
|
85
|
-
)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
describe 'create' do
|
93
|
-
let(:opts) { {'only_entities' => ['customer']} }
|
94
|
-
subject { post :create, group_id: uid, opts: opts, tenant: tenant }
|
95
|
-
|
96
|
-
|
97
|
-
context 'without authentication' do
|
98
|
-
before {
|
99
|
-
controller.class.before_filter :authenticate_maestrano!
|
100
|
-
}
|
101
|
-
|
102
|
-
it 'respond with unauthorized' do
|
103
|
-
subject
|
104
|
-
expect(response.status).to eq(401)
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
context 'with authentication' do
|
109
|
-
before {
|
110
|
-
controller.class.skip_before_filter :authenticate_maestrano!
|
111
|
-
}
|
112
|
-
|
113
|
-
context 'when organization is not found' do
|
114
|
-
let!(:organization) { create(:organization, uid: 'cld-bbbb') }
|
115
|
-
|
116
|
-
it 'is a 404' do
|
117
|
-
subject
|
118
|
-
expect(response.status).to eq(404)
|
119
|
-
end
|
120
|
-
|
121
|
-
context 'bad tenant' do
|
122
|
-
let!(:organization) { create(:organization, uid: uid, tenant: 'another_tenant') }
|
123
|
-
|
124
|
-
it 'is a 404' do
|
125
|
-
subject
|
126
|
-
expect(response.status).to eq(404)
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
context 'when organization is found' do
|
132
|
-
let!(:organization) { create(:organization, uid: uid) }
|
133
|
-
|
134
|
-
it 'is a success' do
|
135
|
-
subject
|
136
|
-
expect(response.status).to eq(201)
|
137
|
-
end
|
138
|
-
|
139
|
-
it 'queues a sync' do
|
140
|
-
expect(Maestrano::Connector::Rails::SynchronizationJob).to receive(:perform_later).with(organization.id, opts)
|
141
|
-
subject
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
describe 'toggle_sync' do
|
148
|
-
subject { put :toggle_sync, group_id: uid, tenant: tenant }
|
149
|
-
|
150
|
-
|
151
|
-
context 'without authentication' do
|
152
|
-
before {
|
153
|
-
controller.class.before_filter :authenticate_maestrano!
|
154
|
-
}
|
155
|
-
|
156
|
-
it 'respond with unauthorized' do
|
157
|
-
subject
|
158
|
-
expect(response.status).to eq(401)
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
context 'with authentication' do
|
163
|
-
before {
|
164
|
-
controller.class.skip_before_filter :authenticate_maestrano!
|
165
|
-
}
|
166
|
-
|
167
|
-
context 'when organization is not found' do
|
168
|
-
let!(:organization) { create(:organization, uid: 'cld-bbbb') }
|
169
|
-
|
170
|
-
it 'is a 404' do
|
171
|
-
subject
|
172
|
-
expect(response.status).to eq(404)
|
173
|
-
end
|
174
|
-
|
175
|
-
context 'bad tenant' do
|
176
|
-
let!(:organization) { create(:organization, uid: uid, tenant: 'another_tenant') }
|
177
|
-
|
178
|
-
it 'is a 404' do
|
179
|
-
subject
|
180
|
-
expect(response.status).to eq(404)
|
181
|
-
end
|
182
|
-
end
|
183
|
-
end
|
184
|
-
|
185
|
-
context 'when organization is found' do
|
186
|
-
let!(:organization) { create(:organization, uid: uid) }
|
187
|
-
|
188
|
-
it 'is a success' do
|
189
|
-
subject
|
190
|
-
expect(response.status).to eq(200)
|
191
|
-
end
|
192
|
-
|
193
|
-
context 'when sync_enabled is true' do
|
194
|
-
before { organization.update(sync_enabled: true) }
|
195
|
-
it 'disables the organizatio syncs' do
|
196
|
-
subject
|
197
|
-
expect(organization.reload.sync_enabled).to be false
|
198
|
-
end
|
199
|
-
end
|
200
|
-
|
201
|
-
context 'when sync_enabled is false' do
|
202
|
-
before { organization.update(sync_enabled: false) }
|
203
|
-
it 'enables the organizatio syncs' do
|
204
|
-
subject
|
205
|
-
expect(organization.reload.sync_enabled).to be true
|
206
|
-
end
|
207
|
-
end
|
208
|
-
end
|
209
|
-
end
|
210
|
-
end
|
211
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe VersionController, type: :controller do
|
4
|
-
routes { Maestrano::Connector::Rails::Engine.routes }
|
5
|
-
|
6
|
-
describe 'index' do
|
7
|
-
subject { get :index, format: :json }
|
8
|
-
before {
|
9
|
-
allow(Gem).to receive(:loaded_specs).and_return({'maestrano-connector-rails' => Gem::Specification.new('maestrano-connector-rails', '1.2')})
|
10
|
-
}
|
11
|
-
|
12
|
-
it 'returns a version hash' do
|
13
|
-
subject
|
14
|
-
expect(JSON.parse(response.body)).to eql('framework_version'=>'1.2', 'ci_branch' => nil, 'ci_commit' => nil, 'env' => 'test', 'ruby_version' => RUBY_VERSION, 'ruby_engine' => RUBY_ENGINE)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
data/spec/dummy/README.md
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
Dummy application for testing purpose
|
data/spec/dummy/Rakefile
DELETED
File without changes
|
@@ -1,13 +0,0 @@
|
|
1
|
-
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
-
// listed below.
|
3
|
-
//
|
4
|
-
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
-
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
-
//
|
7
|
-
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
-
// compiled file.
|
9
|
-
//
|
10
|
-
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
-
// about supported directives.
|
12
|
-
//
|
13
|
-
//= require_tree .
|
@@ -1,15 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
-
* listed below.
|
4
|
-
*
|
5
|
-
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
-
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
-
*
|
8
|
-
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
-
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
-
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
-
* file per style scope.
|
12
|
-
*
|
13
|
-
*= require_tree .
|
14
|
-
*= require_self
|
15
|
-
*/
|
@@ -1,8 +0,0 @@
|
|
1
|
-
class ApplicationController < ActionController::Base
|
2
|
-
helper Maestrano::Connector::Rails::Engine.helpers
|
3
|
-
include Maestrano::Connector::Rails::SessionHelper
|
4
|
-
|
5
|
-
# Prevent CSRF attacks by raising an exception.
|
6
|
-
# For APIs, you may want to use :null_session instead.
|
7
|
-
protect_from_forgery with: :exception
|
8
|
-
end
|
File without changes
|
File without changes
|
data/spec/dummy/app/models/.keep
DELETED
File without changes
|
File without changes
|
File without changes
|
@@ -1 +0,0 @@
|
|
1
|
-
<!-- TODO -->
|
@@ -1,14 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>Dummy</title>
|
5
|
-
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
|
6
|
-
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
|
7
|
-
<%= csrf_meta_tags %>
|
8
|
-
</head>
|
9
|
-
<body>
|
10
|
-
|
11
|
-
<%= yield %>
|
12
|
-
|
13
|
-
</body>
|
14
|
-
</html>
|
data/spec/dummy/bin/bundle
DELETED
data/spec/dummy/bin/rails
DELETED
data/spec/dummy/bin/rake
DELETED
data/spec/dummy/bin/setup
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require 'pathname'
|
3
|
-
|
4
|
-
# path to your application root.
|
5
|
-
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
6
|
-
|
7
|
-
Dir.chdir APP_ROOT do
|
8
|
-
# This script is a starting point to setup your application.
|
9
|
-
# Add necessary setup steps to this file:
|
10
|
-
|
11
|
-
puts "== Installing dependencies =="
|
12
|
-
system "gem install bundler --conservative"
|
13
|
-
system "bundle check || bundle install"
|
14
|
-
|
15
|
-
# puts "\n== Copying sample files =="
|
16
|
-
# unless File.exist?("config/database.yml")
|
17
|
-
# system "cp config/database.yml.sample config/database.yml"
|
18
|
-
# end
|
19
|
-
|
20
|
-
puts "\n== Preparing database =="
|
21
|
-
system "bin/rake db:setup"
|
22
|
-
|
23
|
-
puts "\n== Removing old logs and tempfiles =="
|
24
|
-
system "rm -f log/*"
|
25
|
-
system "rm -rf tmp/cache"
|
26
|
-
|
27
|
-
puts "\n== Restarting application server =="
|
28
|
-
system "touch tmp/restart.txt"
|
29
|
-
end
|