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

1767981: Unable to enable the tools repository for Satellite 6.6 [2.6] #2668

Merged
merged 2 commits into from
Mar 27, 2020
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
106 changes: 106 additions & 0 deletions server/spec/derived_product_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

before(:each) do
@owner = create_owner random_string('instance_owner')
@owner_key = @owner['key']
@user = user_client(@owner, random_string('virt_user'))

#create_product() creates products with numeric IDs by default
Expand Down Expand Up @@ -296,6 +297,111 @@
product['content'].size.should == 0
end

it 'regenerates entitlements when updating derived content' do
skip("candlepin running in standalone mode") if not is_hosted?

# Create a subscription with an upstream product with a derived product that provides content
datacenter_product = create_upstream_product(random_string('dc_prod'), {
:attributes => {
:virt_limit => "unlimited",
:stacking_id => "stackme",
:sockets => "2",
'multi-entitlement' => "yes"
}
})
derived_product = create_upstream_product(random_string('derived_prod'), {
:attributes => {
:cores => 2,
:sockets=>4
}
})

derived_eng_product = create_upstream_product(random_string(nil, true))
derived_content = create_upstream_content("twentyTwo", {
:type => "yum",
:label => "teardropsOnMyGuitar",
:name => "swiftrocks",
:vendor => "fifteen",
:releaseVer => nil
})
add_content_to_product_upstream(derived_eng_product.id, derived_content.id)

sub = create_upstream_subscription(random_string('dc_sub'), @owner_key, datacenter_product.id, {
:quantity => 10,
:derived_product => derived_product,
:derived_provided_products => [derived_eng_product]
})

@cp.refresh_pools(@owner_key)
@cp.get_product(@owner_key, derived_eng_product.id)['productContent'].size.should == 1
main_pools = @cp.list_pools({:owner => @owner.id, :product => datacenter_product.id})
expect(main_pools.length).to eq(1) # We're expecting the base pool

dist_name = random_string("CP Distributor")
create_distributor_version(dist_name, "Subscription Asset Manager", ["cert_v3", "derived_product"])
@distributor_client.update_consumer({:facts => {'distributor_version' => dist_name}})
entitlement = @distributor_client.consume_pool main_pools.first['id']
json_body = extract_payload(@distributor_client.list_certificates[0]['cert'])
products = json_body['products']
products.size.should == 1

found = false;
products.each do |cert_product|
if cert_product['id'] == derived_eng_product.id
found = true;
content_sets = cert_product['content']
content_sets.size.should == 1
content_sets[0].id.should == derived_content.id
end
end
found.should == true

# Add content to the derived product upstream
new_derived_content = create_upstream_content("twentyFour", {
:type => "yum",
:label => "teardropsOnMyUkelele",
:name => "slowrocks",
:vendor => "fifteen",
:releaseVer => nil
})
add_content_to_product_upstream(derived_eng_product.id, new_derived_content.id)

# Refresh the account
@cp.refresh_pools(@owner_key)
@cp.get_product(@owner_key, derived_eng_product.id)['productContent'].size.should == 2
json_body = extract_payload(@distributor_client.list_certificates[0]['cert'])
products = json_body['products']
products.size.should == 1

found = false;
products.each do |cert_product|
if cert_product['id'] == derived_eng_product.id
found = true;
content_sets = cert_product['content']
content_sets.size.should == 2
expect(content_sets[0].id).to eq(derived_content.id).or eq(new_derived_content.id)
expect(content_sets[1].id).to eq(derived_content.id).or eq(new_derived_content.id)
end
end
found.should == true

@distributor_client.unbind_entitlement(entitlement[0].id)
entitlement = @distributor_client.consume_pool main_pools.first['id']
json_body = extract_payload(@distributor_client.list_certificates[0]['cert'])
products = json_body['products']

found = false;
products.each do |cert_product|
if cert_product['id'] == derived_eng_product.id
found = true;
content_sets = cert_product['content']
content_sets.size.should == 2
expect(content_sets[0].id).to eq(derived_content.id).or eq(new_derived_content.id)
expect(content_sets[1].id).to eq(derived_content.id).or eq(new_derived_content.id)
end
end
found.should == true
end

def setup_modifier_test
# Content for modified product is only included if it provides the modified product
Expand Down
4 changes: 2 additions & 2 deletions server/spec/oauth_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
def make_request(oauth_consumer, oauth_secret, uri, headers = {})
consumer = OAuth::Consumer.new(oauth_consumer, oauth_secret, @oauth_params)

request = Net::HTTP::Get.new("#{@site}#{uri}")
consumer.sign!(request)
url = URI.parse("#{@site}#{uri}")
request = Net::HTTP::Get.new(url)
consumer.sign!(request)

headers.each_pair do |k, v|
request[k] = v
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ protected Set<String> processPoolUpdates(Map<String, EventBuilder> poolEvents,

// dates changed. regenerate all entitlement certificates
if (updatedPool.getDatesChanged() || updatedPool.getProductsChanged() ||
updatedPool.getBrandingChanged()) {
updatedPool.getBrandingChanged() || updatedPool.getDerivedProductsChanged()) {

poolsToRegenEnts.add(existingPool);
}
Expand Down