juice-shop

Форк
0
/
cypress.config.ts 
99 строк · 3.4 Кб
1
import { defineConfig } from 'cypress'
2
import * as security from './lib/insecurity'
3
import config from 'config'
4
import type { Memory as MemoryConfig, Product as ProductConfig } from './lib/config.types'
5
import * as utils from './lib/utils'
6
import * as otplib from 'otplib'
7

8
export default defineConfig({
9
  projectId: '3hrkhu',
10
  defaultCommandTimeout: 10000,
11
  e2e: {
12
    baseUrl: 'http://localhost:3000',
13
    specPattern: 'test/cypress/e2e/**.spec.ts',
14
    downloadsFolder: 'test/cypress/downloads',
15
    fixturesFolder: false,
16
    supportFile: 'test/cypress/support/e2e.ts',
17
    setupNodeEvents (on: any) {
18
      on('before:browser:launch', (browser: any = {}, launchOptions: any) => { // TODO Remove after upgrade to Cypress >=12.5.0 <or> Chrome 119 become available on GitHub Workflows, see https://github.com/cypress-io/cypress-documentation/issues/5479
19
        if (browser.name === 'chrome' && browser.isHeadless) {
20
          launchOptions.args = launchOptions.args.map((arg: any) => {
21
            if (arg === '--headless') {
22
              return '--headless=new'
23
            }
24

25
            return arg
26
          })
27
        }
28
        return launchOptions
29
      })
30

31
      on('task', {
32
        GenerateCoupon (discount: number) {
33
          return security.generateCoupon(discount)
34
        },
35
        GetBlueprint () {
36
          for (const product of config.get<ProductConfig[]>('products')) {
37
            if (product.fileForRetrieveBlueprintChallenge) {
38
              const blueprint = product.fileForRetrieveBlueprintChallenge
39
              return blueprint
40
            }
41
          }
42
        },
43
        GetChristmasProduct () {
44
          return config.get<ProductConfig[]>('products').filter(
45
            (product) => product.useForChristmasSpecialChallenge
46
          )[0]
47
        },
48
        GetCouponIntent () {
49
          const trainingData = require(`data/chatbot/${utils.extractFilename(
50
            config.get('application.chatBot.trainingData')
51
          )}`)
52
          const couponIntent = trainingData.data.filter(
53
            (data: { intent: string }) => data.intent === 'queries.couponCode'
54
          )[0]
55
          return couponIntent
56
        },
57
        GetFromMemories (property: string) {
58
          for (const memory of config.get<MemoryConfig[]>('memories') as any) {
59
            if (memory[property]) {
60
              return memory[property]
61
            }
62
          }
63
        },
64
        GetFromConfig (variable: string) {
65
          return config.get(variable)
66
        },
67
        GetOverwriteUrl () {
68
          return config.get('challenges.overwriteUrlForProductTamperingChallenge')
69
        },
70
        GetPastebinLeakProduct () {
71
          return config.get<ProductConfig[]>('products').filter(
72
            (product) => product.keywordsForPastebinDataLeakChallenge
73
          )[0]
74
        },
75
        GetTamperingProductId () {
76
          const products = config.get<ProductConfig[]>('products')
77
          for (let i = 0; i < products.length; i++) {
78
            if (products[i].urlForProductTamperingChallenge) {
79
              return i + 1
80
            }
81
          }
82
        },
83
        GenerateAuthenticator (inputString: string) {
84
          return otplib.authenticator.generate(inputString)
85
        },
86
        toISO8601 () {
87
          const date = new Date()
88
          return utils.toISO8601(date)
89
        },
90
        isDocker () {
91
          return utils.isDocker()
92
        },
93
        isWindows () {
94
          return utils.isWindows()
95
        }
96
      })
97
    }
98
  }
99
})
100

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.