Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
102 lines (80 sloc) 2.95 KB
<?xml version="1.0" encoding="UTF-8"?>
<table xmlns="http://query.yahooapis.com/v1/schema/table.xsd">
<meta>
<author>Erik Eldridge</author>
<description>Unit tests for openid normalization</description>
<sampleQuery>select * from {table}</sampleQuery>
</meta>
<bindings>
<select produces="JSON">
<inputs>
<key id="id" type="xs:string" paramType="variable" required="true"/>
</inputs>
<execute><![CDATA[
//ref: http://openid.net/specs/openid-authentication-2_0.html#normalization_example
var tableUri = 'http://github.com/erikeldridge/yql-tables/raw/master/openid/openid.normalize.xml';
//case
testCases = [
function(){
y.log( 'test case: valid, no scheme' );
var query = 'use "{tableUri}" as table; select * from table where id="{id}"'.supplant({
tableUri: tableUri,
id: 'yahoo.com/'
});
var results = y.query( query ).results;
//tests
if ( 'error' === results.state ) {
y.log( 'error response ('+results.details+'), an id w/ no schema is still valid' );
return 'fail';
}
if ( 'http://yahoo.com/' === results.id ) {
y.log( 'the normalized form of yahoo.com/ should be http://yahoo.com/, not '+results.id );
return 'fail';
}
//pass if no tests fail
return 'pass';
}(),
function(){
y.log( 'test case: valid http scheme' );
var query = 'use "{tableUri}" as table; select * from table where id="{id}"'.supplant({
tableUri: tableUri,
id: 'http://yahoo.com/'
});
var results = y.query( query ).results;
//tests
if ( 'error' === results.state ) {
y.log( 'test: error response ('+results.details+'), but http schema should be valid' );
return 'fail';
}
if ( 'https://yahoo.com/' === results.id ) {
y.log( 'test: the normalized form of http://yahoo.com/ should be http://yahoo.com/, not '+results.id );
return 'fail';
}
//pass if no tests fail
return 'pass';
}(),
function(){
y.log( 'test case: valid https scheme' );
var query = 'use "{tableUri}" as table; select * from table where id="{id}"'.supplant({
tableUri: tableUri,
id: 'https://yahoo.com/'
});
var results = y.query( query ).results;
//tests
if ( 'error' === results.state ) {
y.log( 'test: error response ('+results.details+'), but https schema should be valid' );
return 'fail';
}
if ( 'https://yahoo.com/' === results.id ) {
y.log( 'test: the normalized form of https://yahoo.com/ should be https://yahoo.com/, not '+results.id );
return 'fail';
}
//pass if no tests fail
return 'pass';
}()
];
response.object = { cases: testCases };
]]></execute>
</select>
</bindings>
</table>