File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -32,6 +32,9 @@ export const config = {
3232 get googleEmailAddress ( ) : string {
3333 return process . env . GOOGLE_EMAIL_ADDRESS ?? ''
3434 } ,
35+ get removeSuspendedUsers ( ) : boolean {
36+ return process . env . REMOVE_SUSPENDED_USERS ?. toLowerCase ( ) === 'true'
37+ } ,
3538}
3639
3740export interface googleCredentials {
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ export async function getGithubUsersFromGoogle(): Promise<Set<string>> {
3737 fields : 'users(customSchemas/Accounts/github(value)),nextPageToken' ,
3838 customFieldMask : 'Accounts' ,
3939 pageToken : pageToken ,
40+ query : config . removeSuspendedUsers ? 'isSuspended=false' : '' ,
4041 } )
4142 pageToken = userList . data . nextPageToken
4243 githubAccounts = new Set ( [ ...githubAccounts , ...formatUserList ( userList . data . users ) ] )
Original file line number Diff line number Diff line change @@ -156,3 +156,28 @@ describe('googleEmailAddress', () => {
156156 expect ( mod . config . googleEmailAddress ) . toStrictEqual ( 'hello' )
157157 } )
158158} )
159+
160+ describe ( 'removeSuspendedUsers' , ( ) => {
161+ beforeEach ( ( ) => {
162+ delete process . env . REMOVE_SUSPENDED_USERS
163+ } )
164+ it ( 'no value' , ( ) => {
165+ expect ( mod . config . removeSuspendedUsers ) . toStrictEqual ( false )
166+ } )
167+ it ( 'invalid value' , ( ) => {
168+ process . env . REMOVE_SUSPENDED_USERS = 'foobar'
169+ expect ( mod . config . removeSuspendedUsers ) . toStrictEqual ( false )
170+ } )
171+ it ( 'false value' , ( ) => {
172+ process . env . REMOVE_SUSPENDED_USERS = 'false'
173+ expect ( mod . config . removeSuspendedUsers ) . toStrictEqual ( false )
174+ } )
175+ it ( 'true value' , ( ) => {
176+ process . env . REMOVE_SUSPENDED_USERS = 'true'
177+ expect ( mod . config . removeSuspendedUsers ) . toStrictEqual ( true )
178+ } )
179+ it ( 'true value mixed case' , ( ) => {
180+ process . env . REMOVE_SUSPENDED_USERS = 'tRuE'
181+ expect ( mod . config . removeSuspendedUsers ) . toStrictEqual ( true )
182+ } )
183+ } )
You can’t perform that action at this time.
0 commit comments