Bug 612247

Summary: subscribe to custom pool w/ custom product fails
Product: [Community] Candlepin Reporter: wes hayutin <whayutin>
Component: candlepinAssignee: Adrian Likins <alikins>
Status: CLOSED WONTFIX QA Contact: wes hayutin <whayutin>
Severity: medium Docs Contact:
Priority: medium    
Version: 0.5CC: alikins, bkearney
Target Milestone: ---Keywords: Triaged
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-04-16 20:18:37 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description wes hayutin 2010-07-07 16:33:41 UTC
Use the following script to create a custom owner, user, product and pool.

#####
Error:
[root@oldceremony ~]# subscription-manager-cli subscribe --pool=13
Runtime Error java.lang.IllegalArgumentException: string 1.3.6.1.4.1.2312.9.1.-188428674.1 not an OID at org.bouncycastle.asn1.DERObjectIdentifier.<init>:-1
#####


#### SCRIPT ##########
[root@localhost ruby]# cat population.rb 
#!/usr/bin/ruby

#require  "../../../client/ruby/candlepin_api"
require  "candlepin_api"
require 'pp'

cp = Candlepin.new('admin', 'admin')

puts 'Creating Owner'
owner = cp.create_owner('owner_test04')

puts 'Creating User'
user = cp.create_user(owner['id'], 'user_test04', 'dog8code')

puts 'Creating Product'
product = cp.create_product('product_test04', 'product_test04'.hash)

puts 'Creating Subscription'
cp.create_subscription(owner['id'], product['id'], 3000000)
cp.refresh_pools(owner['key'])
[root@localhost ruby]# 


#####################################
DB entry


ard support  |       10 |                      | 2010-07-06 20:00:00 |             10 |        1 |                     
 11 | 2010-07-07 10:23:12.913 | 2010-07-07 11:49:31.191 | t                  |        0 | 2011-07-06 20:00:00 | MKT-ipa-client-50                     | IPA Client Pack (50)                                   
             |      500 |                      | 2010-07-06 20:00:00 |             11 |        1 |                     
 12 | 2010-07-07 12:10:35.628 | 2010-07-07 12:10:35.628 | t                  |        0 | 2011-07-06 20:00:00 | -188428675                            |                                                        
             |  3000000 |                      | 2010-07-06 20:00:00 |             12 |        3 |                     
 13 | 2010-07-07 12:19:50.142 | 2010-07-07 12:23:58.598 | t                  |        0 | 2011-07-06 20:00:00 | -188428674                            | product_test04                                         
             |  3000000 |                      | 2010-07-06 20:00:00 |             13 |        4 |                     
(13 rows)

###################
  4 | 2010-07-07 12:19:49.412 | 2010-07-07 12:19:49.412 | owner_test04 | owner_test04

###################
  5 | 2010-07-07 12:19:49.634 | 2010-07-07 12:19:49.634 | dog8code | f          | user_test04  |        4
(5 rows)

##################
TOMCAT LOG
Jul 07 12:26:50 [http-8443-3] DEBUG org.fedoraproject.candlepin.resteasy.interceptor.BasicAuth - principal created for owner 'owner_test04' with username 'user_test04'
Jul 07 12:26:50 [http-8443-3] DEBUG org.fedoraproject.candlepin.auth.interceptor.SecurityInterceptor - Invoked.
Jul 07 12:26:50 [http-8443-3] DEBUG org.fedoraproject.candlepin.auth.interceptor.SecurityInterceptor - com.google.inject.InterceptorStackCallback$InterceptedMethodInvocation
Jul 07 12:26:50 [http-8443-3] DEBUG org.fedoraproject.candlepin.auth.interceptor.SecurityInterceptor - 0
Jul 07 12:26:50 [http-8443-3] DEBUG org.fedoraproject.candlepin.auth.interceptor.SecurityInterceptor - Method annotation: @org.fedoraproject.candlepin.auth.interceptor.AllowRoles(roles=[OWNER_ADMIN])
Jul 07 12:26:50 [http-8443-3] DEBUG org.fedoraproject.candlepin.auth.interceptor.SecurityInterceptor -    allowing role: OWNER_ADMIN
Jul 07 12:26:50 [http-8443-3] DEBUG org.fedoraproject.candlepin.auth.interceptor.SecurityInterceptor - Granting access for UserPrincipal [ownerId=4, username=user_test04, roles=[OWNER_ADMIN]] due to role: OWNER_ADMIN
Jul 07 12:26:50 [http-8443-3] DEBUG org.fedoraproject.candlepin.servlet.filter.logging.LoggingFilter - ====Response====
Jul 07 12:26:50 [http-8443-3] DEBUG org.fedoraproject.candlepin.servlet.filter.logging.LoggingFilter - Status: 200
Jul 07 12:26:50 [http-8443-3] DEBUG org.fedoraproject.candlepin.servlet.filter.logging.LoggingFilter - Response Body:<?xml version="1.0" encoding="UTF-8" standalone="yes"?><atom:feed xmlns:atom="http://www.w3.org/2005/Atom"><atom:updated>2010-07-07T12:20:15.060-04:00</atom:updated><atom:entry><atom:title>CONSUMER CREATED</atom:title><atom:published>2010-07-07T12:20:15.060-04:00</atom:published><atom:content><event><consumerId>3</consumerId><entityId>3</entityId><id>8</id><ownerId>4</ownerId><principal>UserPrincipal [ownerId=4, username=user_test04, roles=[OWNER_ADMIN]]</principal><target>CONSUMER</target><timestamp>2010-07-07T12:20:15.060-04:00</timestamp><type>CREATED</type></event></atom:content></atom:entry></atom:feed>
(END) 
####################
SUBSCRIPTION-MANAGER LOG
2010-07-07 12:05:57,529 [INFO] __init__() @connection.py:111 - Connection Established: host: 10.16.120.131, port: 8443, handler: /candlepin
2010-07-07 12:05:58,716 [ERROR] _do_command() @managercli.py:245 - Runtime Error java.lang.IllegalArgumentException: string 1.3.6.1.4.1.2312.9.1.-188428674.1 not an OID at org.bouncycastle.asn1.DERObjectIdentifier.<init>:-1

Comment 1 Adrian Likins 2010-07-12 18:21:43 UTC
Looks like the script is using product_name.hash for it's id.  .hash can sometimes be negative, which is not valid for a product id (or at least not for a product that is going to have a subscription/pool created for it directly, since that product id will eventually end up in the x509 cert OID). 

Also, need to register as the user created in that script to be able to subscribe to that product. Updated script inline (also adds cli argument to specify the user/product/etc count)

#!/usr/bin/ruby

#require  "../../../client/ruby/candlepin_api"
require  "candlepin_api"
require 'pp'

count = ARGV[0]

puts count
cp = Candlepin.new('admin', 'admin')

puts 'Creating Owner'
owner = cp.create_owner("owner_test#{count}")

puts 'Creating User'
user = cp.create_user(owner['id'], "user_test#{count}", 'dog8code')

puts 'Creating Product'
product = cp.create_product("product_test#{count}", "product_test#{count}".hash.abs)

puts 'Creating Subscription'
cp.create_subscription(owner['id'], product['id'], 3000000)
cp.refresh_pools(owner['key'])



Running that as ".that_script.rb 114"
then

      sudo subscription-manager-cli register --username user_test114 --password dog8code  --force

then

[adrian@alikins ruby]$ sudo subscription-manager-cli list --available
d8a6fae2-fa89-4e5d-b252-838d43785b95 <connection.UEPConnection instance at 0x15c77e8>
+-------------------------------------------+
    Available Subscriptions
+-------------------------------------------+


Name:              	product_test114          
ProductId:         	1131145341               
PoolId:            	17                       
quantity:          	3000000                  
Expires:           	2011-07-11               

[adrian@alikins ruby]$ sudo subscription-manager-cli subscribe --pool 17

Seems to work.



Serverside should probably be detecting that that is an invalid id for a "SVC" product (svc is the default in the ruby api) and complaining.