File tree 4 files changed +32
-1
lines changed
4 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -133,4 +133,14 @@ describe('OAuth', function() {
133
133
done ( ) ;
134
134
} )
135
135
} ) ;
136
+
137
+ it ( "Should fail with missing options" , ( done ) => {
138
+ var options = undefined ;
139
+ try {
140
+ new OAuth ( options ) ;
141
+ } catch ( error ) {
142
+ jequal ( error . message , 'No options passed to OAuth' ) ;
143
+ done ( ) ;
144
+ }
145
+ } ) ;
136
146
} ) ;
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ describe('Twitter Auth', () => {
9
9
consumer_key : 'hello'
10
10
} , {
11
11
consumer_key : 'world'
12
- } ] ) . consumer_key ) . toEqual ( 'hello' )
12
+ } ] ) . consumer_key ) . toEqual ( 'hello' ) ;
13
13
14
14
// Multiple options, consumer_key not found
15
15
expect ( function ( ) {
@@ -47,4 +47,18 @@ describe('Twitter Auth', () => {
47
47
consumer_key : 'hello'
48
48
} ) . consumer_key ) . toEqual ( 'hello' ) ;
49
49
} ) ;
50
+
51
+ it ( "Should fail with missing options" , ( done ) => {
52
+ try {
53
+ twitter . validateAuthData ( {
54
+ consumer_key : 'key' ,
55
+ consumer_secret : 'secret' ,
56
+ auth_token : 'token' ,
57
+ auth_token_secret : 'secret'
58
+ } , undefined ) ;
59
+ } catch ( error ) {
60
+ jequal ( error . message , 'Twitter auth configuration missing' ) ;
61
+ done ( ) ;
62
+ }
63
+ } ) ;
50
64
} ) ;
Original file line number Diff line number Diff line change 1
1
var https = require ( 'https' ) ,
2
2
crypto = require ( 'crypto' ) ;
3
+ var Parse = require ( 'parse/node' ) . Parse ;
3
4
4
5
var OAuth = function ( options ) {
6
+ if ( ! options ) {
7
+ throw new Parse . Error ( Parse . Error . INTERNAL_SERVER_ERROR , 'No options passed to OAuth' ) ;
8
+ }
5
9
this . consumer_key = options . consumer_key ;
6
10
this . consumer_secret = options . consumer_secret ;
7
11
this . auth_token = options . auth_token ;
Original file line number Diff line number Diff line change @@ -5,6 +5,9 @@ var logger = require('../../logger').default;
5
5
6
6
// Returns a promise that fulfills iff this user id is valid.
7
7
function validateAuthData ( authData , options ) {
8
+ if ( ! options ) {
9
+ throw new Parse . Error ( Parse . Error . INTERNAL_SERVER_ERROR , 'Twitter auth configuration missing' ) ;
10
+ }
8
11
options = handleMultipleConfigurations ( authData , options ) ;
9
12
var client = new OAuth ( options ) ;
10
13
client . host = "api.twitter.com" ;
You can’t perform that action at this time.
0 commit comments