fix(workspace): rename private key to encrypted private key

This commit is contained in:
Karol Sójko
2022-10-10 10:09:49 +02:00
parent 3f6db48f83
commit 447d600dbe
4 changed files with 22 additions and 5 deletions
@@ -0,0 +1,17 @@
import { MigrationInterface, QueryRunner } from 'typeorm'
export class renamePrivateKey1665389240189 implements MigrationInterface {
name = 'renamePrivateKey1665389240189'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
'ALTER TABLE `workspace_users` CHANGE `private_key` `encrypted_private_key` varchar(255) NOT NULL',
)
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
'ALTER TABLE `workspace_users` CHANGE `encrypted_private_key` `private_key` varchar(255) NOT NULL',
)
}
}
@@ -41,7 +41,7 @@ describe('CreateWorkspace', () => {
expect(workspaceUserRepository.save).toHaveBeenCalledWith({
accessLevel: 'owner',
encryptedWorkspaceKey: 'bar',
privateKey: 'foo',
encryptedPrivateKey: 'foo',
publicKey: 'buzz',
status: 'active',
userUuid: '1-2-3',
@@ -64,7 +64,7 @@ describe('CreateWorkspace', () => {
expect(workspaceUserRepository.save).toHaveBeenCalledWith({
accessLevel: 'owner',
encryptedWorkspaceKey: 'bar',
privateKey: 'foo',
encryptedPrivateKey: 'foo',
publicKey: 'buzz',
status: 'active',
userUuid: '1-2-3',
@@ -31,7 +31,7 @@ export class CreateWorkspace implements UseCaseInterface {
const ownerAssociation = new WorkspaceUser()
ownerAssociation.accessLevel = WorkspaceAccessLevel.Owner
ownerAssociation.encryptedWorkspaceKey = dto.encryptedWorkspaceKey
ownerAssociation.privateKey = dto.encryptedPrivateKey
ownerAssociation.encryptedPrivateKey = dto.encryptedPrivateKey
ownerAssociation.publicKey = dto.publicKey
ownerAssociation.status = WorkspaceUserStatus.Active
ownerAssociation.userUuid = dto.ownerUuid
@@ -42,11 +42,11 @@ export class WorkspaceUser {
declare publicKey: string
@Column({
name: 'private_key',
name: 'encrypted_private_key',
length: 255,
type: 'varchar',
})
declare privateKey: string
declare encryptedPrivateKey: string
@Column({
name: 'status',