author | Michael Krelin <hacker@klever.net> | 2008-01-20 21:10:23 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2008-01-20 21:10:23 (UTC) |
commit | d16e79b1c792352eade736e7080c401a6c7ace03 (patch) (unidiff) | |
tree | 545a905ab8ef5c2a2135c17d2f949556b354b842 /test/test.cc | |
parent | 9bfb6fadf71c46bf4cb5adabba0c96c32e84c1bc (diff) | |
download | libopkele-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>
-rw-r--r-- | test/test.cc | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/test/test.cc b/test/test.cc index 1a012b5..35f58ab 100644 --- a/test/test.cc +++ b/test/test.cc | |||
@@ -1,9 +1,8 @@ | |||
1 | #include <iostream> | 1 | #include <iostream> |
2 | #include <stdexcept> | 2 | #include <stdexcept> |
3 | using namespace std; | 3 | using namespace std; |
4 | #include <opkele/exception.h> | 4 | #include <opkele/exception.h> |
5 | #include <opkele/consumer.h> | ||
6 | #include <opkele/util.h> | 5 | #include <opkele/util.h> |
7 | 6 | ||
8 | #include "config.h" | 7 | #include "config.h" |
9 | 8 | ||
@@ -12,55 +11,8 @@ class failed_test : public opkele::exception { | |||
12 | failed_test(OPKELE_E_PARS) | 11 | failed_test(OPKELE_E_PARS) |
13 | : exception(OPKELE_E_CONS) { } | 12 | : exception(OPKELE_E_CONS) { } |
14 | }; | 13 | }; |
15 | 14 | ||
16 | class dummy_consumer_t : public opkele::consumer_t { | ||
17 | public: | ||
18 | virtual opkele::assoc_t store_assoc(const string& /* server */,const string& /* handle */,const opkele::secret_t& /* secret */,int /* expires_in */) { | ||
19 | throw opkele::not_implemented(OPKELE_CP_ "Not implemented"); | ||
20 | } | ||
21 | virtual opkele::assoc_t retrieve_assoc(const string& /* server */ ,const string& /* handle */) { | ||
22 | throw opkele::not_implemented(OPKELE_CP_ "Not implemented"); | ||
23 | } | ||
24 | virtual void invalidate_assoc(const string& /* server */,const string& /* handle */) { | ||
25 | throw opkele::not_implemented(OPKELE_CP_ "Not implemented"); | ||
26 | } | ||
27 | }; | ||
28 | |||
29 | |||
30 | void test_retrieve_links(const string& f,bool success,const string& s="",const string& d="") { | ||
31 | dummy_consumer_t dc; | ||
32 | string server, delegate; | ||
33 | try { | ||
34 | dc.retrieve_links("file://" OPKELE_SRC_DIR "/test/html/"+f,server,delegate); | ||
35 | if(!success) | ||
36 | throw failed_test(OPKELE_CP_ "Retrieved links when it shouldn't"); | ||
37 | if(server!=s) | ||
38 | throw failed_test(OPKELE_CP_ "retrieve_links test failed, expected server '"+s+"', got '"+server+"'"); | ||
39 | if(delegate!=d) | ||
40 | throw failed_test(OPKELE_CP_ "retrieve_links test failed, expected delegate '"+d+"', got '"+delegate+"'"); | ||
41 | }catch(opkele::bad_input& obi) { | ||
42 | if(success) | ||
43 | throw failed_test(OPKELE_CP_ "Test '"+f+"' failed due to 'bad_input'["+obi.what()+"]"); | ||
44 | }catch(opkele::failed_assertion& ofa) { | ||
45 | if(success) | ||
46 | throw failed_test(OPKELE_CP_ "Test '"+f+"' failed due to 'failed_assertion'["+ofa.what()+"]"); | ||
47 | } | ||
48 | } | ||
49 | |||
50 | void test_retrieve_links() { | ||
51 | test_retrieve_links("empty.html",false); | ||
52 | test_retrieve_links("in-body.html",false); | ||
53 | test_retrieve_links("head-in-body.html",false); | ||
54 | test_retrieve_links("hkn.html",true,"http://www.klever.net/openid.server","http://hacker.klever.net/"); | ||
55 | test_retrieve_links("hkn-server.html",true,"http://www.klever.net/openid.server"); | ||
56 | test_retrieve_links("hkn-delegate.html",false); | ||
57 | test_retrieve_links("unclosed-head.html",true,"http://www.klever.net/openid.server","http://hacker.klever.net/"); | ||
58 | test_retrieve_links("spaced-links.html",true,"http://www.klever.net/openid.server","http://hacker.klever.net/"); | ||
59 | test_retrieve_links("spaced-link-attrs.html",true,"http://www.klever.net/openid.server","http://hacker.klever.net/"); | ||
60 | test_retrieve_links("2rels.html",true,"http://www.klever.net/openid.server","http://www.klever.net/openid.server"); | ||
61 | } | ||
62 | |||
63 | void test_rfc_3986_normalize_uri(const string &ouri,bool success,const string& nuri="") { | 15 | void test_rfc_3986_normalize_uri(const string &ouri,bool success,const string& nuri="") { |
64 | try { | 16 | try { |
65 | string n = opkele::util::rfc_3986_normalize_uri(ouri); | 17 | string n = opkele::util::rfc_3986_normalize_uri(ouri); |
66 | if(!success) | 18 | if(!success) |
@@ -127,9 +79,8 @@ void test_rfc_3986_normalize_uri() { | |||
127 | 79 | ||
128 | int main() { | 80 | int main() { |
129 | try { | 81 | try { |
130 | test_rfc_3986_normalize_uri(); | 82 | test_rfc_3986_normalize_uri(); |
131 | test_retrieve_links(); | ||
132 | }catch(failed_test& ft) { | 83 | }catch(failed_test& ft) { |
133 | cerr << "Test failed: " << ft.what() << endl; | 84 | cerr << "Test failed: " << ft.what() << endl; |
134 | }catch(exception& e) { | 85 | }catch(exception& e) { |
135 | cerr << "oops: " << e.what() << endl; | 86 | cerr << "oops: " << e.what() << endl; |