rollback: Remove cypress

This commit is contained in:
mbaharip
2023-09-11 05:12:57 +07:00
parent 3ff46a088c
commit 6208d21a98
5 changed files with 0 additions and 641 deletions
-10
View File
@@ -1,10 +0,0 @@
import { defineConfig } from "cypress";
export default defineConfig({
e2e: {
baseUrl: "http://localhost:5000",
setupNodeEvents(on, config) {
// implement node event listeners here
},
},
});
-569
View File
@@ -1,569 +0,0 @@
const hash = require("../../src/utils/hashHelper");
const ids: { [key: string]: string } = {
file: "1K_KyC8B54En7UaD3_o7zubxwG4jtXTVK",
folder: "12fKI0g0Uvkubk1sSHCd_SDErLyc9TlWe",
protectedFolder: "1p6znx1BKPsqFnyOPw49uhoc8FNglfYnD",
protectedFile: "1NK-J1QIf0vuGnDIEHXBG2-9jXP6sKCuN",
protectedSubFolder: "1_N87OSlhPYfC3L1fGfE546LoJnCK8zBX",
protectedSubFile: "1CSKTtgXunrSHYRRp8FyMXYpNP6xK1iju",
protectedInsideProtected: "1VMU0sQOkuI06icRRJFof-6V-NLyBWlp5",
protectedFileInsideProtected: "1wXsNhp8JxOc8iBRyb98PkR1G_MijE2e0",
};
describe("Files API", () => {
it("Get root files", () => {
cy.request({
method: "GET",
url: "/api/files",
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body.passwordRequired).to.eq(false);
expect(response.body.passwordValidated).to.satisfy(
(key: any) => key === true || key === undefined,
);
expect(response.body.protectedId).to.eq(undefined);
expect(response.body.folders).to.have.length.at.least(0);
expect(response.body.files).to.have.length.at.least(0);
expect(response.body.readmeExists).to.be.a("boolean");
expect(response.body.nextPageToken).to.satisfy(
(key: any) => typeof key === "string" || key === undefined,
);
});
});
it("Get file", () => {
cy.request({
method: "GET",
url: `/api/files/${ids.file}`,
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body.passwordRequired).to.eq(false);
expect(response.body.passwordValidated).to.satisfy(
(key: any) => key === true || key === undefined,
);
expect(response.body.protectedId).to.eq(undefined);
expect(response.body.parents).to.have.length.at.least(0);
expect(response.body.file).to.have.property("id");
});
});
it("Get folder", () => {
cy.request({
method: "GET",
url: `/api/files/${ids.folder}`,
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body.passwordRequired).to.eq(false);
expect(response.body.passwordValidated).to.satisfy(
(key: any) => key === true || key === undefined,
);
expect(response.body.protectedId).to.eq(undefined);
expect(response.body.parents).to.have.length.at.least(0);
expect(response.body.folders).to.have.length.at.least(0);
expect(response.body.files).to.have.length.at.least(0);
expect(response.body.readmeExists).to.be.a("boolean");
expect(response.body.nextPageToken).to.satisfy(
(key: any) => typeof key === "string" || key === undefined,
);
});
});
it("View file", () => {
// Test if file returning a binary
cy.request({
method: "GET",
encoding: "binary",
url: `/api/files/${ids.file}/view`,
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.headers).have.property("content-type");
expect(response.headers)
.have.property("content-disposition")
.contains("inline");
});
});
it("Download file", () => {
// Test if file returning a binary
cy.request({
method: "GET",
encoding: "binary",
url: `/api/files/${ids.file}/download`,
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.headers).have.property("content-type");
expect(response.headers)
.have.property("content-disposition")
.contains("attachment");
});
});
});
describe("Protected files API", () => {
const folder = ids.protectedFolder;
const file = ids.protectedFile;
it("Get protected folder - without password", () => {
cy.request({
method: "GET",
url: `/api/files/${folder}`,
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body.passwordRequired).to.eq(true);
expect(response.body.passwordValidated).to.eq(false);
expect(response.body.protectedId).to.be.a("string");
});
});
it("Get protected folder - wrong password", () => {
const hashPassword = hash.hashToken("wrong password");
cy.request({
method: "GET",
url: `/api/files/${folder}`,
headers: {
Authorization: `Bearer ${hashPassword}`,
},
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body.passwordRequired).to.eq(true);
expect(response.body.passwordValidated).to.eq(false);
expect(response.body.protectedId).to.be.a("string");
});
});
it("Get protected folder - with password", () => {
const hashPassword = hash.hashToken("loremipsum");
cy.request({
method: "GET",
url: `/api/files/${folder}`,
headers: {
Authorization: `Bearer ${hashPassword}`,
},
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body.passwordRequired).to.eq(true);
expect(response.body.passwordValidated).to.eq(true);
expect(response.body.protectedId).to.be.a("string");
expect(response.body.parents).to.have.length.at.least(0);
expect(response.body.folders).to.have.length.at.least(0);
expect(response.body.files).to.have.length.at.least(0);
expect(response.body.readmeExists).to.be.a("boolean");
expect(response.body.nextPageToken).to.satisfy(
(key: any) => typeof key === "string" || key === undefined,
);
});
});
it("Get protected file - without password", () => {
cy.request({
method: "GET",
url: `/api/files/${file}`,
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body.passwordRequired).to.eq(true);
expect(response.body.passwordValidated).to.eq(false);
expect(response.body.protectedId).to.be.a("string");
});
});
it("Get protected file - wrong password", () => {
const hashPassword = hash.hashToken("wrong password");
cy.request({
method: "GET",
url: `/api/files/${file}`,
headers: {
Authorization: `Bearer ${hashPassword}`,
},
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body.passwordRequired).to.eq(true);
expect(response.body.passwordValidated).to.eq(false);
expect(response.body.protectedId).to.be.a("string");
});
});
it("Get protected file - with password", () => {
const hashPassword = hash.hashToken("loremipsum");
// The file is in a protected folder, so the password is the same
cy.request({
method: "GET",
url: `/api/files/${file}`,
headers: {
Authorization: `Bearer ${hashPassword}`,
},
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body.passwordRequired).to.eq(true);
expect(response.body.passwordValidated).to.eq(true);
expect(response.body.protectedId).to.be.a("string");
expect(response.body.parents).to.have.length.at.least(0);
expect(response.body.file).to.have.property("id");
});
});
it("View protected file - without token", () => {
cy.request({
method: "GET",
encoding: "binary",
url: `/api/files/${file}/view`,
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body.passwordRequired).to.eq(true);
expect(response.body.passwordValidated).to.eq(false);
});
});
it("View protected file - with wrong token", () => {
const hashPassword = hash.hashToken("wrongpassword");
cy.request({
method: "GET",
encoding: "binary",
url: `/api/files/${file}/view?hash=${hashPassword}`,
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body.passwordRequired).to.eq(true);
expect(response.body.passwordValidated).to.eq(false);
});
cy.request({
method: "GET",
encoding: "binary",
url: `/api/files/${file}/download?hash=${hashPassword}`,
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body.passwordRequired).to.eq(true);
expect(response.body.passwordValidated).to.eq(false);
});
});
it("View protected file - with token", () => {
const hashPassword = hash.hashToken("loremipsum");
cy.request({
method: "GET",
encoding: "binary",
url: `/api/files/${file}/view?token=${hashPassword}`,
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.headers).have.property("content-type");
// expect(response.headers)
// .have.property("content-disposition")
// .contains("inline");
});
cy.request({
method: "GET",
encoding: "binary",
url: `/api/files/${file}/download?token=${hashPassword}`,
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.headers).have.property("content-type");
// expect(response.headers)
// .have.property("content-disposition")
// .contains("attachment");
});
});
});
describe("Protected files sub folder API", () => {
const folder = ids.protectedSubFolder;
const file = ids.protectedSubFile;
it("Get protected folder - without password", () => {
cy.request({
method: "GET",
url: `/api/files/${folder}`,
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body.passwordRequired).to.eq(true);
expect(response.body.passwordValidated).to.eq(false);
expect(response.body.protectedId).to.be.a("string");
});
});
it("Get protected folder - wrong password", () => {
const hashPassword = hash.hashToken("wrong password");
cy.request({
method: "GET",
url: `/api/files/${folder}`,
headers: {
Authorization: `Bearer ${hashPassword}`,
},
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body.passwordRequired).to.eq(true);
expect(response.body.passwordValidated).to.eq(false);
expect(response.body.protectedId).to.be.a("string");
});
});
it("Get protected folder - with password", () => {
const hashPassword = hash.hashToken("loremipsum");
cy.request({
method: "GET",
url: `/api/files/${folder}`,
headers: {
Authorization: `Bearer ${hashPassword}`,
},
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body.passwordRequired).to.eq(true);
expect(response.body.passwordValidated).to.eq(true);
expect(response.body.protectedId).to.be.a("string");
expect(response.body.parents).to.have.length.at.least(0);
expect(response.body.folders).to.have.length.at.least(0);
expect(response.body.files).to.have.length.at.least(0);
expect(response.body.readmeExists).to.be.a("boolean");
expect(response.body.nextPageToken).to.satisfy(
(key: any) => typeof key === "string" || key === undefined,
);
});
});
it("Get protected file - without password", () => {
cy.request({
method: "GET",
url: `/api/files/${file}`,
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body.passwordRequired).to.eq(true);
expect(response.body.passwordValidated).to.eq(false);
expect(response.body.protectedId).to.be.a("string");
});
});
it("Get protected file - wrong password", () => {
const hashPassword = hash.hashToken("wrong password");
cy.request({
method: "GET",
url: `/api/files/${file}`,
headers: {
Authorization: `Bearer ${hashPassword}`,
},
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body.passwordRequired).to.eq(true);
expect(response.body.passwordValidated).to.eq(false);
expect(response.body.protectedId).to.be.a("string");
});
});
it("Get protected file - with password", () => {
const hashPassword = hash.hashToken("loremipsum");
// The file is in a protected folder, so the password is the same
cy.request({
method: "GET",
url: `/api/files/${file}`,
headers: {
Authorization: `Bearer ${hashPassword}`,
},
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body.passwordRequired).to.eq(true);
expect(response.body.passwordValidated).to.eq(true);
expect(response.body.protectedId).to.be.a("string");
expect(response.body.parents).to.have.length.at.least(0);
expect(response.body.file).to.have.property("id");
});
});
it("View protected file - without token", () => {
cy.request({
method: "GET",
encoding: "binary",
url: `/api/files/${file}/view`,
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body.passwordRequired).to.eq(true);
expect(response.body.passwordValidated).to.eq(false);
});
});
it("View protected file - with wrong token", () => {
const hashPassword = hash.hashToken("wrongpassword");
cy.request({
method: "GET",
encoding: "binary",
url: `/api/files/${file}/view?hash=${hashPassword}`,
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body.passwordRequired).to.eq(true);
expect(response.body.passwordValidated).to.eq(false);
});
cy.request({
method: "GET",
encoding: "binary",
url: `/api/files/${file}/download?hash=${hashPassword}`,
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body.passwordRequired).to.eq(true);
expect(response.body.passwordValidated).to.eq(false);
});
});
it("View protected file - with token", () => {
const hashPassword = hash.hashToken("loremipsum");
cy.request({
method: "GET",
encoding: "binary",
url: `/api/files/${file}/view?token=${hashPassword}`,
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.headers).have.property("content-type");
// expect(response.headers)
// .have.property("content-disposition")
// .contains("inline");
});
cy.request({
method: "GET",
encoding: "binary",
url: `/api/files/${file}/download?token=${hashPassword}`,
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.headers).have.property("content-type");
// expect(response.headers)
// .have.property("content-disposition")
// .contains("attachment");
});
});
});
describe("Protected files inside protected API", () => {
const folder = ids.protectedInsideProtected;
const file = ids.protectedFileInsideProtected;
it("Get protected folder - without password", () => {
cy.request({
method: "GET",
url: `/api/files/${folder}`,
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body.passwordRequired).to.eq(true);
expect(response.body.passwordValidated).to.eq(false);
expect(response.body.protectedId).to.be.a("string");
});
});
it("Get protected folder - wrong password", () => {
const hashPassword = hash.hashToken("wrong password");
cy.request({
method: "GET",
url: `/api/files/${folder}`,
headers: {
Authorization: `Bearer ${hashPassword}`,
},
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body.passwordRequired).to.eq(true);
expect(response.body.passwordValidated).to.eq(false);
expect(response.body.protectedId).to.be.a("string");
});
});
it("Get protected folder - with password", () => {
const hashPassword = hash.hashToken("123");
cy.request({
method: "GET",
url: `/api/files/${folder}`,
headers: {
Authorization: `Bearer ${hashPassword}`,
},
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body.passwordRequired).to.eq(true);
expect(response.body.passwordValidated).to.eq(true);
expect(response.body.protectedId).to.be.a("string");
expect(response.body.parents).to.have.length.at.least(0);
expect(response.body.folders).to.have.length.at.least(0);
expect(response.body.files).to.have.length.at.least(0);
expect(response.body.readmeExists).to.be.a("boolean");
expect(response.body.nextPageToken).to.satisfy(
(key: any) => typeof key === "string" || key === undefined,
);
});
});
it("Get protected file - without password", () => {
cy.request({
method: "GET",
url: `/api/files/${file}`,
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body.passwordRequired).to.eq(true);
expect(response.body.passwordValidated).to.eq(false);
expect(response.body.protectedId).to.be.a("string");
});
});
it("Get protected file - wrong password", () => {
const hashPassword = hash.hashToken("wrong password");
cy.request({
method: "GET",
url: `/api/files/${file}`,
headers: {
Authorization: `Bearer ${hashPassword}`,
},
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body.passwordRequired).to.eq(true);
expect(response.body.passwordValidated).to.eq(false);
expect(response.body.protectedId).to.be.a("string");
});
});
it("Get protected file - with password", () => {
const hashPassword = hash.hashToken("123");
// The file is in a protected folder, so the password is the same
cy.request({
method: "GET",
url: `/api/files/${file}`,
headers: {
Authorization: `Bearer ${hashPassword}`,
},
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body.passwordRequired).to.eq(true);
expect(response.body.passwordValidated).to.eq(true);
expect(response.body.protectedId).to.be.a("string");
expect(response.body.parents).to.have.length.at.least(0);
expect(response.body.file).to.have.property("id");
});
});
it("View protected file - without token", () => {
cy.request({
method: "GET",
encoding: "binary",
url: `/api/files/${file}/view`,
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body.passwordRequired).to.eq(true);
expect(response.body.passwordValidated).to.eq(false);
});
});
it("View protected file - with wrong token", () => {
const hashPassword = hash.hashToken("wrongpassword");
cy.request({
method: "GET",
encoding: "binary",
url: `/api/files/${file}/view?hash=${hashPassword}`,
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body.passwordRequired).to.eq(true);
expect(response.body.passwordValidated).to.eq(false);
});
cy.request({
method: "GET",
encoding: "binary",
url: `/api/files/${file}/download?hash=${hashPassword}`,
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body.passwordRequired).to.eq(true);
expect(response.body.passwordValidated).to.eq(false);
});
});
it("View protected file - with token", () => {
const hashPassword = hash.hashToken("123");
cy.request({
method: "GET",
encoding: "binary",
url: `/api/files/${file}/view?token=${hashPassword}`,
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.headers).have.property("content-type");
// expect(response.headers)
// .have.property("content-disposition")
// .contains("inline");
});
cy.request({
method: "GET",
encoding: "binary",
url: `/api/files/${file}/download?token=${hashPassword}`,
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.headers).have.property("content-type");
// expect(response.headers)
// .have.property("content-disposition")
// .contains("attachment");
});
});
});
-5
View File
@@ -1,5 +0,0 @@
{
"name": "Using fixtures to represent data",
"email": "hello@cypress.io",
"body": "Fixtures are a great way to mock data for responses to routes"
}
-37
View File
@@ -1,37 +0,0 @@
/// <reference types="cypress" />
// ***********************************************
// This example commands.ts shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
//
// declare global {
// namespace Cypress {
// interface Chainable {
// login(email: string, password: string): Chainable<void>
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
// }
// }
// }
-20
View File
@@ -1,20 +0,0 @@
// ***********************************************************
// This example support/e2e.ts is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************
// Import commands.js using ES2015 syntax:
import './commands'
// Alternatively you can use CommonJS syntax:
// require('./commands')