Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict'
/*
* adonis-auth
*
* (c) Harminder Virk
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
require('@adonisjs/lucid/lib/iocResolver').setFold(require('@adonisjs/fold'))
const test = require('japa')
const AuthManager = require('../../src/Auth/Manager')
const { session: Session } = require('../../src/Schemes')
const { lucid: Lucid } = require('../../src/Serializers')
const setup = require('./setup')
test.group('AuthManager', (group) => {
setup.hashHook(group)
test('extend by adding a new serializer', (assert) => {
const mongo = {}
AuthManager.extend('mongo', mongo, 'serializer')
assert.deepEqual(AuthManager._serializers, { mongo })
})
'use strict'
/*
* adonis-auth
*
* (c) Harminder Virk
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
require('@adonisjs/lucid/lib/iocResolver').setFold(require('@adonisjs/fold'))
const test = require('japa')
const { ioc } = require('@adonisjs/fold')
const { database: DatabaseSerializer } = require('../../src/Serializers')
const setup = require('./setup')
test.group('Serializers - Database', (group) => {
setup.databaseHook(group)
setup.hashHook(group)
test('generate correct query to fetch user by id', async (assert) => {
const config = {
uid: 'email',
password: 'password',
table: 'users',
'use strict'
/*
* adonis-auth
*
* (c) Harminder Virk
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
require('@adonisjs/lucid/lib/iocResolver').setFold(require('@adonisjs/fold'))
const test = require('japa')
const { ioc } = require('@adonisjs/fold')
const Model = require('@adonisjs/lucid/src/Lucid/Model')
const { basic: BasicAuth } = require('../../src/Schemes')
const { lucid: LucidSerializer } = require('../../src/Serializers')
const setup = require('./setup')
test.group('Schemes - BasicAuth', (group) => {
setup.databaseHook(group)
setup.hashHook(group)
test('throw exception when unable to validate credentials', async (assert) => {
assert.plan(1)
'use strict'
/*
* adonis-auth
*
* (c) Harminder Virk
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
require('@adonisjs/lucid/lib/iocResolver').setFold(require('@adonisjs/fold'))
const test = require('japa')
const { ioc } = require('@adonisjs/fold')
const { lucid: LucidSerializer } = require('../../src/Serializers')
const helpers = require('./helpers')
const setup = require('./setup')
test.group('Serializers - Lucid', (group) => {
setup.databaseHook(group)
setup.hashHook(group)
test('generate correct query to fetch user by id', async (assert) => {
const User = helpers.getUserModel()
let authQuery = null
User.onQuery((query) => (authQuery = query))
'use strict'
/*
* adonis-auth
*
* (c) Harminder Virk
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
require('@adonisjs/lucid/lib/iocResolver').setFold(require('@adonisjs/fold'))
const test = require('japa')
const { ioc } = require('@adonisjs/fold')
const { Config } = require('@adonisjs/sink')
const { session: Session } = require('../../src/Schemes')
const { lucid: LucidSerializer } = require('../../src/Serializers')
const helpers = require('./helpers')
const setup = require('./setup')
test.group('Schemes - Session', (group) => {
setup.databaseHook(group)
setup.hashHook(group)
test('return uid field name', async (assert) => {
assert.plan(1)
'use strict'
require('@adonisjs/lucid/lib/iocResolver').setFold(require('@adonisjs/fold'))
const fs = require('fs-extra')
const path = require('path')
const { ioc, registrar } = require('@adonisjs/fold')
const { Config, setupResolver, Helpers } = require('@adonisjs/sink')
const Model = require('@adonisjs/lucid/src/Lucid/Model')
const setup = require('../unit/fixtures/setup')
beforeAll(async () => {
ioc.singleton('Adonis/Src/Config', function () {
const config = new Config()
config.set('database', {
connection: 'sqlite',
sqlite: {
client: 'sqlite',
connection: {
'use strict'
/*
* adonis-auth
*
* (c) Harminder Virk
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
require('@adonisjs/lucid/lib/iocResolver').setFold(require('@adonisjs/fold'))
const test = require('japa')
const { ioc } = require('@adonisjs/fold')
const jwtLib = require('jsonwebtoken')
const { jwt: Jwt } = require('../../src/Schemes')
const { lucid: LucidSerializer, database: DatabaseSerializer } = require('../../src/Serializers')
const helpers = require('./helpers')
const setup = require('./setup')
const SECRET = 'averylongsecretkey'
const Encryption = {
encrypt (token) {
return `e${token}`
},
'use strict'
/*
* adonis-auth
*
* (c) Harminder Virk
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
require('@adonisjs/lucid/lib/iocResolver').setFold(require('@adonisjs/fold'))
const { ioc, registrar } = require('@adonisjs/fold')
const path = require('path')
const Macroable = require('macroable')
const { Config } = require('@adonisjs/sink')
const helpers = require('../../unit/helpers')
class Context extends Macroable {
static onReady () {}
}
Context._getters = {}
Context._macros = {}
module.exports = async () => {
ioc.bind('Adonis/Src/HttpContext', () => {
return Context
'use strict'
require('@adonisjs/lucid/lib/iocResolver').setFold(require('@adonisjs/fold'))
const test = require('japa')
const fs = require('fs-extra')
const path = require('path')
const { ioc } = require('@adonisjs/fold')
const { Config, setupResolver } = require('@adonisjs/sink')
const Model = require('@adonisjs/lucid/src/Lucid/Model')
const DatabaseManager = require('@adonisjs/lucid/src/Database/Manager')
const Morphable = require('adonis-lucid-polymorphic/src/Traits/Morphable')
const ChannelManager = require('../../src/ChannelManager')
const DatabaseChannel = require('../../src/Channels/DatabaseChannel')
const fixtures = require('../fixtures')
test.group('ChannelManager', (group) => {
group.before(async function () {
ioc.singleton('Adonis/Src/Config', function () {
'use strict'
/**
* adonis-acl
* Copyright(c) 2017 Evgeny Razumov
* MIT Licensed
*/
require('@adonisjs/lucid/lib/iocResolver').setFold(require('@adonisjs/fold'))
const test = require('japa')
const fs = require('fs-extra')
const path = require('path')
const Model = require('@adonisjs/lucid/src/Lucid/Model')
const DatabaseManager = require('@adonisjs/lucid/src/Database/Manager')
const BelongsToMany = require('@adonisjs/lucid/src/Lucid/Relations/BelongsToMany')
const { ioc } = require('@adonisjs/fold')
const { Config, setupResolver } = require('@adonisjs/sink')
const HasPermission = require('../../src/Traits/HasPermission')
const HasRole = require('../../src/Traits/HasRole')
const fixtures = require('../fixtures')
test.group('Traits', function (group) {
group.before(async function () {
ioc.singleton('Adonis/Src/Database', function () {
const config = new Config()