Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix slow auth tests #142

Closed
wants to merge 53 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
a6c18f1
fix: fix slow auth tests
CodeItQuick Oct 10, 2020
06d63f2
fix: extra file in here not needed that has changes
CodeItQuick Oct 10, 2020
71d474d
fix: extra file in here not needed that has changes
CodeItQuick Oct 10, 2020
f635102
fix: added additional assert
CodeItQuick Oct 10, 2020
999a23c
fix: remove console log
CodeItQuick Oct 10, 2020
4b0a98b
fix: typescript and linting errors
CodeItQuick Oct 10, 2020
1bb7751
fix: fixing DI
CodeItQuick Oct 10, 2020
f6f5bf2
fix: fixing DI
CodeItQuick Oct 10, 2020
ac04de1
fix: fixing test
CodeItQuick Oct 11, 2020
c86e98f
fix: fixed a buncha tests
CodeItQuick Oct 11, 2020
a7f75bb
fix: fixed a buncha tests
CodeItQuick Oct 11, 2020
78c45d2
fix: fixed a buncha tests
CodeItQuick Oct 11, 2020
bb8fe22
fix: fixed a buncha tests
CodeItQuick Oct 11, 2020
20c2c27
fix: fixed a buncha tests
CodeItQuick Oct 11, 2020
6e3ddb9
fix: fixed a buncha tests
CodeItQuick Oct 11, 2020
eb4f57f
fix: fixed a buncha tests
CodeItQuick Oct 11, 2020
ddcfac3
fix: all the tests should pass now
CodeItQuick Oct 11, 2020
0789940
Merge branch 'master' into fix/slowAPITests
CodeItQuick Oct 11, 2020
5b22c8e
fix: all the tests should pass now again
CodeItQuick Oct 11, 2020
6558253
fix: remove cacheing to see if it fixes yarn issues
CodeItQuick Oct 11, 2020
fe1c96e
fix: fixing RefreshToken which I think broke
CodeItQuick Oct 11, 2020
9c1e8e1
fix: git workflows issues
CodeItQuick Oct 11, 2020
2d919e7
fix: git workflows issues
CodeItQuick Oct 11, 2020
1159a40
fix: git workflows issues
CodeItQuick Oct 11, 2020
ece5cb7
fix: git workflows issues
CodeItQuick Oct 11, 2020
896e24e
fix: git workflows issues
CodeItQuick Oct 11, 2020
b0b9464
fix: git workflows issues
CodeItQuick Oct 11, 2020
287493a
fix: needed a before for noc
CodeItQuick Oct 11, 2020
ee27936
fix: needed a before for noc
CodeItQuick Oct 11, 2020
36fe9cb
fix: fix workflow
CodeItQuick Oct 11, 2020
44a3b2c
fix: fix workflow
CodeItQuick Oct 11, 2020
151eef4
fix: fix workflow
CodeItQuick Oct 11, 2020
ed8918b
fix: fix workflow
CodeItQuick Oct 11, 2020
8d68d89
fix: fix workflow
CodeItQuick Oct 11, 2020
099432f
fix: fix nock
CodeItQuick Oct 11, 2020
e2853c0
fix: fix nock
CodeItQuick Oct 11, 2020
c6e52a5
fix: fix nock
CodeItQuick Oct 11, 2020
3a31b6f
fix: fix nock
CodeItQuick Oct 11, 2020
0c29967
fix: fix nock
CodeItQuick Oct 11, 2020
caca12d
fix: fix nock
CodeItQuick Oct 11, 2020
a557ff3
fix: fix nock
CodeItQuick Oct 11, 2020
efb3ab4
fix: fix nock
CodeItQuick Oct 11, 2020
5faaaac
fix: fix nock
CodeItQuick Oct 11, 2020
0170593
fix: fix nock
CodeItQuick Oct 11, 2020
979aa83
fix: fix nock
CodeItQuick Oct 11, 2020
2a54796
fix: fix nock
CodeItQuick Oct 11, 2020
047a190
fix: added dummy file to trigger rerun
CodeItQuick Oct 11, 2020
26d5435
fix: removed dummy txt
CodeItQuick Oct 11, 2020
4160aa7
fix: added dummy file to trigger rerun
CodeItQuick Oct 11, 2020
d4a3d41
fix: fix workflow
CodeItQuick Oct 11, 2020
bd8d3ea
fix: fixing gha workflow
CodeItQuick Oct 13, 2020
9059a8b
fix: fixing gha workflow
CodeItQuick Oct 13, 2020
74ad60c
fix: fixing gha workflow
CodeItQuick Oct 13, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/helpers/RefreshToken.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
import RefreshToken from './RefreshToken'
import nock from 'nock'
import axios from 'axios'

require('dotenv').config()
const clientId = 'user_id'
const clientSecret = 'client_secret'
const refreshToken = 'refresh_token'

axios.defaults.adapter = require('axios/lib/adapters/http')
describe('RefreshToken', () => {
it('Gets auth correctly', async () => {
const auth = await RefreshToken()
nock('https://id.twitch.tv')
.post(
`/oauth2/token?grant_type=refresh_token&refresh_token=${refreshToken}&client_id=${clientId}&client_secret=${clientSecret}`
)
.reply(200, {
access_token: 'dummy_string',
})
.persist()
const auth = await RefreshToken({ refreshToken, clientId, clientSecret })
expect(auth).toHaveProperty('clientId')
expect(auth.clientId).toBe('user_id')
})
})
18 changes: 14 additions & 4 deletions src/helpers/RefreshToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,21 @@ import { AuthProvider, StaticAuthProvider } from 'twitch/lib'
import { error } from 'console'
require('dotenv').config()

export default async (): Promise<AuthProvider> => {
const clientId = process.env.USER_ID || ''
const clientSecret = process.env.SECRET || ''
const refreshToken = process.env.REFRESH_TOKEN || ''
const client_id = process.env.USER_ID || ''
const client_secret = process.env.SECRET || ''
const refresh_token = process.env.REFRESH_TOKEN || ''

interface IAuthRequest {
clientId: string
clientSecret: string
refreshToken: string
}

export default async ({
clientId = client_id,
clientSecret = client_secret,
refreshToken = refresh_token,
}: IAuthRequest): Promise<AuthProvider> => {
CodeItQuick marked this conversation as resolved.
Show resolved Hide resolved
if (!clientId.length || !clientSecret.length || !refreshToken.length) {
throw error('env not loading properly')
}
Expand Down
19 changes: 19 additions & 0 deletions wallaby.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = function(wallaby) {
return {
// tell wallaby to use automatic configuration
autoDetect: true,

files: [
{ pattern: 'src/**/*.ts*', load: false },
'!src/**/*.test.ts',
'!semantic/**/*',
'!node_modules/**/*'
],

tests: [ 'src/**/*.test.ts' ],

testFramework: 'jest',

env: { type: 'node' }
};
};