cloudspokes/tc-api — pull request #200 by bugbuka (2014-04-15 07:38:01+00:00)
Title: For register challenge API, check if there is a jwt (logged in user).

static:tc-api mac$ node_modules/.bin/mocha test/test.challengeRegistration.js

Tue Apr 15 2014 15:38:03 GMT+0800 (CST) - Initialized pool for url - jdbc:informix-sqli://informix.cloud.topcoder.com:2021/tcs_catalog:INFORMIXSERVER=informixoltp_tcp;INFORMIXCONRETRY=1;INFORMIXCONTIME=3;
Apr 15, 2014 3:38:03 PM snaq.db.ConnectionPool.pool-tcs_catalog log_info
INFO: pool-tcs_catalog: Getting connection (user/password): jdbc:informix-sqli://informix.cloud.topcoder.com:2021/tcs_catalog:INFORMIXSERVER=informixoltp_tcp;INFORMIXCONRETRY=1;INFORMIXCONTIME=3;
Apr 15, 2014 3:38:03 PM snaq.db.ConnectionPool.pool-tcs_catalog log_info
INFO: pool-tcs_catalog: Created a new connection
Apr 15, 2014 3:38:03 PM snaq.db.ConnectionPool.pool-tcs_catalog log_info
INFO: pool-tcs_catalog: Warning - Database has transactions
Apr 15, 2014 3:38:03 PM snaq.db.ConnectionPool.pool-tcs_catalog log_info
INFO: pool-tcs_catalog: Warning - Database selected
Tue Apr 15 2014 15:38:03 GMT+0800 (CST) - Initialized pool for url - jdbc:informix-sqli://informix.cloud.topcoder.com:2021/common_oltp:INFORMIXSERVER=informixoltp_tcp;INFORMIXCONRETRY=1;INFORMIXCONTIME=3;
Apr 15, 2014 3:38:03 PM snaq.db.ConnectionPool.pool-common_oltp log_info
INFO: pool-common_oltp: Getting connection (user/password): jdbc:informix-sqli://informix.cloud.topcoder.com:2021/common_oltp:INFORMIXSERVER=informixoltp_tcp;INFORMIXCONRETRY=1;INFORMIXCONTIME=3;
Apr 15, 2014 3:38:04 PM snaq.db.ConnectionPool.pool-common_oltp log_info
INFO: pool-common_oltp: Created a new connection
Apr 15, 2014 3:38:04 PM snaq.db.ConnectionPool.pool-common_oltp log_info
INFO: pool-common_oltp: Warning - Database has transactions
Apr 15, 2014 3:38:04 PM snaq.db.ConnectionPool.pool-common_oltp log_info
INFO: pool-common_oltp: Warning - Database selected
Tue Apr 15 2014 15:38:04 GMT+0800 (CST) - Initialized pool for url - jdbc:informix-sqli://informix.cloud.topcoder.com:2021/informixoltp:INFORMIXSERVER=informixoltp_tcp;INFORMIXCONRETRY=1;INFORMIXCONTIME=3;
Apr 15, 2014 3:38:04 PM snaq.db.ConnectionPool.pool-informixoltp log_info
INFO: pool-informixoltp: Getting connection (user/password): jdbc:informix-sqli://informix.cloud.topcoder.com:2021/informixoltp:INFORMIXSERVER=informixoltp_tcp;INFORMIXCONRETRY=1;INFORMIXCONTIME=3;
Apr 15, 2014 3:38:04 PM snaq.db.ConnectionPool.pool-informixoltp log_info
INFO: pool-informixoltp: Created a new connection
Apr 15, 2014 3:38:04 PM snaq.db.ConnectionPool.pool-informixoltp log_info
INFO: pool-informixoltp: Warning - Database has transactions
Apr 15, 2014 3:38:04 PM snaq.db.ConnectionPool.pool-informixoltp log_info
INFO: pool-informixoltp: Warning - Database selected
Challenge Registration API Register software challenge with all of terms of use agreed should success: Registration completed. Now verify the database is the same as predicted data
Now validate based on sqlfile: sqls/challengeRegistration/tcs_catalog__select_component_inquiry.json
the text: {
"component_id": 40000001,
"user_id": 400011,
"agreed_to_terms": 1,
"rating": 0,
"comment": "Cool",
"phase": 113,
"tc_user_id": 400011,
"version": 1,
"project_id": 40000001
}
the parsed object:{"component_id":40000001,"user_id":400011,"agreed_to_terms":1,"rating":0,"comment":"Cool","phase":113,"tc_user_id":400011,"version":1,"project_id":40000001}
Now validate based on sqlfile: sqls/challengeRegistration/tcs_catalog__select_project_result.json
the text: {
"project_id": 40000001,
"user_id": 400011,
"rating_ind": 0,
"valid_submission_ind": 0,
"old_rating": 0
}
the parsed object:{"project_id":40000001,"user_id":400011,"rating_ind":0,"valid_submission_ind":0,"old_rating":0}
Now validate based on sqlfile: sqls/challengeRegistration/tcs_catalog__select_software_challenge_resource.json
the text: {
"resource_role_id" : 1,
"project_id" : 40000001,
"create_user" : "400011",
"modify_user" : "400011"
}
the parsed object:{"resource_role_id":1,"project_id":40000001,"create_user":"400011","modify_user":"400011"}
Now validate based on sqlfile: sqls/challengeRegistration/tcs_catalog__select_software_challenge_resource_info.json
the text: {
"user_id": "400011",
"handle": "normal_user_11"
}
the parsed object:{"user_id":"400011","handle":"normal_user_11"}
Now validate based on sqlfile: sqls/challengeRegistration/tcs_catalog__select_software_notification.json
the text: {
"project_id": 40000001,
"external_ref_id": 400011,
"notification_type_id": 1,
"create_user": "400011",
"modify_user": "400011"
}
the parsed object:{"project_id":40000001,"external_ref_id":400011,"notification_type_id":1,"create_user":"400011","modify_user":"400011"}
Apr 15, 2014 3:38:04 PM snaq.db.ConnectionPool.pool-tcs_catalog log_info
INFO: pool-tcs_catalog: Getting connection (user/password): jdbc:informix-sqli://informix.cloud.topcoder.com:2021/tcs_catalog:INFORMIXSERVER=informixoltp_tcp;INFORMIXCONRETRY=1;INFORMIXCONTIME=3;
Apr 15, 2014 3:38:04 PM snaq.db.ConnectionPool.pool-tcs_catalog log_info
INFO: pool-tcs_catalog: Created a new connection
Apr 15, 2014 3:38:04 PM snaq.db.ConnectionPool.pool-tcs_catalog log_info
INFO: pool-tcs_catalog: Warning - Database has transactions
Apr 15, 2014 3:38:04 PM snaq.db.ConnectionPool.pool-tcs_catalog log_info
INFO: pool-tcs_catalog: Warning - Database selected
Apr 15, 2014 3:38:04 PM snaq.db.ConnectionPool.pool-tcs_catalog log_info
INFO: pool-tcs_catalog: Getting connection (user/password): jdbc:informix-sqli://informix.cloud.topcoder.com:2021/tcs_catalog:INFORMIXSERVER=informixoltp_tcp;INFORMIXCONRETRY=1;INFORMIXCONTIME=3;
The query result:[{"tc_user_id":400011,"component_id":40000001,"project_id":40000001,"create_time":"2014-04-15T15:38:04.000+0800","agreed_to_terms":1,"user_id":400011,"component_inquiry_id":4000054,"rating":0,"comment":"Cool","phase":113,"version":1}]
the object in database:{"tc_user_id":400011,"component_id":40000001,"project_id":40000001,"create_time":"2014-04-15T15:38:04.000+0800","agreed_to_terms":1,"user_id":400011,"component_inquiry_id":4000054,"rating":0,"comment":"Cool","phase":113,"version":1}
matched
Apr 15, 2014 3:38:04 PM snaq.db.ConnectionPool.pool-tcs_catalog log_info
INFO: pool-tcs_catalog: Created a new connection
Apr 15, 2014 3:38:04 PM snaq.db.ConnectionPool.pool-tcs_catalog log_info
INFO: pool-tcs_catalog: Warning - Database has transactions
Apr 15, 2014 3:38:04 PM snaq.db.ConnectionPool.pool-tcs_catalog log_info
INFO: pool-tcs_catalog: Warning - Database selected
Apr 15, 2014 3:38:04 PM snaq.db.ConnectionPool.pool-tcs_catalog log_info
INFO: pool-tcs_catalog: Getting connection (user/password): jdbc:informix-sqli://informix.cloud.topcoder.com:2021/tcs_catalog:INFORMIXSERVER=informixoltp_tcp;INFORMIXCONRETRY=1;INFORMIXCONTIME=3;
The query result:[{"modify_date":"2014-04-15T15:38:04.000+0800","valid_submission_ind":0,"create_date":"2014-04-15T15:38:04.000+0800","project_id":40000001,"rating_ind":0,"user_id":400011,"old_rating":0}]
the object in database:{"modify_date":"2014-04-15T15:38:04.000+0800","valid_submission_ind":0,"create_date":"2014-04-15T15:38:04.000+0800","project_id":40000001,"rating_ind":0,"user_id":400011,"old_rating":0}
matched
The query result:[{"handle":"normal_user_11","user_id":"400011"}]
the object in database:{"handle":"normal_user_11","user_id":"400011"}
matched
Apr 15, 2014 3:38:05 PM snaq.db.ConnectionPool.pool-tcs_catalog log_info
INFO: pool-tcs_catalog: Created a new connection
Apr 15, 2014 3:38:05 PM snaq.db.ConnectionPool.pool-tcs_catalog log_info
INFO: pool-tcs_catalog: Warning - Database has transactions
Apr 15, 2014 3:38:05 PM snaq.db.ConnectionPool.pool-tcs_catalog log_info
INFO: pool-tcs_catalog: Warning - Database selected
Apr 15, 2014 3:38:05 PM snaq.db.ConnectionPool.pool-tcs_catalog log_info
INFO: pool-tcs_catalog: Getting connection (user/password): jdbc:informix-sqli://informix.cloud.topcoder.com:2021/tcs_catalog:INFORMIXSERVER=informixoltp_tcp;INFORMIXCONRETRY=1;INFORMIXCONTIME=3;
The query result:[{"resource_id":4000054,"modify_user":"400011","create_date":"2014-04-15T15:38:04.000+0800","modify_date":"2014-04-15T15:38:04.000+0800","project_id":40000001,"create_user":"400011","user_id":400011,"resource_role_id":1}]
the object in database:{"resource_id":4000054,"modify_user":"400011","create_date":"2014-04-15T15:38:04.000+0800","modify_date":"2014-04-15T15:38:04.000+0800","project_id":40000001,"create_user":"400011","user_id":400011,"resource_role_id":1}
matched
Apr 15, 2014 3:38:05 PM snaq.db.ConnectionPool.pool-tcs_catalog log_info
INFO: pool-tcs_catalog: Created a new connection
Apr 15, 2014 3:38:05 PM snaq.db.ConnectionPool.pool-tcs_catalog log_info
INFO: pool-tcs_catalog: Warning - Database has transactions
Apr 15, 2014 3:38:05 PM snaq.db.ConnectionPool.pool-tcs_catalog log_info
INFO: pool-tcs_catalog: Warning - Database selected
The query result:[{"modify_user":"400011","create_date":"2014-04-15T15:38:04.000+0800","modify_date":"2014-04-15T15:38:04.000+0800","project_id":40000001,"external_ref_id":400011,"create_user":"400011","notification_type_id":1}]
the object in database:{"modify_user":"400011","create_date":"2014-04-15T15:38:04.000+0800","modify_date":"2014-04-15T15:38:04.000+0800","project_id":40000001,"external_ref_id":400011,"create_user":"400011","notification_type_id":1}
matched
․ Challenge Registration API Register software challenge with all of terms of use agreed should success: 998ms
․ Challenge Registration API Register again should fail: 25ms
․ Challenge Registration API Register again should fail: 6ms
Challenge Registration API Register studio challenge with all of terms of use agreed should success: Now validate based on sqlfile: sqls/challengeRegistration/tcs_catalog__select_studio_notification.json
the text: {
"project_id": 40000002,
"external_ref_id": 400011,
"notification_type_id": 1,
"create_user": "400011",
"modify_user": "400011"
}
the parsed object:{"project_id":40000002,"external_ref_id":400011,"notification_type_id":1,"create_user":"400011","modify_user":"400011"}
Apr 15, 2014 3:38:05 PM snaq.db.ConnectionPool.pool-tcs_catalog log_info
INFO: pool-tcs_catalog: Getting connection (user/password): jdbc:informix-sqli://informix.cloud.topcoder.com:2021/tcs_catalog:INFORMIXSERVER=informixoltp_tcp;INFORMIXCONRETRY=1;INFORMIXCONTIME=3;
Apr 15, 2014 3:38:05 PM snaq.db.ConnectionPool.pool-tcs_catalog log_info
INFO: pool-tcs_catalog: Created a new connection
Apr 15, 2014 3:38:05 PM snaq.db.ConnectionPool.pool-tcs_catalog log_info
INFO: pool-tcs_catalog: Warning - Database has transactions
Apr 15, 2014 3:38:05 PM snaq.db.ConnectionPool.pool-tcs_catalog log_info
INFO: pool-tcs_catalog: Warning - Database selected
The query result:[{"modify_user":"400011","create_date":"2014-04-15T15:38:05.000+0800","modify_date":"2014-04-15T15:38:05.000+0800","project_id":40000002,"external_ref_id":400011,"create_user":"400011","notification_type_id":1}]
the object in database:{"modify_user":"400011","create_date":"2014-04-15T15:38:05.000+0800","modify_date":"2014-04-15T15:38:05.000+0800","project_id":40000002,"external_ref_id":400011,"create_user":"400011","notification_type_id":1}
matched
Now validate based on sqlfile: sqls/challengeRegistration/tcs_catalog__select_studio_challenge_resource.json
the text: {
"resource_role_id" : 1,
"project_id" : 40000002,
"create_user" : "400011",
"modify_user" : "400011"
}
the parsed object:{"resource_role_id":1,"project_id":40000002,"create_user":"400011","modify_user":"400011"}
Apr 15, 2014 3:38:05 PM snaq.db.ConnectionPool.pool-tcs_catalog log_info
INFO: pool-tcs_catalog: Getting connection (user/password): jdbc:informix-sqli://informix.cloud.topcoder.com:2021/tcs_catalog:INFORMIXSERVER=informixoltp_tcp;INFORMIXCONRETRY=1;INFORMIXCONTIME=3;
Apr 15, 2014 3:38:05 PM snaq.db.ConnectionPool.pool-tcs_catalog log_info
INFO: pool-tcs_catalog: Created a new connection
Apr 15, 2014 3:38:05 PM snaq.db.ConnectionPool.pool-tcs_catalog log_info
INFO: pool-tcs_catalog: Warning - Database has transactions
Apr 15, 2014 3:38:05 PM snaq.db.ConnectionPool.pool-tcs_catalog log_info
INFO: pool-tcs_catalog: Warning - Database selected
The query result:[{"resource_id":4000055,"modify_user":"400011","create_date":"2014-04-15T15:38:05.000+0800","modify_date":"2014-04-15T15:38:05.000+0800","project_id":40000002,"create_user":"400011","user_id":400011,"resource_role_id":1}]
the object in database:{"resource_id":4000055,"modify_user":"400011","create_date":"2014-04-15T15:38:05.000+0800","modify_date":"2014-04-15T15:38:05.000+0800","project_id":40000002,"create_user":"400011","user_id":400011,"resource_role_id":1}
matched
Now validate based on sqlfile: sqls/challengeRegistration/tcs_catalog__select_studio_challenge_resource_info.json
the text: {
"user_id": "400011",
"handle": "normal_user_11",
"payments": "N/A"
}
the parsed object:{"user_id":"400011","handle":"normal_user_11","payments":"N/A"}
Apr 15, 2014 3:38:05 PM snaq.db.ConnectionPool.pool-tcs_catalog log_info
INFO: pool-tcs_catalog: Getting connection (user/password): jdbc:informix-sqli://informix.cloud.topcoder.com:2021/tcs_catalog:INFORMIXSERVER=informixoltp_tcp;INFORMIXCONRETRY=1;INFORMIXCONTIME=3;
Apr 15, 2014 3:38:05 PM snaq.db.ConnectionPool.pool-tcs_catalog log_info
INFO: pool-tcs_catalog: Created a new connection
Apr 15, 2014 3:38:05 PM snaq.db.ConnectionPool.pool-tcs_catalog log_info
INFO: pool-tcs_catalog: Warning - Database has transactions
Apr 15, 2014 3:38:05 PM snaq.db.ConnectionPool.pool-tcs_catalog log_info
INFO: pool-tcs_catalog: Warning - Database selected
The query result:[{"handle":"normal_user_11","payments":"N/A","user_id":"400011"}]
the object in database:{"handle":"normal_user_11","payments":"N/A","user_id":"400011"}
matched
․ Challenge Registration API Register studio challenge with all of terms of use agreed should success: 452ms
․ Challenge Registration API Register studio challenge again should fail: 13ms
․ Challenge Registration API Register software challenge with a part of terms of use agreed should fail: 42ms
․ Challenge Registration API Register studio challenge with a part of terms of use agreed should fail: 20ms
․ Challenge Registration API negative challenge number: 6ms
․ Challenge Registration API Challenge is NOT a number: 5ms
․ Challenge Registration API Challenge number exceed MAX_INT: 39ms
․ Challenge Registration API User is from a banned country: 20ms
․ Challenge Registration API User is not copilot: 21ms
․ Challenge Registration API User register a copilot posting challenge: 83ms
Apr 15, 2014 3:38:05 PM snaq.db.ConnectionPool.pool-tcs_catalog log_info
INFO: pool-tcs_catalog: Getting connection (user/password): jdbc:informix-sqli://informix.cloud.topcoder.com:2021/tcs_catalog:INFORMIXSERVER=informixoltp_tcp;INFORMIXCONRETRY=1;INFORMIXCONTIME=3;
Apr 15, 2014 3:38:06 PM snaq.db.ConnectionPool.pool-tcs_catalog log_info
INFO: pool-tcs_catalog: Created a new connection
Apr 15, 2014 3:38:06 PM snaq.db.ConnectionPool.pool-tcs_catalog log_info
INFO: pool-tcs_catalog: Warning - Database has transactions
Apr 15, 2014 3:38:06 PM snaq.db.ConnectionPool.pool-tcs_catalog log_info
INFO: pool-tcs_catalog: Warning - Database selected

13 passing (2s)

static:tc-api mac$