2023-12-22 21:23:21 +01:00
|
|
|
const request = require('supertest')
|
|
|
|
const dayjs = require('dayjs')
|
|
|
|
const path = require('path')
|
|
|
|
|
|
|
|
const admin = { username: 'admin', password: 'test', grant_type: 'password', client_id: 'self' }
|
|
|
|
|
|
|
|
let token
|
|
|
|
let app
|
|
|
|
let places = []
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
|
|
|
|
|
|
|
switch (process.env.DB) {
|
|
|
|
case 'mariadb':
|
|
|
|
process.env.config_path = path.resolve(__dirname, './seeds/config.mariadb.json')
|
|
|
|
break
|
|
|
|
case 'postgresql':
|
|
|
|
process.env.config_path = path.resolve(__dirname, './seeds/config.postgres.json')
|
|
|
|
break
|
|
|
|
case 'sqlite':
|
|
|
|
default:
|
|
|
|
process.env.config_path = path.resolve(__dirname, './seeds/config.sqlite.json')
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
app = await require('../server/routes.js').main()
|
|
|
|
const { sequelize } = require('../server/api/models/index')
|
2024-01-31 10:52:34 +01:00
|
|
|
const { col } = require('../server/helpers')
|
|
|
|
|
2024-01-03 22:17:47 +01:00
|
|
|
// sequelize.sync({ force: true })
|
2024-01-31 10:52:34 +01:00
|
|
|
// await sequelize.query('PRAGMA foreign_keys = OFF')
|
2023-12-22 21:23:21 +01:00
|
|
|
await sequelize.query('DELETE FROM settings')
|
2024-01-31 10:52:34 +01:00
|
|
|
await sequelize.query(`DELETE FROM ${col('user_followers')}`)
|
|
|
|
await sequelize.query(`DELETE FROM ${col('events')} where ${col('parentId')} IS NOT NULL`)
|
2023-12-22 21:23:21 +01:00
|
|
|
await sequelize.query('DELETE FROM ap_users')
|
2024-01-03 22:17:47 +01:00
|
|
|
await sequelize.query('DELETE FROM events')
|
|
|
|
await sequelize.query('DELETE FROM event_tags')
|
|
|
|
await sequelize.query('DELETE FROM resources')
|
2023-12-22 21:23:21 +01:00
|
|
|
await sequelize.query('DELETE FROM instances')
|
2024-01-03 22:17:47 +01:00
|
|
|
await sequelize.query('DELETE FROM announcements')
|
2024-01-31 10:52:34 +01:00
|
|
|
await sequelize.query('DELETE FROM oauth_tokens')
|
2024-01-03 22:17:47 +01:00
|
|
|
await sequelize.query('DELETE FROM users')
|
2023-12-22 21:23:21 +01:00
|
|
|
await sequelize.query('DELETE FROM tags')
|
|
|
|
await sequelize.query('DELETE FROM places')
|
|
|
|
await sequelize.query('DELETE FROM filters')
|
|
|
|
await sequelize.query('DELETE FROM collections')
|
2024-01-03 22:17:47 +01:00
|
|
|
await sequelize.query('DELETE FROM notifications')
|
|
|
|
await sequelize.query('DELETE FROM event_notifications')
|
2024-01-31 10:52:34 +01:00
|
|
|
// await sequelize.query('PRAGMA foreign_keys = ON')
|
2023-12-22 21:23:21 +01:00
|
|
|
} catch (e) {
|
|
|
|
console.error(e)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
await require('../server/initialize.server.js').shutdown(false)
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('Nodeinfo', () => {
|
|
|
|
test('shoud return a json content', async () => {
|
|
|
|
const response = await request(app).get('/.well-known/nodeinfo')
|
|
|
|
.expect('Content-Type', /application\/json/)
|
|
|
|
.expect(200)
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
test('shoud support nodeinfo 2.0 and 2.1', async () => {
|
|
|
|
const response = await request(app).get('/.well-known/nodeinfo')
|
|
|
|
.expect('Content-Type', /application\/json/)
|
|
|
|
.expect(200)
|
|
|
|
expect(response.body.links.find(l => l.rel === 'http://nodeinfo.diaspora.software/ns/schema/2.0').href).toBe('http://localhost:13120/.well-known/nodeinfo/2.0')
|
|
|
|
expect(response.body.links.find(l => l.rel === 'http://nodeinfo.diaspora.software/ns/schema/2.1').href).toBe('http://localhost:13120/.well-known/nodeinfo/2.1')
|
|
|
|
})
|
|
|
|
|
|
|
|
test('shoud implement FEP-2677 - Application Actor', async () => {
|
|
|
|
const response = await request(app).get('/.well-known/nodeinfo')
|
|
|
|
.expect('Content-Type', /application\/json/)
|
|
|
|
.expect(200)
|
|
|
|
expect(response.body.links.find(l => l.rel === 'https://www.w3.org/ns/activitystreams#Application').href).toBe('http://localhost:13120/federation/u/relay')
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
})
|