<commit_before>const rolesModel = require('../../../../src/services/role/model.js');
const { userModel } = require('../../../../src/services/user/model.js');
const accountModel = require('../../../../src/services/account/model.js');
// const app = require(SRC + 'app');
const { BadRequest } = require('@feathersjs/errors');
const { ObjectId } = require('mongoose').Types;
const app = require('../../../../src/app');
const { warning } = require('../../../../src/logger/index');

const PASSWORD = process.env.TEST_PW ? process.env.TEST_PW.trim() : warning('process.env.TEST_PW is not defined');
const PASSWORD_HASH = process.env.TEST_HASH ? process.env.TEST_HASH.trim() : warning('process.env.TEST_HASH is not defined');
const AT = '@schul-cloud.org';

const REQUEST_PARAMS = {
	headers: { 'content-type': 'application/json' },
	provider: 'rest',
};

const getToken = async ({ userId }) => {
	const result = app.service('authentication').create({
		strategy: 'local',
		username: userId + AT,
		password: PASSWORD,
	}, REQUEST_PARAMS);
	return result.accessToken;
};

const getRoleByKey = (key, value) => rolesModel.find({
	[key]: value,
})
	.then(([role]) => role);

const createUser = async (userId, roleName = 'student', schoolId = '0000d186816abba584714c5f') => {
	if (!['expert', 'student', 'teacher', 'parent', 'administrator', 'superhero'].includes(roleName)) throw BadRequest(`You want to test a not related role .${roleName}`);

	const role = await getRoleByKey('name', roleName);

	return userModel.create({
		_id: userId,<commit_msg>Fix logger objects being used as passwords<commit_after>const rolesModel = require('../../../../src/services/role/model.js');
const { userModel } = require('../../../../src/services/user/model.js');
const accountModel = require('../../../../src/services/account/model.js');
// const app = require(SRC + 'app');
const { BadRequest } = require('@feathersjs/errors');
const { ObjectId } = require('mongoose').Types;
const app = require('../../../../src/app');
const { warning } = require('../../../../src/logger');

const PASSWORD = (process.env.TEST_PW || '').trim();
if (PASSWORD === '') warning('process.env.TEST_PW is not defined');
const PASSWORD_HASH = (process.env.TEST_HASH || '').trim();
if (PASSWORD_HASH === '') warning('process.env.TEST_HASH is not defined');
const AT = '@schul-cloud.org';

const REQUEST_PARAMS = {
	headers: { 'content-type': 'application/json' },
	provider: 'rest',
};

const getToken = async ({ userId }) => {
	const result = app.service('authentication').create({
		strategy: 'local',
		username: userId + AT,
		password: PASSWORD,
	}, REQUEST_PARAMS);
	return result.accessToken;
};

const getRoleByKey = (key, value) => rolesModel.find({
	[key]: value,
})
	.then(([role]) => role);

const createUser = async (userId, roleName = 'student', schoolId = '0000d186816abba584714c5f') => {
	if (!['expert', 'student', 'teacher', 'parent', 'administrator', 'superhero'].includes(roleName)) throw BadRequest(`You want to test a not related role .${roleName}`);

	const role = await getRoleByKey('name', roleName);

	return userModel.create({
		_id: userId,
{'fraction_non_alphanumeric': 0.21044202434336964, 'fraction_numerical': 0.010890454836643177, 'mean_word_length': 4.329351535836177, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3388279', 'n_tokens_mistral': 1029, 'n_tokens_neox': 1004, 'n_words': 231}