summaryrefslogtreecommitdiffabout
path: root/test/idiscover.cc
authorMichael Krelin <hacker@klever.net>2008-01-20 21:10:23 (UTC)
committer Michael Krelin <hacker@klever.net>2008-01-20 21:10:23 (UTC)
commitd16e79b1c792352eade736e7080c401a6c7ace03 (patch) (unidiff)
tree545a905ab8ef5c2a2135c17d2f949556b354b842 /test/idiscover.cc
parent9bfb6fadf71c46bf4cb5adabba0c96c32e84c1bc (diff)
downloadlibopkele-d16e79b1c792352eade736e7080c401a6c7ace03.zip
libopkele-d16e79b1c792352eade736e7080c401a6c7ace03.tar.gz
libopkele-d16e79b1c792352eade736e7080c401a6c7ace03.tar.bz2
test part rewritten
* cut down test.cc to only test rfc uri normalization * redone idiscover to only list discovered endpoints * added test RP cgi Signed-off-by: Michael Krelin <hacker@klever.net>
Diffstat (limited to 'test/idiscover.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--test/idiscover.cc46
1 files changed, 16 insertions, 30 deletions
diff --git a/test/idiscover.cc b/test/idiscover.cc
index d9a7c62..44df9ce 100644
--- a/test/idiscover.cc
+++ b/test/idiscover.cc
@@ -1,54 +1,40 @@
1#include <iostream> 1#include <iostream>
2#include <stdexcept> 2#include <stdexcept>
3#include <iterator> 3#include <iterator>
4#include <algorithm> 4#include <algorithm>
5using namespace std; 5using namespace std;
6#include <opkele/exception.h> 6#include <opkele/exception.h>
7#include <opkele/discovery.h> 7#include <opkele/discovery.h>
8#include <opkele/util.h>
8 9
9template<typename _PDT> 10namespace opkele {
10 ostream& operator<<(ostream& o,const opkele::xrd::priority_map<_PDT>& pm) { 11 ostream& operator<<(ostream& o,const opkele::openid_endpoint_t& oep) {
11 for(typename opkele::xrd::priority_map<_PDT>::const_iterator i=pm.begin(); 12 o
12 i!=pm.end();++i) 13 << " URI: " << oep.uri << endl
13 o << ' ' << i->second << '[' << i->first << ']'; 14 << " Claimed ID: " << oep.claimed_id << endl
15 << " Local ID: " << oep.local_id << endl;
14 return o; 16 return o;
15 } 17 }
16
17ostream& operator<<(ostream& o,const opkele::xrd::service_t s) {
18 o << "{" << endl
19 << " Type: ";
20 copy(s.types.begin(),s.types.end(),
21 ostream_iterator<string>(o," "));
22 o << endl
23 << " URI: " << s.uris << endl
24 << " LocalID: " << s.local_ids << endl
25 << " ProviderID: " << s.provider_id << endl;
26 o << "}";
27} 18}
28 19
29int main(int argc,char **argv) { 20int main(int argc,char **argv) {
30 try { 21 try {
31 if(argc<2) 22 if(argc<2)
32 throw opkele::exception(OPKELE_CP_ "Please, give me something to resolve"); 23 throw opkele::exception(OPKELE_CP_ "Please, give me something to resolve");
33 for(int a=1;a<argc;++a) { 24 for(int a=1;a<argc;++a) {
34 opkele::idiscovery_t discovery(argv[a]); 25 cout << "==============================================================" << endl
35 clog
36 << "===============================================================" << endl
37 << "User-supplied ID: " << argv[a] << endl 26 << "User-supplied ID: " << argv[a] << endl
38 << "Normalized ID: " << discovery.normalized_id << endl 27 << "Endpoints:" << endl
39 << "Canonicalized ID: " << discovery.canonicalized_id << endl 28 << " --" << endl;
40 << "The identity is " << (discovery.xri_identity?"":"not ") << "an i-name" << endl; 29 string normalized = opkele::idiscover(
41 if(discovery.xrd.expires) 30 ostream_iterator<opkele::openid_endpoint_t>(cout," --\n")
42 clog << "Information expires in " << discovery.xrd.expires-time(0) << " seconds" << endl; 31 ,argv[a]);
43 clog << endl 32 cout << "Normalized ID: " << normalized << endl;
44 << "CanonicalID: " << discovery.xrd.canonical_ids << endl
45 << "LocalID: " << discovery.xrd.local_ids << endl
46 << "ProviderID: " << discovery.xrd.provider_id << endl
47 << "Services: " << discovery.xrd.services << endl;
48 } 33 }
49 }catch(exception& e) { 34 }catch(exception& e) {
50 cerr << "oops: " << e.what() << endl; 35 cerr << "oops, caught " << opkele::util::abi_demangle(typeid(e).name()) << endl
36 << " .what(): " << e.what() << endl;
51 _exit(1); 37 _exit(1);
52 } 38 }
53 _exit(0); 39 _exit(0);
54} 40}