mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-12-24 18:51:50 +00:00
Add basic test for auth middlewares ✅
To check for basic mistakes like broken imports, these tests try to create all middlewares (excluding SAML, because that requires a certificate file on disk) Signed-off-by: David Mehren <dmehren1@gmail.com>
This commit is contained in:
parent
3262315248
commit
798586c996
1 changed files with 110 additions and 0 deletions
110
test/auth.ts
Normal file
110
test/auth.ts
Normal file
|
@ -0,0 +1,110 @@
|
|||
import assert from 'assert'
|
||||
import { ImportMock } from 'ts-mock-imports'
|
||||
import * as configModule from '../lib/config'
|
||||
import { DropboxMiddleware } from '../lib/web/auth/dropbox'
|
||||
import { EmailMiddleware } from '../lib/web/auth/email'
|
||||
import { FacebookMiddleware } from '../lib/web/auth/facebook'
|
||||
import { GithubMiddleware } from '../lib/web/auth/github'
|
||||
import { GitlabMiddleware } from '../lib/web/auth/gitlab'
|
||||
import { GoogleMiddleware } from '../lib/web/auth/google'
|
||||
import { LdapMiddleware } from '../lib/web/auth/ldap'
|
||||
import { OAuth2Middleware } from '../lib/web/auth/oauth2'
|
||||
import { OPenIDMiddleware } from '../lib/web/auth/openid'
|
||||
import { TwitterMiddleware } from '../lib/web/auth/twitter'
|
||||
|
||||
describe('AuthMiddlewares', function () {
|
||||
// We currently exclude the SAML Auth, because it needs a certificate file
|
||||
const middlewareList = [{
|
||||
name: 'Facebook',
|
||||
middleware: FacebookMiddleware,
|
||||
config: {
|
||||
facebook: {
|
||||
clientID: 'foobar',
|
||||
clientSecret: 'foobar'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'Twitter',
|
||||
middleware: TwitterMiddleware,
|
||||
config: {
|
||||
twitter: {
|
||||
consumerKey: 'foobar',
|
||||
consumerSecret: 'foobar'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'GitHub',
|
||||
middleware: GithubMiddleware,
|
||||
config: {
|
||||
github: {
|
||||
clientID: 'foobar',
|
||||
clientSecret: 'foobar'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'Gitlab',
|
||||
middleware: GitlabMiddleware,
|
||||
config: {
|
||||
gitlab: {
|
||||
clientID: 'foobar',
|
||||
clientSecret: 'foobar'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'Dropbox',
|
||||
middleware: DropboxMiddleware,
|
||||
config: {
|
||||
dropbox: {
|
||||
clientID: 'foobar',
|
||||
clientSecret: 'foobar'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'Google',
|
||||
middleware: GoogleMiddleware,
|
||||
config: {
|
||||
google: {
|
||||
clientID: 'foobar',
|
||||
clientSecret: 'foobar'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'LDAP',
|
||||
middleware: LdapMiddleware,
|
||||
config: {
|
||||
ldap: {}
|
||||
}
|
||||
}, {
|
||||
name: 'OAuth2',
|
||||
middleware: OAuth2Middleware,
|
||||
config: {
|
||||
oauth2: {
|
||||
clientID: 'foobar',
|
||||
clientSecret: 'foobar',
|
||||
authorizationURL: 'foobar',
|
||||
tokenURL: 'foobar',
|
||||
userProfileURL: 'foobar',
|
||||
scope: 'foobar'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'Email',
|
||||
middleware: EmailMiddleware,
|
||||
config: {}
|
||||
}, {
|
||||
name: 'OpenID',
|
||||
middleware: OPenIDMiddleware,
|
||||
config: {}
|
||||
}]
|
||||
|
||||
middlewareList.forEach((middleware) => {
|
||||
describe(middleware.name + 'Middleware', () => {
|
||||
before(() => {
|
||||
ImportMock.mockOther(configModule, 'config', middleware.config)
|
||||
})
|
||||
it('can be instantiated', () => {
|
||||
assert.ok(middleware.middleware.getMiddleware())
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
Loading…
Reference in a new issue