Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5472-user_passExpired

This commit is contained in:
Alex Moreno 2023-06-12 11:06:27 +02:00
commit 22e69e6e91
8 changed files with 24 additions and 34 deletions

View File

@ -1,26 +1,18 @@
FROM mariadb:10.7.5 FROM mariadb:10.7.7
ENV MYSQL_ROOT_PASSWORD root ENV MYSQL_ROOT_PASSWORD root
ENV TZ Europe/Madrid ENV TZ Europe/Madrid
ARG MOCKDATE=2001-01-01 11:00:00 ARG MOCKDATE=2001-01-01 11:00:00
ARG DEBIAN_FRONTEND=noninteractive ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -y --no-install-recommends curl ca-certificates \
&& curl -sL https://apt.verdnatura.es/conf/verdnatura.gpg | apt-key add - \
&& echo "deb http://apt.verdnatura.es/ jessie main" > /etc/apt/sources.list.d/vn.list \
&& apt-get update \
&& apt-get install -y vn-mariadb \
&& apt-get purge -y --auto-remove curl ca-certificates \
&& rm -rf /var/lib/apt/lists/*
COPY docker/docker.cnf /etc/mysql/conf.d/ COPY docker/docker.cnf /etc/mysql/conf.d/
COPY \ COPY \
docker/docker-start.sh \
docker/docker-init.sh \ docker/docker-init.sh \
docker/docker-temp-start.sh \
docker/docker-temp-stop.sh \ docker/docker-temp-stop.sh \
docker/docker-dump.sh \ docker/docker-dump.sh \
docker/docker-start.sh \ docker/docker-structure.sh \
docker/docker-fixtures.sh \
/usr/local/bin/ /usr/local/bin/
RUN mkdir /mysql-data \ RUN mkdir /mysql-data \
@ -31,26 +23,16 @@ WORKDIR /docker-boot
COPY \ COPY \
import-changes.sh \ import-changes.sh \
config.ini \ config.ini \
dump/mysqlPlugins.sql \
dump/structure.sql \ dump/structure.sql \
dump/mockDate.sql \ dump/mockDate.sql \
dump/dumpedFixtures.sql \ dump/dumpedFixtures.sql \
./ ./
RUN gosu mysql docker-init.sh \ RUN sed -i -e 's/@mockDate/'"$MOCKDATE"'/g' mockDate.sql \
&& docker-dump.sh mysqlPlugins \ && gosu mysql docker-structure.sh
&& docker-dump.sh structure \
&& sed -i -e 's/@mockDate/'"$MOCKDATE"'/g' mockDate.sql \
&& docker-dump.sh mockDate \
&& docker-dump.sh dumpedFixtures \
&& gosu mysql docker-temp-stop.sh
COPY changes ./changes COPY changes ./changes
COPY dump/fixtures.sql ./ COPY dump/fixtures.sql ./
ARG STAMP=unknown ARG STAMP=unknown
RUN gosu mysql docker-temp-start.sh \ RUN gosu mysql docker-fixtures.sh
&& ./import-changes.sh \
&& docker-dump.sh fixtures \
&& gosu mysql docker-temp-stop.sh
RUN echo "[INFO] -> Import finished" \ RUN echo "[INFO] -> Import finished" \
&& rm -rf /docker-boot && rm -rf /docker-boot

View File

@ -5,3 +5,6 @@ CMD=mysqld
docker_setup_env "$CMD" docker_setup_env "$CMD"
docker_temp_server_start "$CMD" docker_temp_server_start "$CMD"
bash import-changes.sh
docker-dump.sh fixtures
docker_temp_server_stop

7
db/docker/docker-structure.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
. docker-init.sh
docker-dump.sh structure
docker-dump.sh mockDate
docker-dump.sh dumpedFixtures
. docker-temp-stop.sh

0
db/docker/docker-temp-stop.sh Executable file → Normal file
View File

View File

@ -1,4 +0,0 @@
-- Import compiled functions
CREATE AGGREGATE FUNCTION minacum RETURNS INT SONAME 'minacum.so';
CREATE AGGREGATE FUNCTION multimax RETURNS INT SONAME 'multimax.so';

View File

@ -1,6 +1,6 @@
module.exports = Self => { module.exports = Self => {
Self.remoteMethodCtx('changePassword', { Self.remoteMethod('changePassword', {
description: 'Changes the user password', description: 'Changes the user password',
accessType: 'WRITE', accessType: 'WRITE',
accepts: [ accepts: [

View File

@ -1,14 +1,15 @@
const {models} = require('vn-loopback/server/server'); const {models} = require('vn-loopback/server/server');
describe('Account setPassword()', () => { describe('Account setPassword()', () => {
const ctx = {req: {accessToken: {userId: 9}}};
it('should throw an error when password does not meet requirements', async() => { it('should throw an error when password does not meet requirements', async() => {
let req = models.Account.setPassword(1, 'insecurePass'); let req = models.Account.setPassword(ctx, 1, 'insecurePass');
await expectAsync(req).toBeRejected(); await expectAsync(req).toBeRejected();
}); });
it('should update password when it passes requirements', async() => { it('should update password when it passes requirements', async() => {
let req = models.Account.setPassword(1, 'Very$ecurePa22.'); let req = models.Account.setPassword(ctx, 1, 'Very$ecurePa22.');
await expectAsync(req).toBeResolved(); await expectAsync(req).toBeResolved();
}); });

View File

@ -1,11 +1,12 @@
const models = require('vn-loopback/server/server').models; const models = require('vn-loopback/server/server').models;
describe('Client setPassword', () => { describe('Client setPassword', () => {
const ctx = {req: {accessToken: {userId: 9}}};
it('should throw an error the setPassword target is not just a client but a worker', async() => { it('should throw an error the setPassword target is not just a client but a worker', async() => {
let error; let error;
try { try {
await models.Client.setPassword(1, 't0pl3v3l.p455w0rd!'); await models.Client.setPassword(ctx, 1, 't0pl3v3l.p455w0rd!');
} catch (e) { } catch (e) {
error = e; error = e;
} }
@ -17,7 +18,7 @@ describe('Client setPassword', () => {
let error; let error;
try { try {
await models.Client.setPassword(1101, 't0pl3v3l.p455w0rd!'); await models.Client.setPassword(ctx, 1101, 't0pl3v3l.p455w0rd!');
} catch (e) { } catch (e) {
error = e; error = e;
} }