summaryrefslogtreecommitdiffabout
path: root/test/RP.cc
authorMichael Krelin <hacker@klever.net>2008-02-11 21:16:26 (UTC)
committer Michael Krelin <hacker@klever.net>2008-02-11 21:16:26 (UTC)
commit947098ee2ab09c340e6822f2bfce7570388c86b4 (patch) (unidiff)
treebcf221248e6196ce39b073866727b55e56c2dd57 /test/RP.cc
parent4cd6cad3b5fda6eb09c8c36efeb9426316f35a37 (diff)
downloadlibopkele-947098ee2ab09c340e6822f2bfce7570388c86b4.zip
libopkele-947098ee2ab09c340e6822f2bfce7570388c86b4.tar.gz
libopkele-947098ee2ab09c340e6822f2bfce7570388c86b4.tar.bz2
removed obsoleted functions in test RP
Signed-off-by: Michael Krelin <hacker@klever.net>
Diffstat (limited to 'test/RP.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--test/RP.cc28
1 files changed, 0 insertions, 28 deletions
diff --git a/test/RP.cc b/test/RP.cc
index 99a792c..813b9b7 100644
--- a/test/RP.cc
+++ b/test/RP.cc
@@ -206,124 +206,96 @@ class example_rp_t : public opkele::prequeue_RP {
206 as_id,ordinal++, 206 as_id,ordinal++,
207 ep.uri.c_str(),ep.claimed_id.c_str(),ep.local_id.c_str()); 207 ep.uri.c_str(),ep.claimed_id.c_str(),ep.local_id.c_str());
208 db.exec(S); 208 db.exec(S);
209 } 209 }
210 210
211 mutable openid_endpoint_t eqtop; 211 mutable openid_endpoint_t eqtop;
212 mutable bool have_eqtop; 212 mutable bool have_eqtop;
213 213
214 const openid_endpoint_t& get_endpoint() const { 214 const openid_endpoint_t& get_endpoint() const {
215 assert(as_id>=0); 215 assert(as_id>=0);
216 if(!have_eqtop) { 216 if(!have_eqtop) {
217 sqlite3_mem_t<char*> 217 sqlite3_mem_t<char*>
218 S = sqlite3_mprintf( 218 S = sqlite3_mprintf(
219 "SELECT" 219 "SELECT"
220 " eq_uri, eq_claimed_id, eq_local_id" 220 " eq_uri, eq_claimed_id, eq_local_id"
221 " FROM endpoints_queue" 221 " FROM endpoints_queue"
222 " JOIN auth_sessions USING(as_id)" 222 " JOIN auth_sessions USING(as_id)"
223 " WHERE hts_id=%Q AND as_id=%ld" 223 " WHERE hts_id=%Q AND as_id=%ld"
224 " ORDER BY eq_ctime,eq_ordinal" 224 " ORDER BY eq_ctime,eq_ordinal"
225 " LIMIT 1",htc.get_value().c_str(),as_id); 225 " LIMIT 1",htc.get_value().c_str(),as_id);
226 sqlite3_table_t T; int nr,nc; 226 sqlite3_table_t T; int nr,nc;
227 db.get_table(S,T,&nr,&nc); 227 db.get_table(S,T,&nr,&nc);
228 if(nr<1) 228 if(nr<1)
229 throw opkele::exception(OPKELE_CP_ "No more endpoints queued"); 229 throw opkele::exception(OPKELE_CP_ "No more endpoints queued");
230 assert(nr==1); assert(nc==3); 230 assert(nr==1); assert(nc==3);
231 eqtop.uri = T.get(1,0,nc); 231 eqtop.uri = T.get(1,0,nc);
232 eqtop.claimed_id = T.get(1,1,nc); 232 eqtop.claimed_id = T.get(1,1,nc);
233 eqtop.local_id = T.get(1,2,nc); 233 eqtop.local_id = T.get(1,2,nc);
234 have_eqtop = true; 234 have_eqtop = true;
235 } 235 }
236 return eqtop; 236 return eqtop;
237 } 237 }
238 238
239 void next_endpoint() { 239 void next_endpoint() {
240 assert(as_id>=0); 240 assert(as_id>=0);
241 get_endpoint(); 241 get_endpoint();
242 have_eqtop = false; 242 have_eqtop = false;
243 sqlite3_mem_t<char*> S = sqlite3_mprintf( 243 sqlite3_mem_t<char*> S = sqlite3_mprintf(
244 "DELETE FROM endpoints_queue" 244 "DELETE FROM endpoints_queue"
245 " WHERE as_id=%ld AND eq_uri=%Q AND eq_local_id=%Q", 245 " WHERE as_id=%ld AND eq_uri=%Q AND eq_local_id=%Q",
246 htc.get_value().c_str(),as_id, 246 htc.get_value().c_str(),as_id,
247 eqtop.uri.c_str()); 247 eqtop.uri.c_str());
248 db.exec(S); 248 db.exec(S);
249 } 249 }
250 250
251 mutable string _cid; 251 mutable string _cid;
252 mutable string _nid; 252 mutable string _nid;
253 253
254 void set_claimed_id(const string& cid) {
255 assert(as_id>=0);
256 sqlite3_mem_t<char*> S = sqlite3_mprintf(
257 "UPDATE auth_sessions"
258 " SET as_claimed_id=%Q"
259 " WHERE hts_id=%Q and as_id=%ld",
260 cid.c_str(),
261 htc.get_value().c_str(),as_id);
262 db.exec(S);
263 _cid = cid;
264 }
265 const string get_claimed_id() const {
266 assert(as_id>=0);
267 if(_cid.empty()) {
268 sqlite3_mem_t<char*> S = sqlite3_mprintf(
269 "SELECT as_claimed_id"
270 " FROM"
271 " auth_sessions"
272 " WHERE"
273 " hts_id=%Q AND as_id=%ld",
274 htc.get_value().c_str(),as_id);
275 sqlite3_table_t T; int nr,nc;
276 db.get_table(S,T,&nr,&nc);
277 assert(nr==1); assert(nc==1);
278 _cid = T.get(1,0,nc);
279 }
280 return _cid;
281 }
282 void set_normalized_id(const string& nid) { 254 void set_normalized_id(const string& nid) {
283 assert(as_id>=0); 255 assert(as_id>=0);
284 sqlite3_mem_t<char*> S = sqlite3_mprintf( 256 sqlite3_mem_t<char*> S = sqlite3_mprintf(
285 "UPDATE auth_sessions" 257 "UPDATE auth_sessions"
286 " SET as_normalized_id=%Q" 258 " SET as_normalized_id=%Q"
287 " WHERE hts_id=%Q and as_id=%ld", 259 " WHERE hts_id=%Q and as_id=%ld",
288 nid.c_str(), 260 nid.c_str(),
289 htc.get_value().c_str(),as_id); 261 htc.get_value().c_str(),as_id);
290 db.exec(S); 262 db.exec(S);
291 _nid = nid; 263 _nid = nid;
292 } 264 }
293 const string get_normalized_id() const { 265 const string get_normalized_id() const {
294 assert(as_id>=0); 266 assert(as_id>=0);
295 if(_nid.empty()) { 267 if(_nid.empty()) {
296 sqlite3_mem_t<char*> S = sqlite3_mprintf( 268 sqlite3_mem_t<char*> S = sqlite3_mprintf(
297 "SELECT as_normalized_id" 269 "SELECT as_normalized_id"
298 " FROM" 270 " FROM"
299 " auth_sessions" 271 " auth_sessions"
300 " WHERE" 272 " WHERE"
301 " hts_id=%Q AND as_id=%ld", 273 " hts_id=%Q AND as_id=%ld",
302 htc.get_value().c_str(),as_id); 274 htc.get_value().c_str(),as_id);
303 sqlite3_table_t T; int nr,nc; 275 sqlite3_table_t T; int nr,nc;
304 db.get_table(S,T,&nr,&nc); 276 db.get_table(S,T,&nr,&nc);
305 assert(nr==1); assert(nc==1); 277 assert(nr==1); assert(nc==1);
306 _nid = T.get(1,0,nc); 278 _nid = T.get(1,0,nc);
307 } 279 }
308 return _nid; 280 return _nid;
309 } 281 }
310 282
311 const string get_this_url() const { 283 const string get_this_url() const {
312 bool s = gw.has_meta("SSL_PROTOCOL_VERSION"); 284 bool s = gw.has_meta("SSL_PROTOCOL_VERSION");
313 string rv = s?"https://":"http://"; 285 string rv = s?"https://":"http://";
314 rv += gw.http_request_header("Host"); 286 rv += gw.http_request_header("Host");
315 const string& port = gw.get_meta("SERVER_PORT"); 287 const string& port = gw.get_meta("SERVER_PORT");
316 if( port!=(s?"443":"80") ) { 288 if( port!=(s?"443":"80") ) {
317 rv += ':'; rv += port; 289 rv += ':'; rv += port;
318 } 290 }
319 rv += gw.get_meta("REQUEST_URI"); 291 rv += gw.get_meta("REQUEST_URI");
320 return rv; 292 return rv;
321 } 293 }
322 294
323 void initiate(const string& usi) { 295 void initiate(const string& usi) {
324 allocate_asid(); 296 allocate_asid();
325 prequeue_RP::initiate(usi); 297 prequeue_RP::initiate(usi);
326 } 298 }
327 299
328 string get_self_url() const { 300 string get_self_url() const {
329 string rv = get_this_url(); 301 string rv = get_this_url();