1 | package edu.ucsb.cs156.frontiers.startup; | |
2 | ||
3 | import edu.ucsb.cs156.frontiers.entities.Admin; | |
4 | import edu.ucsb.cs156.frontiers.repositories.AdminRepository; | |
5 | import java.util.List; | |
6 | import lombok.extern.slf4j.Slf4j; | |
7 | import org.springframework.beans.factory.annotation.Autowired; | |
8 | import org.springframework.beans.factory.annotation.Value; | |
9 | import org.springframework.stereotype.Component; | |
10 | ||
11 | /** This class contains a `run` method that is called once at application startup time. */ | |
12 | @Slf4j | |
13 | @Component | |
14 | public class FrontiersStartup { | |
15 | ||
16 | @Value("#{'${app.admin.emails}'.split(',')}") | |
17 | List<String> adminEmails; | |
18 | ||
19 | @Value("${app.webhook.secret}") | |
20 | String webhookSecret; | |
21 | ||
22 | @Autowired AdminRepository adminRepository; | |
23 | ||
24 | /** | |
25 | * Called once at application startup time . Put code here if you want it to run once each time | |
26 | * the Spring Boot application starts up in all environments. | |
27 | */ | |
28 | public void alwaysRunOnStartup() { | |
29 | log.info("alwaysRunOnStartup called"); | |
30 | ||
31 |
1
1. alwaysRunOnStartup : removed call to edu/ucsb/cs156/frontiers/startup/FrontiersStartup::validateWebhookSecret → KILLED |
validateWebhookSecret(); |
32 | ||
33 | try { | |
34 |
1
1. alwaysRunOnStartup : removed call to java/util/List::forEach → KILLED |
adminEmails.forEach( |
35 | (email) -> { | |
36 | Admin admin = new Admin(email); | |
37 | adminRepository.save(admin); | |
38 | }); | |
39 | } catch (Exception e) { | |
40 | log.error("Error in loading all ADMIN_EMAILS:", e); | |
41 | } | |
42 | } | |
43 | ||
44 | private void validateWebhookSecret() { | |
45 |
3
1. validateWebhookSecret : negated conditional → KILLED 2. validateWebhookSecret : negated conditional → KILLED 3. validateWebhookSecret : changed conditional boundary → KILLED |
if (webhookSecret == null || webhookSecret.length() < 10) { |
46 | String error = | |
47 | String.format( | |
48 | "WEBHOOK_SECRET must be at least 10 characters long. Current length: %d", | |
49 |
1
1. validateWebhookSecret : negated conditional → KILLED |
webhookSecret == null ? 0 : webhookSecret.length()); |
50 | log.error(error); | |
51 | throw new IllegalStateException(error); | |
52 | } | |
53 | log.info("Webhook secret validation passed"); | |
54 | } | |
55 | } | |
Mutations | ||
31 |
1.1 |
|
34 |
1.1 |
|
45 |
1.1 2.2 3.3 |
|
49 |
1.1 |