Skip to content

Commit

Permalink
Merge pull request #1666 from phong-nguyen-duy/my-master
Browse files Browse the repository at this point in the history
Bump bricks version to 3.7.19

Reviewed-by: https://github.com/danh-ung
  • Loading branch information
gdgate authored Jun 5, 2020
2 parents fe31b4b + 08429de commit 13cfc72
Show file tree
Hide file tree
Showing 18 changed files with 11,626 additions and 1,418 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.7.18
3.7.19
3 changes: 3 additions & 0 deletions bin/run_brick.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
BRICK_PARAM_PREFIX = 'BRICK_PARAM_'
HIDDEN_BRICK_PARAMS_PREFIX = 'HIDDEN_BRICK_PARAM_'

# MSF-17345 Set umask so files are group-writable
File.umask(0002)

brick_type = !ARGV.empty? ? ARGV[0] : DEFAULT_BRICK

def get_brick_params(prefix)
Expand Down
8 changes: 6 additions & 2 deletions bin/test_projects_cleanup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@ def clean_up!(client, force, days)
delete_project_by_title(/LCM spec Client With Conflicting LDM Changes/, projects, days, force)
delete_project_by_title(/LCM spec master project/, projects, days, force)
delete_project_by_title(/users brick load test/, projects, days, force)
delete_project_by_title(/#transfer_processes and #transfer_schedules test/, projects, days, force)
delete_project_by_title(/transfer_processes and #transfer_schedules test/, projects, days, force)
delete_project_by_title(/DailyUse Project for gooddata-ruby integration tests/, projects, days, force)
delete_project_by_title(/^New project$/, projects, days, force)
delete_project_by_title(/RubyGem Dev Week test/, projects, days, force)
delete_project_by_title(/My project from blueprint/, projects, days, force)
delete_ads_by_title(/Development ADS/, client, days, force)
delete_ads_by_title(/Production ADS/, client, days, force)
delete_ads_by_title(/TEST ADS/, client, days, force)
Expand All @@ -112,7 +116,7 @@ def init_client(username, password, server)
prod_client = init_client(username, password, "https://#{config[:prod_server]}")

force = options[:force]
days = options[:days] || 14
days = options[:days] || 3
clean_up!(dev_client, force, days)
clean_up!(prod_client, force, days)

Expand Down
7 changes: 7 additions & 0 deletions lib/gooddata/lcm/actions/synchronize_ldm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ def sync_segment_ldm(params, segment_info)
maql_diff_params << :excludeFactRule if exclude_fact_rule
maql_diff_params << :includeDeprecated if include_deprecated
maql_diff = previous_master.maql_diff(blueprint: blueprint, params: maql_diff_params)
chunks = maql_diff['projectModelDiff']['updateScripts']
if chunks.empty?
GoodData.logger.info "Synchronize LDM to clients will not proceed in mode \
'#{params[:synchronize_ldm].downcase}' due to no LDM changes in the new master project. \
If you had changed LDM of clients manually, please use mode 'diff_against_clients' \
to force synchronize LDM to clients"
end
end

segment_info[:to] = segment_info[:to].pmap do |entry|
Expand Down
2 changes: 1 addition & 1 deletion lib/gooddata/models/domain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def users(domain, id = :all, opts = {})

all_users
else
find_user_by_login(domain, id)
find_user_by_login(domain, id, opts)
end
end

Expand Down
30 changes: 24 additions & 6 deletions lib/gooddata/models/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1606,14 +1606,19 @@ def whitelist_users(new_users, users_list, whitelist, mode = :exclude)
def import_users(new_users, options = {})
role_list = roles
users_list = users
new_users = new_users.map { |x| ((x.is_a?(Hash) && x[:user] && x[:user].to_hash.merge(role: x[:role])) || x.to_hash).tap { |u| u[:login].downcase! } }

GoodData.logger.warn("Importing users to project (#{pid})")
new_users = new_users.map { |x| ((x.is_a?(Hash) && x[:user] && x[:user].to_hash.merge(role: x[:role])) || x.to_hash).tap { |u| u[:login].downcase! } }
# First check that if groups are provided we have them set up
user_groups_cache, change_groups = check_groups(new_users.map(&:to_hash).flat_map { |u| u[:user_group] || [] }.uniq, options[:user_groups_cache], options)

whitelisted_new_users, whitelisted_users = whitelist_users(new_users.map(&:to_hash), users_list, options[:whitelists])
unless change_groups.empty?
new_users.each do |user|
user[:user_group].map! { |e| change_groups[e].nil? ? e : change_groups[e] }
end
end

# First check that if groups are provided we have them set up
user_groups_cache = check_groups(new_users.map(&:to_hash).flat_map { |u| u[:user_group] || [] }.uniq, options[:user_groups_cache], options)
whitelisted_new_users, whitelisted_users = whitelist_users(new_users.map(&:to_hash), users_list, options[:whitelists])

# conform the role on list of new users so we can diff them with the users coming from the project
diffable_new_with_default_role = whitelisted_new_users.map do |u|
Expand Down Expand Up @@ -1760,7 +1765,20 @@ def remove_users(list)
def check_groups(specified_groups, user_groups_cache = nil, options = {})
current_user_groups = user_groups if user_groups_cache.nil? || user_groups_cache.empty?
groups = current_user_groups.map(&:name)
missing_groups = specified_groups - groups
missing_groups = []
change_groups = {}
specified_groups.each do |group|
found_group = groups.find { |name| name.casecmp(group).zero? }
if found_group.nil?
missing_groups << group
else
# Change groups when they have similar group name with difference of case sensitivity
if found_group != group
change_groups[group] = found_group
GoodData.logger.warn("Group with name #{group} is existed in project with name #{found_group}.")
end
end
end
if options[:create_non_existing_user_groups]
missing_groups.each do |g|
GoodData.logger.info("Creating group #{g}")
Expand All @@ -1773,7 +1791,7 @@ def check_groups(specified_groups, user_groups_cache = nil, options = {})
"#{groups.join(',')} and you asked for #{missing_groups.join(',')}"
end
end
current_user_groups
[current_user_groups, change_groups]
end

# Update user
Expand Down
46 changes: 35 additions & 11 deletions spec/integration/models/domain_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,6 @@
end
end

describe '#find_user_by_login' do
it 'Should find user by login' do
domain = @client.domain(ConnectionHelper::DEFAULT_DOMAIN)
user = domain.find_user_by_login(ConnectionHelper::DEFAULT_USERNAME)

expect(user).to be_an_instance_of(GoodData::Profile)
expect(user.login).to eq ConnectionHelper::DEFAULT_USERNAME
end
end

describe '#users' do
it 'Should list users' do
users = @domain.users
Expand Down Expand Up @@ -119,7 +109,7 @@

it 'updates properties of a profile' do
user = @domain.users
.reject { |u| u.login == ConnectionHelper::DEFAULT_USERNAME }.first
.reject { |u| u.login == ConnectionHelper::DEFAULT_USERNAME }.first

old_email = user.email
old_sso_provider = user.sso_provider || ''
Expand All @@ -138,6 +128,40 @@
end
end

describe '#find_user_by_login' do
it 'Should find user by login' do
domain = @client.domain(ConnectionHelper::DEFAULT_DOMAIN)
user = domain.find_user_by_login(ConnectionHelper::DEFAULT_USERNAME)

expect(user).to be_an_instance_of(GoodData::Profile)
expect(user.login).to eq ConnectionHelper::DEFAULT_USERNAME
end

it 'Should find user by users with same result' do
domain = @client.domain(ConnectionHelper::DEFAULT_DOMAIN)
login = "[email protected]"
password = 'gemtest871382persistent'
user = domain.find_user_by_login(login)
user.delete if user
user = domain.add_user(:login => login, :password => password, :first_name => 'X', :last_name => 'X')
@users_to_delete << user
client_normal = GoodData.connect(login, password, :server => GoodData::Environment::ConnectionHelper::DEFAULT_SERVER, :verify_ssl => OpenSSL::SSL::VERIFY_NONE)
begin
client_normal.domain(ConnectionHelper::DEFAULT_DOMAIN).find_user_by_login(login)
raise 'Must be domain admin'
rescue RestClient::Forbidden => e
expect(e.message).to include('Can be accessed only by domain admin')
end
user = domain.find_user_by_login(login)
expect(user).to be_an_instance_of(GoodData::Profile)
expect(user.login).to eq login
user = domain.users(login)
expect(user).to be_an_instance_of(GoodData::Profile)
expect(user.login).to eq login
client_normal.disconnect
end
end

describe '#clients' do
subject { GoodData::Domain.new('my_domain') }
let(:client) { double('client') }
Expand Down
Loading

0 comments on commit 13cfc72

Please sign in to comment.