summaryrefslogtreecommitdiffabout
path: root/test
authorMichael Krelin <hacker@klever.net>2007-12-09 17:22:06 (UTC)
committer Michael Krelin <hacker@klever.net>2007-12-09 22:08:24 (UTC)
commitc34adc6e274c3dbb63af99ca566000e7d218244c (patch) (side-by-side diff)
tree705624c208deb4eaf8d07c119a883e6f4f35236e /test
parent60fdaff7888b455b4d07eadc905cefd20f1ddd3c (diff)
downloadlibopkele-c34adc6e274c3dbb63af99ca566000e7d218244c.zip
libopkele-c34adc6e274c3dbb63af99ca566000e7d218244c.tar.gz
libopkele-c34adc6e274c3dbb63af99ca566000e7d218244c.tar.bz2
reworked identity resolution and service discovery
The discovery, which does both XRDS-based (Yadis, XRI, for XRI, using proxy) and HTML-based search, now returns results in opkele:idiscovery_t structure. It uses expat-based parser idigger_t, which itself is not exposed via any header files, but hidden in lib/discovery.cc, the discovery testing program is renamed from openid_resolve to idiscover. Signed-off-by: Michael Krelin <hacker@klever.net>
Diffstat (limited to 'test') (more/less context) (ignore whitespace changes)
-rw-r--r--test/.gitignore2
-rw-r--r--test/Makefile.am6
-rw-r--r--test/idiscover.cc49
-rw-r--r--test/openid_resolve.cc36
4 files changed, 53 insertions, 40 deletions
diff --git a/test/.gitignore b/test/.gitignore
index 5ce4dc9..31ae686 100644
--- a/test/.gitignore
+++ b/test/.gitignore
@@ -2,4 +2,4 @@
/.libs
/test
*.o
-/openid_resolve
+/idiscover
diff --git a/test/Makefile.am b/test/Makefile.am
index 5aa87b3..13c4cd2 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1,4 +1,4 @@
-noinst_PROGRAMS = test openid_resolve
+noinst_PROGRAMS = test idiscover
DEFAULT_INCLUDES = -I${top_builddir}
INCLUDES = -I${top_srcdir}/include/ ${KONFORKA_CFLAGS}
@@ -11,5 +11,5 @@ EXTRA_DIST=$(addsuffix .html,$(addprefix html/, \
unclosed-head spaced-links spaced-link-attrs 2rels \
))
-openid_resolve_SOURCES = openid_resolve.cc
-openid_resolve_LDADD = ${top_builddir}/lib/libopkele.la
+idiscover_SOURCES = idiscover.cc
+idiscover_LDADD = ${top_builddir}/lib/libopkele.la
diff --git a/test/idiscover.cc b/test/idiscover.cc
new file mode 100644
index 0000000..2abedc9
--- a/dev/null
+++ b/test/idiscover.cc
@@ -0,0 +1,49 @@
+#include <iostream>
+#include <stdexcept>
+#include <iterator>
+#include <algorithm>
+using namespace std;
+#include <opkele/exception.h>
+#include <opkele/discovery.h>
+
+template<typename _PDT>
+ ostream& operator<<(ostream& o,const opkele::xrd::priority_map<_PDT>& pm) {
+ for(typename opkele::xrd::priority_map<_PDT>::const_iterator i=pm.begin();
+ i!=pm.end();++i)
+ o << ' ' << i->second << '[' << i->first << ']';
+ return o;
+ }
+
+ostream& operator<<(ostream& o,const opkele::xrd::service_t s) {
+ o << "{" << endl
+ << " Type: ";
+ copy(s.types.begin(),s.types.end(),
+ ostream_iterator<string>(o," "));
+ o << endl
+ << " URI: " << s.uris << endl
+ << " LocalID: " << s.local_ids << endl;
+ o << "}";
+}
+
+int main(int argc,char **argv) {
+ try {
+ if(argc<2)
+ throw opkele::exception(OPKELE_CP_ "Please, give me something to resolve");
+ for(int a=1;a<argc;++a) {
+ opkele::idiscovery_t discovery(argv[a]);
+ clog
+ << "===============================================================" << endl
+ << "User-supplied ID: " << argv[a] << endl
+ << "Normalized ID: " << discovery.normalized_id << endl
+ << "Canonicalized ID: " << discovery.canonicalized_id << endl
+ << endl
+ << "CanonicalID: " << discovery.xrd.canonical_ids << endl
+ << "LocalID: " << discovery.xrd.local_ids << endl
+ << "Services: " << discovery.xrd.services << endl;
+ }
+ }catch(exception& e) {
+ cerr << "oops: " << e.what() << endl;
+ _exit(1);
+ }
+ _exit(0);
+}
diff --git a/test/openid_resolve.cc b/test/openid_resolve.cc
deleted file mode 100644
index 31c7a6a..0000000
--- a/test/openid_resolve.cc
+++ b/dev/null
@@ -1,36 +0,0 @@
-#include <iostream>
-#include <stdexcept>
-#include <iterator>
-#include <algorithm>
-using namespace std;
-#include <opkele/exception.h>
-#include <opkele/openid_service_resolver.h>
-
-int main(int argc,char **argv) {
- try {
- if(argc<2)
- throw opkele::exception(OPKELE_CP_ "Please, give me something to resolve");
- opkele::openid_service_resolver_t resolver;
- for(int a=1;a<argc;++a) {
- const opkele::openid_auth_info_t& iai = resolver.resolve(argv[a]);
- clog
- << "====================" << endl
- << "canonical id is " << iai.canonical_id << endl
- << endl
- << "service priority is " << iai.auth_SEP.priority << endl
- << "service types are " ;
- copy(
- iai.auth_SEP.xrd_Type.begin(), iai.auth_SEP.xrd_Type.end(),
- ostream_iterator<string>(clog," ") );
- clog << endl
- << "service URI is " << iai.auth_SEP.xrd_URI << endl;
- if(!iai.auth_SEP.openid_Delegate.empty())
- clog << "openid:Delegate is " << iai.auth_SEP.openid_Delegate << endl;
- clog << endl;
- }
- }catch(exception& e) {
- cerr << "oops: " << e.what() << endl;
- _exit(1);
- }
- _exit(0);
-}