@@ -48,94 +48,4 @@ describe('OAuth endpoints initialization', function() {
48
48
method : 'GET'
49
49
} ) ;
50
50
} ) ;
51
-
52
- it ( 'OAuth.initEndpoint should initialize a POST endpoint for the access_token on /oauth/authenticate' , function ( ) {
53
- values . OAuth . initEndpoints ( values . express_app ) ;
54
- var endpoint = values . express_app . getEndpoint ( 'POST /oauth/authenticate' ) ;
55
- expect ( endpoint ) . toBeDefined ;
56
- expect ( endpoint . length ) . toBeDefined ( ) ;
57
- expect ( endpoint . length ) . toBe ( 1 ) ;
58
- } ) ;
59
-
60
- it ( 'The generated endpoint /oauth/authenticate should authenticate on oauth.io.' , function ( done ) {
61
- values . OAuth . initEndpoints ( values . express_app ) ;
62
- values . OAuth . generateStateToken ( values . express_app . req ) ;
63
- var endpoint = values . express_app . getEndpoint ( 'POST /oauth/authenticate' ) ;
64
- expect ( endpoint ) . toBeDefined ( ) ;
65
-
66
- var calls_done = function ( status , result ) {
67
- expect ( status ) . toBe ( 200 ) ;
68
- expect ( typeof result ) . toBe ( 'string' ) ;
69
- expect ( result ) . toBeDefined ( ) ;
70
- expect ( result ) . toBe ( 'Successfully authenticated' ) ;
71
- done ( ) ;
72
- } ;
73
-
74
- values . express_app . addSendHandler ( function ( ) {
75
- var params = Array . prototype . slice . call ( arguments ) ;
76
- calls_done . apply ( this , params ) ;
77
- } ) ;
78
-
79
- var scope = nock ( 'https://oauth.io' )
80
- . post ( '/auth/access_token' , {
81
- code : 'somecode' ,
82
- key : 'somekey' ,
83
- secret : 'somesecret'
84
- } )
85
- . reply ( 200 , {
86
- access_token : 'result_access_token' ,
87
- expires_in : 'someday' ,
88
- request : { } ,
89
- state : 'unique_id' ,
90
- provider : 'facebook'
91
- } ) ;
92
-
93
- values . express_app . callEndpoint ( '/oauth/authenticate' , {
94
- method : 'POST' ,
95
- body : qs . stringify ( {
96
- code : 'somecode'
97
- } )
98
- } ) ;
99
- } ) ;
100
-
101
- it ( 'The generated endpoint /oauth/authenticate should throw 400 An error occured during authentication on error' , function ( done ) {
102
- values . OAuth . initEndpoints ( values . express_app ) ;
103
- values . OAuth . generateStateToken ( values . express_app . req ) ;
104
- var endpoint = values . express_app . getEndpoint ( 'POST /oauth/authenticate' ) ;
105
- expect ( endpoint ) . toBeDefined ( ) ;
106
-
107
- var calls_done = function ( status , result ) {
108
- expect ( status ) . toBe ( 400 ) ;
109
- expect ( typeof result ) . toBe ( 'string' ) ;
110
- expect ( result ) . toBeDefined ( ) ;
111
- expect ( result ) . toBe ( 'An error occured during authentication' ) ;
112
- done ( ) ;
113
- } ;
114
-
115
- values . express_app . addSendHandler ( function ( ) {
116
- var params = Array . prototype . slice . call ( arguments ) ;
117
- calls_done . apply ( this , params ) ;
118
- } ) ;
119
-
120
- var scope = nock ( 'https://oauth.io' )
121
- . post ( '/auth/access_token' , {
122
- code : 'somecode' ,
123
- key : 'somekey' ,
124
- secret : 'somesecret'
125
- } )
126
- . reply ( 400 , {
127
- access_token : 'result_access_token' ,
128
- expires_in : 'someday' ,
129
- request : { } ,
130
- provider : 'facebook'
131
- } ) ;
132
-
133
- values . express_app . callEndpoint ( '/oauth/authenticate' , {
134
- method : 'POST' ,
135
- body : qs . stringify ( {
136
- code : 'somecode'
137
- } )
138
- } ) ;
139
- } ) ;
140
-
141
51
} ) ;
0 commit comments