Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1775361: Syspurpose attributes from AK should have priority over client attributes #2528

Merged
merged 1 commit into from
Dec 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
33 changes: 28 additions & 5 deletions server/spec/consumer_resource_activation_key_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,34 @@
expect(consumer['addOns']).to include('addon2')
end

it 'should override consumer syspurpose attributes with attributes on activation keys' do
prod1 = create_product(random_string('product1'), random_string('product1'))
create_pool_and_subscription(@owner['key'], prod1.id, 10)

key1 = @cp.create_activation_key(@owner['key'], 'key1', nil, nil, 'ak-usage', 'ak-role', ['ak-addon1','ak-addon2'])

consumer = @client.register(
random_string('machine1'), :system, nil, {}, nil, @owner['key'], ["key1"], nil, nil, nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, "client-sla", "client-role", "client-usage", [])
consumer.uuid.should_not be_nil

consumer.serviceLevel.should == "client-sla"
consumer.usage.should == "ak-usage"
consumer.role.should == "ak-role"
consumer['addOns'].length.should == 2
expect(consumer['addOns']).to include('ak-addon1')
expect(consumer['addOns']).to include('ak-addon2')
end

it 'should allow a consumer to register with syspurpose attributes on activation key and consumer' do
prod1 = create_product(random_string('product1'), random_string('product1'))
create_pool_and_subscription(@owner['key'], prod1.id, 10)

key1 = @cp.create_activation_key(@owner['key'], 'key1', nil, nil, 'test-usage', 'test-role', ['addon1','addon2'])
ak_role = 'ak-role'
ak_usage = 'ak-usage'
ak_addons = ['ak-addon1','ak-addon2']

key1 = @cp.create_activation_key(@owner['key'], 'key1', nil, nil, ak_usage, ak_role, ak_addons)

service_level = 'consumer_service_level'
role = 'consumer_role'
Expand All @@ -144,12 +167,12 @@
expect(consumer['uuid']).to_not be_nil

expect(consumer['serviceLevel']).to eq(service_level)
expect(consumer['role']).to eq(role)
expect(consumer['usage']).to eq(usage)
expect(consumer['role']).to eq(ak_role)
expect(consumer['usage']).to eq(ak_usage)

expect(consumer['addOns']).to_not be_nil
expect(consumer['addOns'].size).to eq(addons.size)
expect(consumer['addOns']).to include(*addons)
expect(consumer['addOns'].size).to eq(ak_addons.size)
expect(consumer['addOns']).to include(*ak_addons)
end

it 'should allow a consumer to register with multiple activation keys with same content override names' do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -841,15 +841,15 @@ public Consumer createConsumerFromDTO(ConsumerDTO consumer, ConsumerType type, P

sink.emitConsumerCreated(consumerToCreate);

// Update syspurpose data
// Note: this must come before activation key handling, as syspurpose details on the
// activation keys have higher priority than those on consumer
this.updateSystemPurposeData(consumer, consumerToCreate);

if (keys.size() > 0) {
consumerBindUtil.handleActivationKeys(consumerToCreate, keys, owner.isAutobindDisabled());
}

// Update syspurpose data
// Note: this must come after activation key handling, as syspurpose details on the
// consumer have higher priority than those on activation keys
this.updateSystemPurposeData(consumer, consumerToCreate);

// If no service level was specified, and the owner has a default set, use it:
String csl = consumerToCreate.getServiceLevel();
if ((csl == null || csl.isEmpty())) {
Expand Down