File tree Expand file tree Collapse file tree 3 files changed +65
-1
lines changed Expand file tree Collapse file tree 3 files changed +65
-1
lines changed Original file line number Diff line number Diff line change @@ -550,6 +550,19 @@ An object containing information of new pull request
550550#### Expected Response
5515511 . Pull request object
552552
553+ #### isEnterpriseUser
554+ Required parameters:
555+
556+ | Parameter | Type | Description |
557+ | :------------- | :---- | :-------------|
558+ | config | Object | The config object |
559+ | config.token | String | The github token to interact with the graphql api |
560+ | config.slug | String | The github enterprise slug |
561+ | config.login | String | The github user's login name |
562+
563+ #### Expected Outcome
564+ 1 . Returns True or False
565+
553566## Extending
554567To make use of the validation functions, the functions to override are:
555568
@@ -579,7 +592,8 @@ To make use of the validation functions, the functions to override are:
5795921 . ` _getBranchList `
5805931 . ` _openPr `
5815941 . ` getDisplayName ` (overriding needs only the case of ` scm-router ` )
582- 1 . ` getReadOnlyInfo ` (overriding needs only the case of ` scm-router ` )
595+ 1 . ` getReadOnlyInfo ` (overriding needs only the case of ` scm-router ` )
596+ 1 . ` _isEnterpriseUser `
583597
584598
585599``` js
Original file line number Diff line number Diff line change @@ -709,6 +709,29 @@ class ScmBase {
709709 _openPr ( ) {
710710 return Promise . reject ( new Error ( 'Not implemented' ) ) ;
711711 }
712+
713+ /**
714+ * check if scm user is a member of an enterprise
715+ * @method isEnterpriseUser
716+ * @param {Object } config The configuration object
717+ * @param {String } config.token The token used to authenticate to the SCM
718+ * @param {String } config.slug The slug of the enterprise
719+ * @param {String } config.login The login of the Github user
720+ * @return {Promise } Resolves when operation completed without failure
721+ * @return {Boolean } True if user is a member of an enterprise
722+ * False if user is not a member of an enterprise
723+ */
724+ isEnterpriseUser ( config ) {
725+ return this . _isEnterpriseUser ( config ) ;
726+ }
727+
728+ /**
729+ * Abstract method to return false for non enterprise scm users
730+ * @returns False
731+ */
732+ _isEnterpriseUser ( ) {
733+ return Promise . resolve ( false ) ;
734+ }
712735}
713736
714737module . exports = ScmBase ;
Original file line number Diff line number Diff line change @@ -1326,4 +1326,31 @@ describe('index test', () => {
13261326 assert . strictEqual ( err . message , 'Not implemented' ) ;
13271327 } ) ) ;
13281328 } ) ;
1329+
1330+ describe ( 'isEnterpriseUser' , ( ) => {
1331+ const config = {
1332+ scmContext : 'github:github.com' ,
1333+ token
1334+ } ;
1335+
1336+ it ( 'returns data from underlying method' , ( ) => {
1337+ instance . _isEnterpriseUser = ( ) => Promise . resolve ( true ) ;
1338+
1339+ return instance . isEnterpriseUser ( config ) . then ( output => {
1340+ assert . deepEqual ( output , true ) ;
1341+ } ) ;
1342+ } ) ;
1343+
1344+ it ( 'does not throw error when not implemented' , ( ) => {
1345+ instance
1346+ . isEnterpriseUser ( config )
1347+ . then ( output => {
1348+ assert . equal ( output , false ) ;
1349+ } )
1350+ . catch ( err => {
1351+ // does not reach here
1352+ assert . strictEqual ( err . message , 'Not implemented' ) ;
1353+ } ) ;
1354+ } ) ;
1355+ } ) ;
13291356} ) ;
You can’t perform that action at this time.
0 commit comments