Skip to content

Commit

Permalink
Merge branch 'main' into BC-8348-copy-share-board
Browse files Browse the repository at this point in the history
  • Loading branch information
uidp authored Nov 26, 2024
2 parents 15e59c6 + b4bc6f7 commit 02e17b2
Show file tree
Hide file tree
Showing 40 changed files with 1,447 additions and 620 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/migrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:

env:
MONGODB_VERSION: 6.0
NODE_VERSION: '20'
NODE_VERSION: '22'
jobs:
migration:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ permissions:

env:
MONGODB_VERSION: 6.0
NODE_VERSION: '20'
NODE_VERSION: '22'
jobs:
feathers_tests_cov:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20
22
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM docker.io/node:20 AS git
FROM docker.io/node:22 AS git

RUN mkdir /app && chown -R node:node /app
WORKDIR /app
COPY .git .
RUN git config --global --add safe.directory /app && echo "{\"sha\": \"$(git rev-parse HEAD)\", \"version\": \"$(git describe --tags --abbrev=0)\", \"commitDate\": \"$(git log -1 --format=%cd --date=format:'%Y-%m-%dT%H:%M:%SZ')\", \"birthdate\": \"$(date +%Y-%m-%dT%H:%M:%SZ)\"}" > /app/serverversion

FROM docker.io/node:20-alpine
FROM docker.io/node:22-alpine
ENV TZ=Europe/Berlin
RUN apk add --no-cache git make python3
# to run ldap sync as script curl is needed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ data:
git clone https://github.com/hpi-schul-cloud/schulcloud-server.git
cd /schulcloud-server
git checkout {{ SCHULCLOUD_SERVER_IMAGE_TAG }}
npm install
npm ci
until mongosh $DATABASE__URL --eval "print(\"waited for connection\")"
do
sleep 1
Expand Down Expand Up @@ -519,43 +519,51 @@ data:
# ========== Start of the CTL seed data configuration section.
echo "Inserting ctl seed data secrets to external-tools..."

if [ -n "$CTL_SEED_SECRET_ONLINE_DIA_MATHE" ]; then
# Encrypt secrets of external tools that contain an lti11 config.
CTL_SEED_SECRET_ONLINE_DIA_MATHE=$(node scripts/secret.js -s $AES_KEY -e $CTL_SEED_SECRET_ONLINE_DIA_MATHE)
CTL_SEED_SECRET_ONLINE_DIA_DEUTSCH=$(node scripts/secret.js -s $AES_KEY -e $CTL_SEED_SECRET_ONLINE_DIA_DEUTSCH)

mongosh $DATABASE__URL --quiet --eval 'db.getCollection("external-tools").updateOne(
{
"name": "Product Test Onlinediagnose Grundschule - Mathematik",
},
{ $set: {
"config_secret": "'$CTL_SEED_SECRET_ONLINE_DIA_MATHE'",
} },
{
"upsert": true
}
);'
mongosh $DATABASE__URL --quiet --eval 'db.getCollection("external-tools").updateOne(
{
"name": "Product Test Onlinediagnose Grundschule - Deutsch",
},
{ $set: {
"config_secret": "'$CTL_SEED_SECRET_ONLINE_DIA_DEUTSCH'",
} },
{
"upsert": true
}
);'
mongosh $DATABASE__URL --quiet --eval 'db.getCollection("external-tools").updateOne(
{
"name": "Merlin Bibliothek",
},
{ $set: {
"config_secret": "'$CTL_SEED_SECRET_MERLIN'",
} },
{
"upsert": true
}
);'
CTL_SEED_SECRET_ONLINE_DIA_MATHE=$(node scripts/secret.js -s $AES_KEY -e $CTL_SEED_SECRET_ONLINE_DIA_MATHE)
mongosh $DATABASE__URL --quiet --eval 'db.getCollection("external-tools").updateOne(
{
"name": "Product Test Onlinediagnose Grundschule - Mathematik",
},
{ $set: {
"config_secret": "'$CTL_SEED_SECRET_ONLINE_DIA_MATHE'",
} },
{
"upsert": true
}
);'
fi
if [ -n "$CTL_SEED_SECRET_ONLINE_DIA_DEUTSCH" ]; then
# Encrypt secrets of external tools that contain an lti11 config.
CTL_SEED_SECRET_ONLINE_DIA_DEUTSCH=$(node scripts/secret.js -s $AES_KEY -e $CTL_SEED_SECRET_ONLINE_DIA_DEUTSCH)
mongosh $DATABASE__URL --quiet --eval 'db.getCollection("external-tools").updateOne(
{
"name": "Product Test Onlinediagnose Grundschule - Deutsch",
},
{ $set: {
"config_secret": "'$CTL_SEED_SECRET_ONLINE_DIA_DEUTSCH'",
} },
{
"upsert": true
}
);'
fi
if [ -n "$CTL_SEED_SECRET_MERLIN" ]; then
# Encrypt secrets of external tools that contain an lti11 config.
CTL_SEED_SECRET_MERLIN=$(node scripts/secret.js -s $AES_KEY -e $CTL_SEED_SECRET_MERLIN)
mongosh $DATABASE__URL --quiet --eval 'db.getCollection("external-tools").updateOne(
{
"name": "Merlin Bibliothek",
},
{ $set: {
"config_secret": "'$CTL_SEED_SECRET_MERLIN'",
} },
{
"upsert": true
}
);'
fi
echo "Inserted ctl seed data secrets to external-tools."

# ========== End of the CTL seed data configuration section.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@ spec:
requests:
cpu: {{ API_CPU_REQUESTS|default("100m", true) }}
memory: {{ API_MEMORY_REQUESTS|default("150Mi", true) }}
restartPolicy: Never
restartPolicy: OnFailure
backoffLimit: 5
4 changes: 3 additions & 1 deletion apps/server/src/infra/sync/sync.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ import { LoggerModule } from '@src/core/logger';
import { ProvisioningModule } from '@src/modules/provisioning';
import { SyncConsole } from './console/sync.console';
import { SyncService } from './service/sync.service';
import { TspLegacyMigrationService } from './tsp/tsp-legacy-migration.service';
import { TspOauthDataMapper } from './tsp/tsp-oauth-data.mapper';
import { TspSyncService } from './tsp/tsp-sync.service';
import { TspSyncStrategy } from './tsp/tsp-sync.strategy';
import { SyncUc } from './uc/sync.uc';
import { TspFetchService } from './tsp/tsp-fetch.service';

@Module({
imports: [
Expand All @@ -39,7 +41,7 @@ import { SyncUc } from './uc/sync.uc';
SyncUc,
SyncService,
...((Configuration.get('FEATURE_TSP_SYNC_ENABLED') as boolean)
? [TspSyncStrategy, TspSyncService, TspOauthDataMapper]
? [TspSyncStrategy, TspSyncService, TspOauthDataMapper, TspFetchService, TspLegacyMigrationService]
: []),
],
exports: [SyncConsole],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { TspLegacyMigrationStartLoggable } from './tsp-legacy-migration-start.loggable';

describe(TspLegacyMigrationStartLoggable.name, () => {
let loggable: TspLegacyMigrationStartLoggable;

beforeAll(() => {
loggable = new TspLegacyMigrationStartLoggable();
});

describe('when loggable is initialized', () => {
it('should be defined', () => {
expect(loggable).toBeDefined();
});
});

describe('getLogMessage', () => {
it('should return a log message', () => {
expect(loggable.getLogMessage()).toEqual({
message: 'Running migration of legacy tsp data.',
});
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Loggable, LogMessage } from '@src/core/logger';

export class TspLegacyMigrationStartLoggable implements Loggable {
getLogMessage(): LogMessage {
const message: LogMessage = {
message: 'Running migration of legacy tsp data.',
};

return message;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { TspLegacyMigrationSystemMissingLoggable } from './tsp-legacy-migration-system-missing.loggable';

describe(TspLegacyMigrationSystemMissingLoggable.name, () => {
let loggable: TspLegacyMigrationSystemMissingLoggable;

beforeAll(() => {
loggable = new TspLegacyMigrationSystemMissingLoggable();
});

describe('when loggable is initialized', () => {
it('should be defined', () => {
expect(loggable).toBeDefined();
});
});

describe('getLogMessage', () => {
it('should return a log message', () => {
expect(loggable.getLogMessage()).toEqual({
message: 'No legacy system found',
});
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Loggable, LogMessage } from '@src/core/logger';

export class TspLegacyMigrationSystemMissingLoggable implements Loggable {
getLogMessage(): LogMessage {
const message: LogMessage = {
message: 'No legacy system found',
};

return message;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { TspLegacySchoolMigrationCountLoggable } from './tsp-legacy-school-migration-count.loggable';

describe(TspLegacySchoolMigrationCountLoggable.name, () => {
let loggable: TspLegacySchoolMigrationCountLoggable;

beforeAll(() => {
loggable = new TspLegacySchoolMigrationCountLoggable(10);
});

describe('when loggable is initialized', () => {
it('should be defined', () => {
expect(loggable).toBeDefined();
});
});

describe('getLogMessage', () => {
it('should return a log message', () => {
expect(loggable.getLogMessage()).toEqual({
message: `Found 10 legacy tsp schools to migrate`,
data: {
total: 10,
},
});
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Loggable, LogMessage } from '@src/core/logger';

export class TspLegacySchoolMigrationCountLoggable implements Loggable {
constructor(private readonly total: number) {}

getLogMessage(): LogMessage {
const message: LogMessage = {
message: `Found ${this.total} legacy tsp schools to migrate`,
data: {
total: this.total,
},
};

return message;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { TspLegacySchoolMigrationSuccessLoggable } from './tsp-legacy-school-migration-success.loggable';

describe(TspLegacySchoolMigrationSuccessLoggable.name, () => {
let loggable: TspLegacySchoolMigrationSuccessLoggable;

beforeAll(() => {
loggable = new TspLegacySchoolMigrationSuccessLoggable(10, 5);
});

describe('when loggable is initialized', () => {
it('should be defined', () => {
expect(loggable).toBeDefined();
});
});

describe('getLogMessage', () => {
it('should return a log message', () => {
expect(loggable.getLogMessage()).toEqual({
message: `Legacy tsp data migration finished. Total schools: 10, migrated schools: 5`,
data: {
total: 10,
migrated: 5,
},
});
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Loggable, LogMessage } from '@src/core/logger';

export class TspLegacySchoolMigrationSuccessLoggable implements Loggable {
constructor(private readonly total: number, private readonly migrated: number) {}

getLogMessage(): LogMessage {
const message: LogMessage = {
message: `Legacy tsp data migration finished. Total schools: ${this.total}, migrated schools: ${this.migrated}`,
data: {
total: this.total,
migrated: this.migrated,
},
};

return message;
}
}
Loading

0 comments on commit 02e17b2

Please sign in to comment.