Skip to content

Commit

Permalink
document v1 users/resend_confirmation, add tests #427
Browse files Browse the repository at this point in the history
  • Loading branch information
pleary committed Jul 26, 2024
1 parent 6e34837 commit b14ddc8
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/controllers/v1/users_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ const UsersController = class UsersController {
}

static async resendConfirmation( req ) {
if ( !req.userSession ) { throw new Error( 401 ); }
return InaturalistAPI.iNatJSWrap( users.resendConfirmation, req );
}

Expand Down
13 changes: 13 additions & 0 deletions lib/views/swagger_v1.yml.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -1880,6 +1880,19 @@ paths:
description: Returns an empty 200 response on success
404:
description: Specified user does not exist
/users/resend_confirmation:
post:
summary: User Resend Confirmation
description: Resend an email confirmation
consumes:
- application/json
tags:
- Users
security:
- api_token: []
responses:
200:
description: OK
/users/update_session:
put:
summary: User Update Session
Expand Down
26 changes: 26 additions & 0 deletions test/integration/v1/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,4 +394,30 @@ describe( "Users", ( ) => {
.expect( 200, done );
} );
} );

describe( "resend_confirmation", ( ) => {
const currentUser = fixtures.elasticsearch.users.user[0];
const token = jwt.sign( { user_id: currentUser.id },
config.jwtSecret || "secret",
{ algorithm: "HS512" } );

it( "should 401 without auth", function ( done ) {
request( this.app )
.post( "/v1/users/resend_confirmation" )
.expect( 401, done );
} );
it( "should hit the Rails equivalent and return 200", function ( done ) {
const nockScope = nock( "http://localhost:3000" )
.post( "/users/resend_confirmation" )
.reply( 200 );
request( this.app )
.post( "/v1/users/resend_confirmation" )
.set( "Authorization", token )
.expect( ( ) => {
// Raise an exception if the nocked endpoint doesn't get called
nockScope.done( );
} )
.expect( 200, done );
} );
} );
} );

0 comments on commit b14ddc8

Please sign in to comment.