| (function() { | ||
| var bilby, should, truth; | ||
| bilby = require('bilby'); | ||
| should = require('should'); | ||
| truth = require('./truth'); | ||
| describe('truth', function() { | ||
| describe('existy()', function() { | ||
| it('should return false if null', function() { | ||
| return truth.existy(null).should.be["false"]; | ||
| }); | ||
| it('should return true if 0', function() { | ||
| return truth.existy(0).should.be["true"]; | ||
| }); | ||
| it('should return true if an empty string', function() { | ||
| return truth.existy('').should.be["true"]; | ||
| }); | ||
| it('should return true if an empty array', function() { | ||
| return truth.existy([]).should.be["true"]; | ||
| }); | ||
| it('should return true if an empty object', function() { | ||
| return truth.existy({}).should.be["true"]; | ||
| }); | ||
| it('should return true if true', function() { | ||
| return truth.existy(true).should.be["true"]; | ||
| }); | ||
| return it('should return true if false', function() { | ||
| return truth.existy(false).should.be["true"]; | ||
| }); | ||
| }); | ||
| describe('truthy()', function() { | ||
| it('should return false if null', function() { | ||
| return truth.truthy(null).should.be["false"]; | ||
| }); | ||
| it('should return true if 0', function() { | ||
| return truth.truthy(0).should.be["true"]; | ||
| }); | ||
| it('should return true if an empty string', function() { | ||
| return truth.truthy('').should.be["true"]; | ||
| }); | ||
| it('should return true if an empty array', function() { | ||
| return truth.truthy([]).should.be["true"]; | ||
| }); | ||
| it('should return true if an empty object', function() { | ||
| return truth.truthy({}).should.be["true"]; | ||
| }); | ||
| it('should return true if true', function() { | ||
| return truth.truthy(true).should.be["true"]; | ||
| }); | ||
| return it('should return false if false', function() { | ||
| return truth.truthy(false).should.be["false"]; | ||
| }); | ||
| }); | ||
| describe('lengthy()', function() { | ||
| it('should return false if null', function() { | ||
| return truth.lengthy(null).should.be["false"]; | ||
| }); | ||
| it('should return false if 0', function() { | ||
| return truth.lengthy(0).should.be["false"]; | ||
| }); | ||
| it('should return false if an empty string', function() { | ||
| return truth.lengthy('').should.be["false"]; | ||
| }); | ||
| it('should return false if an empty array', function() { | ||
| return truth.lengthy([]).should.be["false"]; | ||
| }); | ||
| it('should return false if an empty object', function() { | ||
| return truth.lengthy({}).should.be["false"]; | ||
| }); | ||
| it('should return false if true', function() { | ||
| return truth.lengthy(true).should.be["false"]; | ||
| }); | ||
| it('should return false if false', function() { | ||
| return truth.lengthy(false).should.be["false"]; | ||
| }); | ||
| it('should return true if a non-empty string', function() { | ||
| return truth.lengthy('non').should.be["true"]; | ||
| }); | ||
| it('should return true if a non-empty array', function() { | ||
| return truth.lengthy('non').should.be["true"]; | ||
| }); | ||
| return it('should return false if a non-empty object', function() { | ||
| return truth.lengthy({ | ||
| non: 'non' | ||
| }).should.be["false"]; | ||
| }); | ||
| }); | ||
| describe('environmenty()', function() { | ||
| it('should return true when valid', function() { | ||
| return truth.environmenty(bilby.environment()).should.be["true"]; | ||
| }); | ||
| return it('should return false when invalid', function() { | ||
| return truth.environmenty({}).should.be["false"]; | ||
| }); | ||
| }); | ||
| describe('toolcontexty()', function() { | ||
| it('should return true when valid', function() { | ||
| var context; | ||
| context = bilby.environment().property('consumerKey', null).property('consumerSecret', null).property('utcOffset', null).property('host', null).property('path', null).property('port', null); | ||
| return truth.toolcontexty(context).should.be["true"]; | ||
| }); | ||
| return it('should return false when invalid', function() { | ||
| return truth.toolcontexty({}).should.be["false"]; | ||
| }); | ||
| }); | ||
| describe('toolparametery()', function() { | ||
| it('should return true when valid', function() { | ||
| var param; | ||
| param = bilby.environment().property('lti_message_type', null).property('lti_version', null).property('resource_link_id', null); | ||
| return truth.toolparametery(param).should.be["true"]; | ||
| }); | ||
| return it('should return false when invalid', function() { | ||
| return truth.toolcontexty({}).should.be["false"]; | ||
| }); | ||
| }); | ||
| return describe('toolquerystringy()', function() { | ||
| it('should return true when valid', function() { | ||
| return truth.toolquerystringy(bilby.environment()).should.be["true"]; | ||
| }); | ||
| return it('should return false when invalid', function() { | ||
| return truth.toolquerystringy({}).should.be["false"]; | ||
| }); | ||
| }); | ||
| }); | ||
| }).call(this); |
| bilby = require('bilby') | ||
| should = require('should') | ||
| truth = require('./truth') | ||
| describe('truth', -> | ||
| describe('existy()', -> | ||
| it('should return false if null', -> truth.existy(null).should.be.false) | ||
| it('should return true if 0', -> truth.existy(0).should.be.true) | ||
| it('should return true if an empty string', -> truth.existy('').should.be.true) | ||
| it('should return true if an empty array', -> truth.existy([]).should.be.true) | ||
| it('should return true if an empty object', -> truth.existy({}).should.be.true) | ||
| it('should return true if true', -> truth.existy(true).should.be.true) | ||
| it('should return true if false', -> truth.existy(false).should.be.true) | ||
| ) | ||
| describe('truthy()', -> | ||
| it('should return false if null', -> truth.truthy(null).should.be.false) | ||
| it('should return true if 0', -> truth.truthy(0).should.be.true) | ||
| it('should return true if an empty string', -> truth.truthy('').should.be.true) | ||
| it('should return true if an empty array', -> truth.truthy([]).should.be.true) | ||
| it('should return true if an empty object', -> truth.truthy({}).should.be.true) | ||
| it('should return true if true', -> truth.truthy(true).should.be.true) | ||
| it('should return false if false', -> truth.truthy(false).should.be.false) | ||
| ) | ||
| describe('lengthy()', -> | ||
| it('should return false if null', -> truth.lengthy(null).should.be.false) | ||
| it('should return false if 0', -> truth.lengthy(0).should.be.false) | ||
| it('should return false if an empty string', -> truth.lengthy('').should.be.false) | ||
| it('should return false if an empty array', -> truth.lengthy([]).should.be.false) | ||
| it('should return false if an empty object', -> truth.lengthy({}).should.be.false) | ||
| it('should return false if true', -> truth.lengthy(true).should.be.false) | ||
| it('should return false if false', -> truth.lengthy(false).should.be.false) | ||
| it('should return true if a non-empty string', -> truth.lengthy('non').should.be.true) | ||
| it('should return true if a non-empty array', -> truth.lengthy('non').should.be.true) | ||
| it('should return false if a non-empty object', -> truth.lengthy({non: 'non'}).should.be.false) | ||
| ) | ||
| describe('environmenty()', -> | ||
| it('should return true when valid', -> truth.environmenty(bilby.environment()).should.be.true) | ||
| it('should return false when invalid', -> truth.environmenty({}).should.be.false) | ||
| ) | ||
| describe('toolcontexty()', -> | ||
| it('should return true when valid', -> | ||
| context = bilby.environment() | ||
| .property('consumerKey', null) | ||
| .property('consumerSecret', null) | ||
| .property('utcOffset', null) | ||
| .property('host', null) | ||
| .property('path', null) | ||
| .property('port', null) | ||
| truth.toolcontexty(context).should.be.true | ||
| ) | ||
| it('should return false when invalid', -> truth.toolcontexty({}).should.be.false) | ||
| ) | ||
| describe('toolparametery()', -> | ||
| it('should return true when valid', -> | ||
| param = bilby.environment() | ||
| .property('lti_message_type', null) | ||
| .property('lti_version', null) | ||
| .property('resource_link_id', null) | ||
| truth.toolparametery(param).should.be.true | ||
| ) | ||
| it('should return false when invalid', -> truth.toolcontexty({}).should.be.false) | ||
| ) | ||
| describe('toolquerystringy()', -> | ||
| it('should return true when valid', -> truth.toolquerystringy(bilby.environment()).should.be.true) | ||
| it('should return false when invalid', -> truth.toolquerystringy({}).should.be.false) | ||
| ) | ||
| ) |
@@ -33,3 +33,3 @@ (function() { | ||
| describe('sign()', function() { | ||
| return it('should return a string based signature', function() { | ||
| it('should return a string based signature', function() { | ||
| var params; | ||
@@ -47,2 +47,16 @@ params = { | ||
| }); | ||
| return it('should throw upon unknown signature method', function() { | ||
| var params; | ||
| params = { | ||
| oauth_callback: 'about:blank', | ||
| oauth_consumer_key: 'oauth_consumer_key', | ||
| oauth_nonce: oauth.nonce(), | ||
| oauth_signature_method: 'pandora', | ||
| oauth_timestamp: Date.now(), | ||
| oauth_version: '1.0' | ||
| }; | ||
| return (function() { | ||
| return oauth.sign('url', params, 'secret'); | ||
| }).should["throw"](); | ||
| }); | ||
| }); | ||
@@ -49,0 +63,0 @@ return describe('authorization()', function() { |
@@ -17,3 +17,3 @@ (function() { | ||
| }), (function(a) { | ||
| return this.truthy(a) && a.hasOwnProperty('length') && a.length > (0 != null); | ||
| return this.truthy(a) && a.hasOwnProperty('length') && a.length > 0; | ||
| })).method('signedOAuthy', (function(a) { | ||
@@ -20,0 +20,0 @@ return true; |
+1
-3
@@ -19,3 +19,2 @@ module.exports = (grunt) -> | ||
| }] | ||
| copy: test: files: ['build/etc/toolconsumer-test.config.json': 'resource/test/json/etc/toolconsumer-test.config.json'] | ||
| mochacov: | ||
@@ -31,7 +30,6 @@ options: | ||
| grunt.loadNpmTasks('grunt-contrib-coffee') | ||
| grunt.loadNpmTasks('grunt-contrib-copy') | ||
| grunt.loadNpmTasks('grunt-mocha-cov') | ||
| grunt.registerTask('default', ['coffee', 'copy']) | ||
| grunt.registerTask('default', ['coffee']) | ||
| grunt.registerTask('test', ['default', 'mochacov:test']) | ||
| grunt.registerTask('travis', ['test', 'mochacov:coverage']) |
+2
-6
@@ -15,3 +15,2 @@ { | ||
| "grunt-contrib-coffee": "0.7.x", | ||
| "grunt-contrib-copy": "0.4.x", | ||
| "grunt-mocha-cov": "0.1.x", | ||
@@ -26,6 +25,3 @@ "mocha": "1.15.x", | ||
| "name": "lti", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git://github.com/rockymadden/lti.js.git" | ||
| }, | ||
| "repository": {"type": "git", "url": "git://github.com/rockymadden/lti.js.git"}, | ||
| "scripts": { | ||
@@ -35,3 +31,3 @@ "blanket": {"pattern": ["build/lib"]}, | ||
| }, | ||
| "version": "0.3.6" | ||
| "version": "0.3.7" | ||
| } |
@@ -14,3 +14,3 @@ bilby = require('bilby') | ||
| ((a) -> true), | ||
| ((a) -> @truthy(a) and a.hasOwnProperty('length') and a.length > 0?) | ||
| ((a) -> @truthy(a) and a.hasOwnProperty('length') and a.length > 0) | ||
| ) | ||
@@ -17,0 +17,0 @@ .method('signedOAuthy', |
@@ -35,2 +35,13 @@ should = require('should') | ||
| ) | ||
| it('should throw upon unknown signature method', -> | ||
| params = | ||
| oauth_callback: 'about:blank' | ||
| oauth_consumer_key: 'oauth_consumer_key' | ||
| oauth_nonce: oauth.nonce() | ||
| oauth_signature_method: 'pandora' | ||
| oauth_timestamp: Date.now() | ||
| oauth_version: '1.0' | ||
| (-> oauth.sign('url', params, 'secret')).should.throw() | ||
| ) | ||
| ) | ||
@@ -37,0 +48,0 @@ describe('authorization()', -> |
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
52215
20.46%7
-12.5%41
5.13%637
27.66%