mirror of
https://github.com/standardnotes/server
synced 2026-07-14 00:01:54 -04:00
wip: e2e tests
This commit is contained in:
@@ -11,6 +11,7 @@ import '../src/Controller/v1/ActionsController'
|
||||
import '../src/Controller/v1/InvoicesController'
|
||||
import '../src/Controller/v1/RevisionsController'
|
||||
import '../src/Controller/v1/ItemsController'
|
||||
import '../src/Controller/v1/ContactsController'
|
||||
import '../src/Controller/v1/LinksController'
|
||||
import '../src/Controller/v1/GroupsController'
|
||||
import '../src/Controller/v1/PaymentsController'
|
||||
|
||||
@@ -115,7 +115,7 @@ export class ServerContainerConfigLoader extends CommonContainerConfigLoader {
|
||||
return new SyncItems(
|
||||
context.container.get(TYPES.ItemService),
|
||||
context.container.get(TYPES.GroupService),
|
||||
context.container.get(TYPES.GroupUserService),
|
||||
context.container.get(TYPES.GroupInviteService),
|
||||
context.container.get(TYPES.ContactService),
|
||||
)
|
||||
})
|
||||
@@ -223,7 +223,7 @@ export class ServerContainerConfigLoader extends CommonContainerConfigLoader {
|
||||
context.container.get(TYPES.ItemProjector),
|
||||
context.container.get(TYPES.ItemConflictProjector),
|
||||
context.container.get(TYPES.SavedItemProjector),
|
||||
context.container.get(TYPES.GroupUserProjector),
|
||||
context.container.get(TYPES.GroupInviteProjector),
|
||||
context.container.get(TYPES.ContactProjector),
|
||||
context.container.get(TYPES.GroupProjector),
|
||||
)
|
||||
|
||||
@@ -7,7 +7,7 @@ import { ProjectorInterface } from '../Projection/ProjectorInterface'
|
||||
import { Contact } from '../Domain/Contact/Model/Contact'
|
||||
import { ContactProjection } from '../Projection/ContactProjection'
|
||||
|
||||
@controller('/contacts')
|
||||
@controller('/contacts', TYPES.AuthMiddleware)
|
||||
export class ContactsController extends BaseHttpController {
|
||||
constructor(
|
||||
@inject(TYPES.ContactService) private contactService: ContactServiceInterface,
|
||||
@@ -16,7 +16,7 @@ export class ContactsController extends BaseHttpController {
|
||||
super()
|
||||
}
|
||||
|
||||
@httpPost('/', TYPES.AuthMiddleware)
|
||||
@httpPost('/')
|
||||
public async createContact(
|
||||
request: Request,
|
||||
response: Response,
|
||||
@@ -36,7 +36,7 @@ export class ContactsController extends BaseHttpController {
|
||||
})
|
||||
}
|
||||
|
||||
@httpDelete('/:contactUuid', TYPES.AuthMiddleware)
|
||||
@httpDelete('/:contactUuid')
|
||||
public async deleteContact(
|
||||
request: Request,
|
||||
response: Response,
|
||||
|
||||
@@ -42,7 +42,7 @@ export class TypeORMContactRepository implements ContactsRepositoryInterface {
|
||||
}
|
||||
|
||||
if (query.lastSyncTime) {
|
||||
queryBuilder.andWhere('group_user.updated_at_timestamp > :lastSyncTime', {
|
||||
queryBuilder.andWhere('contact.updated_at_timestamp > :lastSyncTime', {
|
||||
lastSyncTime: query.lastSyncTime,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -42,6 +42,10 @@ export class GroupUserService implements GroupUserServiceInterface {
|
||||
return this.groupUserRepository.findAllForUser(dto)
|
||||
}
|
||||
|
||||
getUserForGroup(dto: { userUuid: string; groupUuid: string }): Promise<GroupUser | null> {
|
||||
return this.groupUserRepository.findByUserUuidAndGroupUuid(dto.userUuid, dto.groupUuid)
|
||||
}
|
||||
|
||||
async getGroupUsersForGroup(dto: {
|
||||
groupUuid: string
|
||||
originatorUuid: string
|
||||
|
||||
@@ -11,6 +11,8 @@ export interface GroupUserServiceInterface {
|
||||
|
||||
getAllGroupUsersForUser(dto: GetGroupUsersDTO): Promise<GroupUser[]>
|
||||
|
||||
getUserForGroup(dto: { userUuid: string; groupUuid: string }): Promise<GroupUser | null>
|
||||
|
||||
getGroupUsersForGroup(dto: {
|
||||
groupUuid: string
|
||||
originatorUuid: string
|
||||
|
||||
@@ -6,6 +6,7 @@ import { GroupUserServiceInterface } from '../../GroupUser/Service/GroupUserServ
|
||||
import { ItemHash } from '../ItemHash'
|
||||
import { GroupUserPermission } from '../../GroupUser/Model/GroupUserPermission'
|
||||
import { GroupServiceInterface } from '../../Group/Service/GroupServiceInterface'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
|
||||
export class OwnershipFilter implements ItemSaveRuleInterface {
|
||||
constructor(private groupService: GroupServiceInterface, private groupUserService: GroupUserServiceInterface) {}
|
||||
@@ -52,6 +53,11 @@ export class OwnershipFilter implements ItemSaveRuleInterface {
|
||||
}
|
||||
|
||||
private async groupItemIsBeingSavedWithValidItemsKey(itemHash: ItemHash): Promise<boolean> {
|
||||
const isItemNotEncryptedByItemsKey = itemHash.content_type === ContentType.SharedItemsKey
|
||||
if (isItemNotEncryptedByItemsKey) {
|
||||
return true
|
||||
}
|
||||
|
||||
const group = await this.groupService.getGroup({ groupUuid: itemHash.group_uuid as string })
|
||||
|
||||
if (!group) {
|
||||
@@ -65,12 +71,13 @@ export class OwnershipFilter implements ItemSaveRuleInterface {
|
||||
userUuid: string,
|
||||
itemHash: ItemHash,
|
||||
): Promise<GroupUserPermission | undefined> {
|
||||
const groupUsers = await this.groupUserService.getAllGroupUsersForUser({ userUuid })
|
||||
const groupUser = await this.groupUserService.getUserForGroup({
|
||||
userUuid,
|
||||
groupUuid: itemHash.group_uuid as string,
|
||||
})
|
||||
|
||||
for (const groupUser of groupUsers) {
|
||||
if (itemHash.group_uuid === groupUser.groupUuid) {
|
||||
return groupUser.permissions
|
||||
}
|
||||
if (groupUser) {
|
||||
return groupUser.permissions
|
||||
}
|
||||
|
||||
return undefined
|
||||
|
||||
Reference in New Issue
Block a user