Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cvat/apps/authentication/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def authenticate(self, request):
auth = super().authenticate(request)
session = getattr(request, 'session')
if auth is not None and session.session_key is None:
login(request, auth[0], 'cvat.apps.authentication.authentication_backends.ModelBackend')
login(request, auth[0], 'django.contrib.auth.backends.ModelBackend')
return auth

def register_signals():
Expand Down
20 changes: 20 additions & 0 deletions cvat/apps/authentication/migrations/0002_cascade_removal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 3.1.10 on 2021-08-30 13:04

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('authentication', '0001_initial'),
]

operations = [
migrations.AlterField(
model_name='wallettouser',
name='user',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='+', to=settings.AUTH_USER_MODEL),
),
]
4 changes: 4 additions & 0 deletions cvat/apps/authentication/migrations/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright (C) 2021 Intel Corporation
#
# SPDX-License-Identifier: MIT

2 changes: 1 addition & 1 deletion cvat/apps/authentication/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ def get_session_auth_hash(self):

class WalletToUser(models.Model):
user = models.ForeignKey(User, null=True, blank=True,
on_delete=models.SET_NULL, related_name="+")
on_delete=models.CASCADE, related_name="+")
wallet_address = models.CharField(max_length=42, default='')
10 changes: 8 additions & 2 deletions tests/cypress.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@
"downloadsFolder": "cypress/fixtures",
"env": {
"user": "admin",
"email": "admin@localhost.company",
"password": "12qwaszx"
"email": "admin@admin.com",
"password": "Password2",
"regularUserEmail": "user@test.com",
"regularUserWalletAddress": "0xC4f81FBF7Be438112A8B02D34000B9c607693A36",
"regularUserSignedEmail": "0x7d0bb429f8d89244c08ed31f00059cf34d8e71b228961377c08ab1d98def671b19163c87480e0206867cc76a771857ad14dbf608d9340d2a94f160d15362378c1b",
"regularUser2Email": "user2@test.com",
"regularUser2WalletAddress": "0xE3087cfEadEb3242C204fC47aC7Dd36446C4A65C",
"regularUser2SignedEmail": "0x8367167c41e2da1de79ac4b5ce8db8b67b771762e79949861d06a603c2a2be485f0f86eb3a270b549625e9ea39eb8635093613008ee9e88779a251465e4190161c"
},
"testFiles": [
"auth_page.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,25 @@

/// <reference types="cypress" />

import '../../support/preserve_cookies';

context('Move a task between projects.', () => {
const caseID = 94;
const firtsProject = {
name: `Firts project case ${caseID}`,
label: 'car',
attrName: 'color',
attrVaue: 'red',
multiAttrParams: false
}
multiAttrParams: false,
};

const secondProject = {
name: `Second project case ${caseID}`,
label: 'bicycle',
attrName: 'color',
attrVaue: 'yellow',
multiAttrParams: false
}
multiAttrParams: false,
};

const taskName = `Task case ${caseID}`;
const imagesCount = 1;
Expand All @@ -39,23 +41,45 @@ context('Move a task between projects.', () => {
const attachToProject = false;
const multiAttrParams = false;

function checkTask (project, expectedResult) {
function checkTask(project, expectedResult) {
cy.goToProjectsList();
cy.openProject(project);
cy.get('.cvat-tasks-list-item').should(expectedResult);
}

before(() => {
cy.imageGenerator(imagesFolder, imageFileName, width, height, color, posX, posY, firtsProject.label, imagesCount);
cy.imageGenerator(
imagesFolder,
imageFileName,
width,
height,
color,
posX,
posY,
firtsProject.label,
imagesCount,
);
cy.createZipArchive(directoryToArchive, archivePath);
cy.visit('/');
cy.visit('/admin');
cy.login();
});

beforeEach(() => {
cy.goToProjectsList();
cy.createProjects(firtsProject.name, firtsProject.label, firtsProject.attrName, firtsProject.attrVaue, firtsProject.multiAttrParams);
cy.createProjects(secondProject.name, secondProject.label, secondProject.attrName, secondProject.attrVaue, secondProject.multiAttrParams);
cy.createProjects(
firtsProject.name,
firtsProject.label,
firtsProject.attrName,
firtsProject.attrVaue,
firtsProject.multiAttrParams,
);
cy.createProjects(
secondProject.name,
secondProject.label,
secondProject.attrName,
secondProject.attrVaue,
secondProject.multiAttrParams,
);
cy.openProject(firtsProject.name);
cy.createAnnotationTask(
taskName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,23 @@

/// <reference types="cypress" />

import '../../support/preserve_cookies';

context('Move a task to a project.', () => {
const caseID = '95';
const task = {
name: `Case ${caseID}`,
label: 'Tree',
attrName: 'Kind',
attrValue: 'Oak',
}
};

const project = {
name: `Case ${caseID}`,
label: 'Tree',
attrName: 'Kind',
attrVaue: 'Oak'
}
attrVaue: 'Oak',
};

const imagesCount = 1;
const imageFileName = `image_${task.name.replace(' ', '_').toLowerCase()}`;
Expand All @@ -33,7 +35,7 @@ context('Move a task to a project.', () => {
const directoryToArchive = imagesFolder;

before(() => {
cy.visit('/');
cy.visit('/admin');
cy.login();
cy.imageGenerator(imagesFolder, imageFileName, width, height, color, posX, posY, task.name, imagesCount);
cy.createZipArchive(directoryToArchive, archivePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ context('Base actions on the project', () => {
const newLabelName2 = `Second label ${projectName}`;
const newLabelName3 = `Third label ${projectName}`;
const newLabelName4 = `Fourth label ${projectName}`;
const firstName = 'Seconduser fm';
const lastName = 'Seconduser lm';
const userName = 'Seconduser';
const emailAddr = `${userName}@local.local`;
const password = 'GDrb41RguF!';
let projectID = '';

function getProjectID(projectName) {
Expand All @@ -57,7 +52,7 @@ context('Base actions on the project', () => {
});

after(() => {
cy.deletingRegisteredUsers([userName]);
cy.deletingRegisteredUsers([Cypress.env('regularUserEmail')]);
});

describe(`Testing "Base actions on the project"`, () => {
Expand Down Expand Up @@ -116,26 +111,36 @@ context('Base actions on the project', () => {
it('Logout first user, register second user, tries to create project and logout.', () => {
cy.goToTaskList();
cy.logout();
cy.goToRegisterPage();
cy.userRegistration(firstName, lastName, userName, emailAddr, password);
cy.visit('/');
cy.userRegistration(
Cypress.env('regularUserEmail'),
Cypress.env('regularUserEmail'),
Cypress.env('regularUserWalletAddress'),
Cypress.env('regularUserSignedEmail'),
);
cy.goToProjectsList();
// tries to create project
const failProjectName = 'failProject';
cy.createProjects(failProjectName, labelName, attrName, textDefaultValue, null, 'fail');
cy.closeNotification('.cvat-notification-notice-create-project-failed');
cy.goToProjectsList();
cy.contains('.cvat-projects-project-item-title', failProjectName).should('not.exist');
cy.logout(userName);
cy.logout();
});
it('Login first user. Assign project to second user. Logout.', () => {
cy.visit('/admin');
cy.login();
cy.goToProjectsList();
cy.openProject(projectName);
cy.assignProjectToUser(userName);
cy.assignProjectToUser(Cypress.env('regularUserEmail'));
cy.logout();
});
it('Login second user. The project and first tasks available for that user. Tries to delete project. Logout.', () => {
cy.login(userName, password);
cy.regularUserLogin(
Cypress.env('regularUserEmail'),
Cypress.env('regularUserWalletAddress'),
Cypress.env('regularUserSignedEmail'),
);
cy.goToProjectsList();
// tries to delete project
cy.deleteProject(projectName, projectID, 'fail');
Expand All @@ -145,9 +150,10 @@ context('Base actions on the project', () => {
cy.contains('strong', taskName.secondTask).should('not.exist');
cy.openTask(taskName.firstTask);
cy.goToTaskList();
cy.logout(userName);
cy.logout();
});
it('Delete the project. Deleted project not exist. Checking the availability of tasks.', () => {
cy.visit('/admin');
cy.login();
cy.goToProjectsList();
cy.deleteProject(projectName, projectID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

/// <reference types="cypress" />

import '../../support/preserve_cookies';

context('Delete a label from a task.', () => {
const caseId = '58';
const labelName = `Case ${caseId}`;
Expand All @@ -23,7 +25,7 @@ context('Delete a label from a task.', () => {
const directoryToArchive = imagesFolder;

before(() => {
cy.visit('auth/login');
cy.visit('/admin');
cy.login();
cy.imageGenerator(imagesFolder, imageFileName, width, height, color, posX, posY, labelName, imagesCount);
cy.createZipArchive(directoryToArchive, archivePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

/// <reference types="cypress" />

import '../../support/preserve_cookies';

context('Create a task with set an issue tracker.', () => {
const caseId = '61';
const labelName = `Case ${caseId}`;
Expand All @@ -23,7 +25,7 @@ context('Create a task with set an issue tracker.', () => {
const incorrectBugTrackerUrl = 'somebugtracker.info/task12';

before(() => {
cy.visit('auth/login');
cy.visit('/admin');
cy.login();
cy.imageGenerator(imagesFolder, imageFileName, width, height, color, posX, posY, labelName, imagesCount);
cy.createZipArchive(directoryToArchive, archivePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

/// <reference types="cypress" />

import '../../support/preserve_cookies';

context('Create an annotation task with manifest.', () => {
const caseId = '65';
const labelName = `Case ${caseId}`;
Expand All @@ -14,7 +16,7 @@ context('Create an annotation task with manifest.', () => {
let filesToAttach = [];

before(() => {
cy.visit('auth/login');
cy.visit('/admin');
cy.login();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

/// <reference types="cypress" />

import '../../support/preserve_cookies';

context('Rename a label via raw editor.', () => {
const caseId = '66';
const labelName = `Case ${caseId}`;
Expand Down Expand Up @@ -37,7 +39,7 @@ context('Rename a label via raw editor.', () => {
}

before(() => {
cy.visit('auth/login');
cy.visit('/admin');
cy.login();
cy.imageGenerator(imagesFolder, imageFileName, width, height, color, posX, posY, labelName, imagesCount);
cy.createZipArchive(directoryToArchive, archivePath);
Expand Down
Loading