@@ -15,15 +15,11 @@ import type {
1515} from '../../types' ;
1616import * as comms from '../../utils/comms' ;
1717import * as apiClient from '../api/client' ;
18- import type { FetchAuthenticatedUserDetailsQuery } from '../api/graphql/generated/graphql' ;
1918import * as logger from '../logger' ;
2019import type { AuthMethod } from './types' ;
2120import * as authUtils from './utils' ;
2221import { getNewOAuthAppURL , getNewTokenURL } from './utils' ;
2322
24- // FIXME remove type , mock correct client level?
25- type UserDetailsResponse = FetchAuthenticatedUserDetailsQuery [ 'viewer' ] ;
26-
2723const exchangeWebFlowCodeMock = jest . fn ( ) ;
2824jest . mock ( '@octokit/oauth-methods' , ( ) => ( {
2925 ...jest . requireActual ( '@octokit/oauth-methods' ) ,
@@ -118,7 +114,7 @@ describe('renderer/utils/auth/utils.ts', () => {
118114 expect ( openExternalLinkSpy ) . toHaveBeenCalledTimes ( 1 ) ;
119115 expect ( openExternalLinkSpy ) . toHaveBeenCalledWith (
120116 expect . stringContaining (
121- 'https://github.com/login/oauth/authorize?client_id=FAKE_CLIENT_ID_123&scope=read%3Auser%2Cnotifications%2Crepo' ,
117+ 'https://github.com/login/oauth/authorize?allow_signup=false& client_id=FAKE_CLIENT_ID_123&scope=read%3Auser%2Cnotifications%2Crepo' ,
122118 ) ,
123119 ) ;
124120
@@ -132,26 +128,21 @@ describe('renderer/utils/auth/utils.ts', () => {
132128 describe ( 'exchangeAuthCodeForAccessToken' , ( ) => {
133129 const authCode = '123-456' as AuthCode ;
134130
135- it ( 'should get a token' , async ( ) => {
136- exchangeWebFlowCodeMock . mockResolvedValueOnce (
137- Promise . resolve ( {
138- authentication : {
139- token : 'this-is-a-token' ,
140- } ,
141- } ) ,
142- ) ;
131+ it ( 'should exchange auth code for access token' , async ( ) => {
132+ exchangeWebFlowCodeMock . mockResolvedValueOnce ( {
133+ authentication : {
134+ token : 'this-is-a-token' ,
135+ } ,
136+ } ) ;
143137
144138 const res = await authUtils . exchangeAuthCodeForAccessToken ( authCode ) ;
145139
146- expect ( exchangeWebFlowCodeMock ) . toHaveBeenCalledWith (
147- 'https://github.com/login/oauth/access_token' ,
148- 'POST' ,
149- {
150- client_id : 'FAKE_CLIENT_ID_123' ,
151- client_secret : 'FAKE_CLIENT_SECRET_123' ,
152- code : '123-456' ,
153- } ,
154- ) ;
140+ expect ( exchangeWebFlowCodeMock ) . toHaveBeenCalledWith ( {
141+ clientType : 'oauth-app' ,
142+ clientId : 'FAKE_CLIENT_ID_123' ,
143+ clientSecret : 'FAKE_CLIENT_SECRET_123' ,
144+ code : '123-456' ,
145+ } ) ;
155146 expect ( res ) . toBe ( 'this-is-a-token' ) ;
156147 } ) ;
157148 } ) ;
@@ -177,10 +168,7 @@ describe('renderer/utils/auth/utils.ts', () => {
177168 beforeEach ( ( ) => {
178169 fetchAuthenticatedUserDetailsSpy . mockResolvedValue ( {
179170 data : {
180- viewer : {
181- ...mockGitifyUser ,
182- avatarUrl : mockGitifyUser . avatar ,
183- } as UserDetailsResponse ,
171+ viewer : mockGitifyUser ,
184172 } ,
185173 headers : {
186174 'x-oauth-scopes' : Constants . OAUTH_SCOPES . RECOMMENDED . join ( ', ' ) ,
@@ -235,10 +223,7 @@ describe('renderer/utils/auth/utils.ts', () => {
235223 beforeEach ( ( ) => {
236224 fetchAuthenticatedUserDetailsSpy . mockResolvedValue ( {
237225 data : {
238- viewer : {
239- ...mockGitifyUser ,
240- avatarUrl : mockGitifyUser . avatar ,
241- } as UserDetailsResponse ,
226+ viewer : mockGitifyUser ,
242227 } ,
243228 headers : {
244229 'x-github-enterprise-version' : '3.0.0' ,
0 commit comments