From 6208d21a98a42e179afea192a2b0436c01e5345b Mon Sep 17 00:00:00 2001 From: mbaharip <62494292+mbahArip@users.noreply.github.com> Date: Mon, 11 Sep 2023 05:12:57 +0700 Subject: [PATCH] =?UTF-8?q?=E2=8F=AA=20rollback:=20Remove=20cypress?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cypress.config.ts | 10 - cypress/e2e/api.cy.ts | 569 ---------------------------------- cypress/fixtures/example.json | 5 - cypress/support/commands.ts | 37 --- cypress/support/e2e.ts | 20 -- 5 files changed, 641 deletions(-) delete mode 100644 cypress.config.ts delete mode 100644 cypress/e2e/api.cy.ts delete mode 100644 cypress/fixtures/example.json delete mode 100644 cypress/support/commands.ts delete mode 100644 cypress/support/e2e.ts diff --git a/cypress.config.ts b/cypress.config.ts deleted file mode 100644 index 771ede0..0000000 --- a/cypress.config.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { defineConfig } from "cypress"; - -export default defineConfig({ - e2e: { - baseUrl: "http://localhost:5000", - setupNodeEvents(on, config) { - // implement node event listeners here - }, - }, -}); diff --git a/cypress/e2e/api.cy.ts b/cypress/e2e/api.cy.ts deleted file mode 100644 index 65afa9b..0000000 --- a/cypress/e2e/api.cy.ts +++ /dev/null @@ -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"); - }); - }); -}); diff --git a/cypress/fixtures/example.json b/cypress/fixtures/example.json deleted file mode 100644 index 02e4254..0000000 --- a/cypress/fixtures/example.json +++ /dev/null @@ -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" -} diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts deleted file mode 100644 index 698b01a..0000000 --- a/cypress/support/commands.ts +++ /dev/null @@ -1,37 +0,0 @@ -/// -// *********************************************** -// 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 -// drag(subject: string, options?: Partial): Chainable -// dismiss(subject: string, options?: Partial): Chainable -// visit(originalFn: CommandOriginalFn, url: string, options: Partial): Chainable -// } -// } -// } \ No newline at end of file diff --git a/cypress/support/e2e.ts b/cypress/support/e2e.ts deleted file mode 100644 index f80f74f..0000000 --- a/cypress/support/e2e.ts +++ /dev/null @@ -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') \ No newline at end of file