author | Michael Krelin <hacker@klever.net> | 2008-03-08 22:31:50 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2008-03-08 22:31:50 (UTC) |
commit | e6928c1d6c368e999ec8d1b05fccec44c2bebdbc (patch) (side-by-side diff) | |
tree | e321a949b69e770fe7d6ea00056ed55e4407def3 /test | |
parent | 1d108d28c5c2bd55827021aef944a48421bfb3ef (diff) | |
download | libopkele-e6928c1d6c368e999ec8d1b05fccec44c2bebdbc.zip libopkele-e6928c1d6c368e999ec8d1b05fccec44c2bebdbc.tar.gz libopkele-e6928c1d6c368e999ec8d1b05fccec44c2bebdbc.tar.bz2 |
updated test oauth consumer
Signed-off-by: Michael Krelin <hacker@klever.net>
-rw-r--r-- | test/test-oauth-consumer.cc | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/test/test-oauth-consumer.cc b/test/test-oauth-consumer.cc index c5a0fc0..b3ddef5 100644 --- a/test/test-oauth-consumer.cc +++ b/test/test-oauth-consumer.cc @@ -1,73 +1,69 @@ #include <iostream> #include <cassert> #include <stdexcept> using namespace std; #include <openssl/sha.h> #include <openssl/evp.h> #include <openssl/hmac.h> #include <opkele/exception.h> #include <opkele/debug.h> #include <opkele/util.h> #include <opkele/util-internal.h> #include <opkele/curl.h> #include <opkele/oauth/consumer.h> ostream& operator<<(ostream& o,const opkele::oauth::token_t& t) { o << "{ key: \"" << t.key << "\", secret: \"" << t.secret <<"\" }"; return o; } int main(int,char**) { try { opkele::oauth::simple_consumer sc( opkele::oauth::simple_provider_endpoints( "http://term.ie/oauth/example/request_token.php", "http://term.ie/oauth/example/user_authorization.php", "http://term.ie/oauth/example/access_token.php", "HMAC-SHA1", opkele::oauth::oauth_post_body, opkele::oauth::oauth_auth_header), 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"); CURLcode r = curl.misc_sets(); r || (r=curl.set_write()); if(r) throw opkele::exception_curl(OPKELE_CP_ "failed to set curly options",r); - hr.setup_curl(curl); + 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); 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; } } #endif }catch(std::exception& e){ cerr << "oops, caught " << opkele::util::abi_demangle(typeid(e).name()) << endl << " what: " << e.what() << endl; } } |