• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

juice-shop / juice-shop / 20272126283

16 Dec 2025 12:20PM UTC coverage: 86.917% (+0.2%) from 86.703%
20272126283

push

github

bkimminich
Adjust test to changes in lock behavior and removing feedback

1293 of 1695 branches covered (76.28%)

Branch coverage included in aggregate %.

5397 of 6002 relevant lines covered (89.92%)

41.29 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.89
/frontend/src/app/data-export/data-export.component.ts
1
/*
2
 * Copyright (c) 2014-2026 Bjoern Kimminich & the OWASP Juice Shop contributors.
3
 * SPDX-License-Identifier: MIT
4
 */
5

6
import { Component, type OnInit, inject } from '@angular/core'
7
import { UntypedFormControl, Validators, FormsModule, ReactiveFormsModule } from '@angular/forms'
8
import { ImageCaptchaService } from '../Services/image-captcha.service'
9
import { DataSubjectService } from '../Services/data-subject.service'
10
import { DomSanitizer } from '@angular/platform-browser'
11
import { MatButtonModule } from '@angular/material/button'
12
import { MatInputModule } from '@angular/material/input'
13
import { MatLabel, MatFormFieldModule, MatHint, MatError } from '@angular/material/form-field'
14
import { MatRadioGroup, MatRadioButton } from '@angular/material/radio'
15

16
import { TranslateModule } from '@ngx-translate/core'
17
import { MatCardModule } from '@angular/material/card'
18

19
import { MatIconModule } from '@angular/material/icon'
20

21
@Component({
22
  selector: 'app-data-export',
23
  templateUrl: './data-export.component.html',
24
  styleUrls: ['./data-export.component.scss'],
25
  imports: [MatCardModule, TranslateModule, MatRadioGroup, FormsModule, ReactiveFormsModule, MatLabel, MatRadioButton, MatFormFieldModule, MatInputModule, MatHint, MatError, MatButtonModule, MatIconModule]
26
})
27
export class DataExportComponent implements OnInit {
1✔
28
  sanitizer = inject(DomSanitizer)
7✔
29
  private readonly imageCaptchaService = inject(ImageCaptchaService)
7✔
30
  private readonly dataSubjectService = inject(DataSubjectService)
7✔
31

32
  public captchaControl: UntypedFormControl = new UntypedFormControl('', [Validators.required, Validators.minLength(5)])
7✔
33
  public formatControl: UntypedFormControl = new UntypedFormControl('', [Validators.required])
7✔
34
  public captcha: any
35
  private dataRequest: any = undefined
7✔
36
  public confirmation: any
37
  public error: any
38
  public lastSuccessfulTry: any
39
  public presenceOfCaptcha = false
7✔
40
  public userData: any
41
  ngOnInit (): void {
42
    this.needCaptcha()
7✔
43
    this.dataRequest = {}
7✔
44
  }
45

46
  needCaptcha () {
47
    const nowTime = new Date()
7✔
48
    const timeOfCaptcha = localStorage.getItem('lstdtxprt') ? new Date(JSON.parse(String(localStorage.getItem('lstdtxprt')))) : new Date(0)
7✔
49
    if (nowTime.getTime() - timeOfCaptcha.getTime() < 300000) {
7✔
50
      this.getNewCaptcha()
2✔
51
      this.presenceOfCaptcha = true
2✔
52
    }
53
  }
54

55
  getNewCaptcha () {
56
    this.imageCaptchaService.getCaptcha().subscribe((data: any) => {
3✔
57
      this.captcha = this.sanitizer.bypassSecurityTrustHtml(data.image)
3✔
58
    })
59
  }
60

61
  save () {
62
    if (this.presenceOfCaptcha) {
2!
63
      this.dataRequest.answer = this.captchaControl.value
×
64
    }
65
    this.dataRequest.format = this.formatControl.value
2✔
66
    this.dataSubjectService.dataExport(this.dataRequest).subscribe({
2✔
67
      next: (data: any) => {
68
        this.error = null
1✔
69
        this.confirmation = data.confirmation
1✔
70
        this.userData = data.userData
1✔
71
        window.open('', '_blank', 'width=500')?.document.write(this.userData)
1✔
72
        this.lastSuccessfulTry = new Date()
1✔
73
        localStorage.setItem('lstdtxprt', JSON.stringify(this.lastSuccessfulTry))
1✔
74
        this.ngOnInit()
1✔
75
        this.resetForm()
1✔
76
      },
77
      error: (error) => {
78
        this.error = error.error
1✔
79
        this.confirmation = null
1✔
80
        this.resetFormError()
1✔
81
      }
82
    })
83
  }
84

85
  resetForm () {
86
    this.captchaControl.markAsUntouched()
1✔
87
    this.captchaControl.markAsPristine()
1✔
88
    this.captchaControl.setValue('')
1✔
89
    this.formatControl.markAsUntouched()
1✔
90
    this.formatControl.markAsPristine()
1✔
91
    this.formatControl.setValue('')
1✔
92
  }
93

94
  resetFormError () {
95
    this.captchaControl.markAsUntouched()
×
96
    this.captchaControl.markAsPristine()
×
97
    this.captchaControl.setValue('')
×
98
  }
99
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc