🌟 Data migration from nextcloud (#302)

- Files upload to Twake Drive
- New logger
This commit is contained in:
Anton Shepilov
2024-01-02 17:09:43 +03:00
committed by GitHub
parent 75dffb1c7a
commit 6f7f714fe8
14 changed files with 261 additions and 57 deletions
@@ -2,7 +2,7 @@ import {describe, expect, test} from '@jest/globals';
import { LdapUser } from '../src/shell_ldap_user';
import { LdapConfiguration } from '../src/ldap_user';
//integration debug test
//FOR LOCAL DEBUG PURPOSE ONLY, ITS NOT A TEST
describe.skip('ldap module', () => {
test('ldap returns user info', async () => {
@@ -0,0 +1,26 @@
import { expect, test } from '@jest/globals';
import { TwakeDriveClient, TwakeDriveUser } from '../src/twake_client';
import { NextcloudMigration, NextcloudMigrationConfiguration } from '../src/nextcloud_migration';
//FOR LOCAL DEBUG PURPOSE ONLY, ITS NOT A TEST
describe.skip('nextcloud migration module', () => {
test('upload directory', async () => {
//given
const subj = new NextcloudMigration({
drive: {
url: "http://localhost:4000",
credentials: {
appId: "tdrive_onlyoffice",
secret: "c1cc66db78e1d3bb4713c55d5ab2"
}
}
} as NextcloudMigrationConfiguration);
let user = await subj.driveClient.createUser({firstName: "DWHO", lastName: "DWHO", email: "dwho@example.com", uid: "test"});
//when
await subj.upload(user, "/Users/shepilov/WebstormProjects/TDrive/Documentation/docs/onprem");
});
});
@@ -1,23 +1,34 @@
import { expect, test } from '@jest/globals';
import { TwakeDriveClient } from '../src/twake_client';
//integration debug test
//FOR LOCAL DEBUG PURPOSE ONLY, ITS NOT A TEST
describe.skip('twake client module', () => {
test('twake creates new user', async () => {
//given
const subj = new TwakeDriveClient({
url: "https://tdrive.qa.lin-saas.com/",
credentials: {
appId: "tdrive_onlyoffice",
secret: "QWERTY"
}
})
const subj = new TwakeDriveClient({
url: "http://localhost:4000",
credentials: {
appId: "tdrive_onlyoffice",
secret: "c1cc66db78e1d3bb4713c55d5ab2"
}
})
test('twake creates new user and files for the user', async () => {
//when
const response = await subj.createUser({firstName: "Test", lastName: "User", email: "test@example.com", uid: "test"});
expect(response).toBeDefined();
console.log(response);
let user = await subj.createUser({firstName: "DWHO", lastName: "DWHO", email: "dwho@example.com", uid: "test"});
expect(user).toBeDefined();
expect(user.id).toBeDefined();
user = await subj.getUser(user.id);
expect(user).toBeDefined();
expect(user.id).toBeDefined();
const dir = await subj.createDirectory("My DIR", "user_" + user.id)
const doc = await subj.createFile("/Users/shepilov/WebstormProjects/TDrive/tdrive/backend/utils/nextcloud-migration/src/nextcloud_migration.ts", dir.id);
expect(doc).toBeDefined();
expect(doc.id).toBeDefined();
const item = await subj.getDocument("user_" + user.id);
expect(item.children.filter(i => i.name.startsWith("My DIR")).length).toBeGreaterThan(0);
});
});