-rw-r--r-- | test/Makefile.am | 5 | ||||
-rw-r--r-- | test/test-oauth-consumer.cc | 22 |
2 files changed, 8 insertions, 19 deletions
diff --git a/test/Makefile.am b/test/Makefile.am index f0c0ea8..7cfe3a4 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,35 +1,38 @@ -noinst_PROGRAMS = test idiscover RP.cgi OP.cgi test-oauth-consumer +noinst_PROGRAMS = test idiscover test-oauth-consumer \ + ${_dependent_programs_} AM_CPPFLAGS=${CPPFLAGS_DEBUG} DEFAULT_INCLUDES = -I${top_builddir} INCLUDES = -I${top_srcdir}/test/ -I${top_builddir}/include/ -I${top_srcdir}/include/ ${KONFORKA_CFLAGS} ${LIBCURL_CPPFLAGS} test_SOURCES = test.cc test_LDADD = ${top_builddir}/lib/libopkele.la EXTRA_DIST= \ sqlite.h kingate_openid_message.h \ RP-db.sql OP-db.sql idiscover_SOURCES = idiscover.cc idiscover_LDADD = ${top_builddir}/lib/libopkele.la test_oauth_consumer_SOURCES = test-oauth-consumer.cc test_oauth_consumer_LDADD = ${top_builddir}/lib/libopkele.la if HAVE_SQLITE3 if HAVE_UUID if HAVE_KINGATE +_dependent_programs_ = RP.cgi OP.cgi + RP_cgi_SOURCES = RP.cc nodist_RP_cgi_SOURCES = RP-db.cc RP_cgi_LDADD = ${top_builddir}/lib/libopkele.la \ ${SQLITE3_LIBS} ${KINGATE_LIBS} RP_cgi_CFLAGS = ${SQLITE3_CFLAGS} ${KINGATE_CFLAGS} RP-db.cc: RP-db.sql ( \ echo 'const char * __RP_db_bootstrap = ' && \ sed -e 's/^/"/' -e 's/$$/"/' $< && \ echo ';' \ ) >$@ diff --git a/test/test-oauth-consumer.cc b/test/test-oauth-consumer.cc index 3b3ca70..b3ddef5 100644 --- a/test/test-oauth-consumer.cc +++ b/test/test-oauth-consumer.cc @@ -29,46 +29,32 @@ int main(int,char**) { opkele::oauth::token_t( "key","secret" ) ); opkele::oauth::token_t rt = sc.get_request_token(); cout << "Request token: " << rt << endl; cout << "Authorize URL: " << sc.get_authorize_url(rt) << endl; opkele::oauth::token_t at = sc.get_access_token(rt); cout << "Access token: " << at << endl; opkele::fields_t test; test.set_field("foo","bar"); opkele::util::curl_pick_t curl = opkele::util::curl_t::easy_init(); opkele::oauth::http_request_t hr("POST", "http://term.ie/oauth/example/echo_api.php"); - sc.prepare_request(hr, - opkele::fields_t(),test, - opkele::oauth::oauth_auth_header,"HMAC-SHA1", - &at,"realm"); - DOUT_("url: " << hr.url << endl - << "body: " << hr.body << endl - << "header: " << hr.authorize_header); - opkele::util::curl_slist_t rh; - rh.append("Authorization: "+hr.authorize_header); - CURLcode r; - (r=curl.misc_sets()) - || (r=curl.set_write()) - || (r=curl.easy_setopt(CURLOPT_HTTPHEADER,rh) ) - || (r=curl.easy_setopt(CURLOPT_URL,hr.url.c_str())) - || (r=curl.easy_setopt(CURLOPT_POST,1)) - || (r=curl.easy_setopt(CURLOPT_POSTFIELDS,hr.body.c_str())) - || (r=curl.easy_setopt(CURLOPT_POSTFIELDSIZE,hr.body.size())); + CURLcode r = curl.misc_sets(); + r || (r=curl.set_write()); if(r) throw opkele::exception_curl(OPKELE_CP_ "failed to set curly options",r); + sc.prepare_request(hr,opkele::fields_t(),test,&at).setup_curl(curl); if( (r=curl.easy_perform()) ) throw opkele::exception_curl(OPKELE_CP_ "failed to perform curly request",r); - DOUT_("Response: " << endl << curl.response); + cout << "Response: " << curl.response << endl; #ifdef OPKELE_HAVE_KONFORKA }catch(konforka::exception& e) { cerr << "oops, caught " << opkele::util::abi_demangle(typeid(e).name()) << endl << " what: " << e.what() << endl << " where: " << e.where() << endl; if(!e._seen.empty()) { cerr << " seen:" << endl; for(list<konforka::code_point>::const_iterator i=e._seen.begin();i!=e._seen.end();++i) { cerr << " " << i->c_str() << endl; |