File tree Expand file tree Collapse file tree 4 files changed +49
-0
lines changed Expand file tree Collapse file tree 4 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -102,6 +102,14 @@ functions:
102102 method : delete
103103 authorizer : authorizerGithub
104104
105+ whoamiGet :
106+ handler : whoamiGet.default
107+ events :
108+ - http :
109+ path : ' registry/-/whoami'
110+ method : get
111+ authorizer : authorizerGithub
112+
105113 tarGet :
106114 handler : tarGet.default
107115 events :
Original file line number Diff line number Diff line change 1+ export default async ( { requestContext } , _ , callback ) =>
2+ callback ( null , {
3+ statusCode : 200 ,
4+ body : JSON . stringify ( {
5+ username : requestContext . authorizer . username ,
6+ } ) ,
7+ } ) ;
8+
Original file line number Diff line number Diff line change 1+ /* eslint-disable no-underscore-dangle */
2+ import subject from '../../src/whoami/get' ;
3+
4+ describe ( 'GET /registry/-/whoami' , ( ) => {
5+ let event ;
6+ let callback ;
7+
8+ beforeEach ( ( ) => {
9+ callback = stub ( ) ;
10+ } ) ;
11+
12+ describe ( 'whoami' , ( ) => {
13+ beforeEach ( ( ) => {
14+ event = {
15+ requestContext : {
16+ authorizer : {
17+ username : 'foobar' ,
18+ } ,
19+ } ,
20+ } ;
21+ } ) ;
22+
23+ it ( 'should return correct username' , async ( ) => {
24+ await subject ( event , stub ( ) , callback ) ;
25+
26+ assert ( callback . calledWithExactly ( null , {
27+ statusCode : 200 ,
28+ body : '{"username":"foobar"}' ,
29+ } ) ) ;
30+ } ) ;
31+ } ) ;
32+ } ) ;
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ module.exports = {
1313 distTagsDelete : [ './bootstrap' , './src/dist-tags/delete.js' ] ,
1414 userPut : [ './bootstrap' , './src/user/put.js' ] ,
1515 userDelete : [ './bootstrap' , './src/user/delete.js' ] ,
16+ whoamiGet : [ './bootstrap' , './src/whoami/get.js' ] ,
1617 tarGet : [ './bootstrap' , './src/tar/get.js' ] ,
1718 } ,
1819 output : {
You can’t perform that action at this time.
0 commit comments