Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@

jobs:
build:
uses: valitydev/java-workflow/.github/workflows/maven-service-build.yml@v3
uses: valitydev/java-workflow/.github/workflows/maven-service-build.yml@v3

Check failure on line 10 in .github/workflows/build.yml

View workflow job for this annotation

GitHub Actions / lint / yamllint

wrong indentation: expected 4 but found 6

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}

Copilot Autofix

AI 21 days ago

In general, this issue is fixed by explicitly declaring a permissions block either at the top level of the workflow (applying to all jobs) or on the specific job, granting only the minimal scopes required. Since this workflow only contains the single build job that calls a reusable workflow, and we must not change functionality, the safest minimal fix is to set contents: read on that job (a conservative baseline that still allows common operations like checking out code, but avoids broad write permissions).

Concretely, in .github/workflows/build.yml, under jobs:, for the build job that currently only has a uses: line, we add a permissions: section at the same indentation level as uses:. For example:

jobs:
  build:
    permissions:
      contents: read
    uses: ...

This constrains the GITHUB_TOKEN permissions for that job without altering the rest of the workflow behavior. No additional methods, imports, or external definitions are required; this is a pure YAML configuration change.

Suggested changeset 1
.github/workflows/build.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -7,4 +7,6 @@
 
 jobs:
   build:
-      uses: valitydev/java-workflow/.github/workflows/maven-service-build.yml@v3
+    permissions:
+      contents: read
+    uses: valitydev/java-workflow/.github/workflows/maven-service-build.yml@v3
EOF
@@ -7,4 +7,6 @@

jobs:
build:
uses: valitydev/java-workflow/.github/workflows/maven-service-build.yml@v3
permissions:
contents: read
uses: valitydev/java-workflow/.github/workflows/maven-service-build.yml@v3
Copilot is powered by AI and may make mistakes. Always verify output.
30 changes: 21 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>dev.vality</groupId>
<artifactId>service-parent-pom</artifactId>
<version>3.1.7</version>
<version>3.1.9</version>
</parent>

<artifactId>daway</artifactId>
Expand All @@ -33,6 +33,18 @@
<flyway.postgresql.transactional.lock>false</flyway.postgresql.transactional.lock>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers-bom</artifactId>
<version>2.0.3</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<!--spring -->
<dependency>
Expand Down Expand Up @@ -165,12 +177,12 @@
<dependency>
<groupId>dev.vality</groupId>
<artifactId>damsel</artifactId>
<version>1.674-368f05b</version>
<version>1.682-dfd6648</version>
</dependency>
<dependency>
<groupId>dev.vality</groupId>
<artifactId>fistful-proto</artifactId>
<version>1.185-b30fa2a</version>
<version>1.188-f7ce08e</version>
</dependency>
<dependency>
<groupId>dev.vality</groupId>
Expand Down Expand Up @@ -202,12 +214,6 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>dev.vality</groupId>
<artifactId>testcontainers-annotations</artifactId>
<version>2.0.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
Expand All @@ -219,6 +225,12 @@
<artifactId>junit-platform-launcher</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>dev.vality</groupId>
<artifactId>testcontainers-annotations</artifactId>
<version>4.1.3</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ public void handle(TimestampedChange timestampedChange, MachineEvent event) {
withdrawal.setAmount(cash.getAmount());
withdrawal.setCurrencyCode(cash.getCurrency().getSymbolicCode());
withdrawal.setWithdrawalStatus(WithdrawalStatus.pending);
if (withdrawalDamsel.isSetContactInfo() && withdrawalDamsel.getContactInfo().isSetEmail()) {
withdrawal.setCustomerId(withdrawalDamsel.getContactInfo().email);
}
if (withdrawalDamsel.getRoute() != null && withdrawalDamsel.getRoute().isSetTerminalId()) {
withdrawal.setTerminalId(String.valueOf(withdrawalDamsel.getRoute().getTerminalId()));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE dw.withdrawal ADD COLUMN IF NOT EXISTS customer_id character varying;
2 changes: 1 addition & 1 deletion src/test/java/dev/vality/daway/IntegrationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

@Slf4j
@PostgresqlSpringBootITest
@Sql(scripts = {"classpath:sql/partition_idx.sql"}, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_CLASS)
@Sql(scripts = {"classpath:sql/partition_idx.sql"}, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
class IntegrationTest {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package dev.vality.daway.config;

import dev.vality.daway.kafka.KafkaProducer;
import dev.vality.testcontainers.annotations.DefaultSpringBootTest;
import dev.vality.testcontainers.annotations.KafkaTestConfig;
import dev.vality.testcontainers.annotations.kafka.KafkaTestcontainerSingleton;
import dev.vality.testcontainers.annotations.postgresql.PostgresqlTestcontainerSingleton;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.Import;

import java.lang.annotation.ElementType;
Expand Down Expand Up @@ -42,7 +43,8 @@
"kafka.topics.limit-config.id",
"kafka.topics.exrate.id"}
)
@DefaultSpringBootTest
@SpringBootTest
@KafkaTestConfig
@Import(KafkaProducer.class)
public @interface KafkaPostgresqlSpringBootITest {
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import dev.vality.testcontainers.annotations.postgresql.PostgresqlTestcontainerSingleton;
import org.springframework.boot.test.autoconfigure.jooq.JooqTest;
import org.springframework.boot.test.context.SpringBootTest;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package dev.vality.daway.config;

import dev.vality.testcontainers.annotations.DefaultSpringBootTest;
import dev.vality.testcontainers.annotations.postgresql.PostgresqlTestcontainerSingleton;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.DirtiesContext;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
Expand All @@ -10,7 +11,7 @@

@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@SpringBootTest
@PostgresqlTestcontainerSingleton
@DefaultSpringBootTest
public @interface PostgresqlSpringBootITest {
}
5 changes: 3 additions & 2 deletions src/test/java/dev/vality/daway/dao/DaoTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,16 +212,17 @@ void invoiceCartDaoTest() {

@Test
void paymentRecurrentInfoDaoTest() {
Random random = new Random();
jdbcTemplate.execute("truncate table dw.payment_recurrent_info cascade");
List<PaymentRecurrentInfo> list = RandomBeans.randomListOf(2, PaymentRecurrentInfo.class);
List<PaymentRecurrentInfo> list = RandomBeans.randomListOf(random.nextLong(), 2, PaymentRecurrentInfo.class);
list.forEach(statusInfo -> statusInfo.setCurrent(true));
paymentRecurrentInfoDao.saveBatch(list);
PaymentRecurrentInfo first = list.get(0);
assertEquals(first, paymentRecurrentInfoDao.get(first.getInvoiceId(), first.getPaymentId()));
PaymentRecurrentInfo second = list.get(1);
assertEquals(second, paymentRecurrentInfoDao.get(second.getInvoiceId(), second.getPaymentId()));

PaymentRecurrentInfo third = RandomBeans.random(PaymentRecurrentInfo.class);
PaymentRecurrentInfo third = RandomBeans.random(random.nextLong(), PaymentRecurrentInfo.class);
third.setId(first.getId() + 1);
third.setCurrent(false);
third.setInvoiceId(first.getInvoiceId());
Expand Down
11 changes: 7 additions & 4 deletions src/test/java/dev/vality/daway/dao/partition/DaoTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.time.temporal.ChronoUnit;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.Set;

import static dev.vality.daway.domain.tables.Invoice.INVOICE;
Expand Down Expand Up @@ -110,10 +111,11 @@ void invoiceStatusInfoDaoTest() {

@Test
void paymentDaoTest() {
Payment first = RandomBeans.random(Payment.class);
Random random = new Random();
Payment first = RandomBeans.random(random.nextLong(100), Payment.class);
first.setId(1L);
first.setEventCreatedAt(LocalDateTime.now().truncatedTo(ChronoUnit.SECONDS));
Payment second = RandomBeans.random(Payment.class);
Payment second = RandomBeans.random(random.nextLong(100),Payment.class);
second.setId(2L);
second.setEventCreatedAt(LocalDateTime.now().truncatedTo(ChronoUnit.SECONDS));
paymentDao.saveBatch(Arrays.asList(first, second));
Expand Down Expand Up @@ -145,9 +147,10 @@ void paymentStatusInfoDaoTest() {

@Test
void paymentPayerInfoDaoTest() {
PaymentPayerInfo first = RandomBeans.random(PaymentPayerInfo.class);
Random random = new Random();
PaymentPayerInfo first = RandomBeans.random(random.nextLong(100), PaymentPayerInfo.class);
first.setId(1L);
PaymentPayerInfo second = RandomBeans.random(PaymentPayerInfo.class);
PaymentPayerInfo second = RandomBeans.random(random.nextLong(100), PaymentPayerInfo.class);
second.setId(2L);
paymentPayerInfoDao.saveBatch(Arrays.asList(first, second));
assertEquals(first, paymentPayerInfoDao.get(first.getInvoiceId(), first.getPaymentId()));
Expand Down
5 changes: 3 additions & 2 deletions src/test/java/dev/vality/daway/kafka/KafkaProducer.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import dev.vality.damsel.domain_config_v2.HistoricalCommit;
import dev.vality.machinegun.eventsink.MachineEvent;
import dev.vality.machinegun.eventsink.SinkEvent;
import dev.vality.testcontainers.annotations.kafka.config.KafkaProducerConfig;
import dev.vality.testcontainers.annotations.KafkaTestConfig;
import dev.vality.testcontainers.annotations.kafka.config.KafkaProducerTestConfig;
import lombok.extern.slf4j.Slf4j;
import org.apache.thrift.TBase;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -17,7 +18,7 @@
import java.util.Collections;

@TestComponent
@Import(KafkaProducerConfig.class)
@Import(KafkaProducerTestConfig.class)
@Slf4j
public class KafkaProducer {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import static org.junit.jupiter.api.Assertions.*;

@PostgresqlSpringBootITest
@Sql(scripts = {"classpath:sql/partition_idx.sql"}, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_CLASS)
@Sql(scripts = {"classpath:sql/partition_idx.sql"}, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
class IntegrationInvoicingServiceTest {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.springframework.test.context.jdbc.Sql;

import java.util.List;
import java.util.Random;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

Expand All @@ -23,7 +24,7 @@
import static org.junit.jupiter.api.Assertions.*;

@PostgresqlSpringBootITest
@Sql(scripts = {"classpath:sql/partition_idx.sql"}, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_CLASS)
@Sql(scripts = {"classpath:sql/partition_idx.sql"}, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
class InvoiceWrapperServiceTest {

@Autowired
Expand Down Expand Up @@ -59,11 +60,12 @@ void duplicationTest() {
}

private List<InvoiceWrapper> prepareInvoiceWrappers() {
Random random = new Random();
List<InvoiceWrapper> invoiceWrappers = IntStream.range(1, 5)
.mapToObj(x -> new InvoiceWrapper(
RandomBeans.random(Invoice.class, "id"),
RandomBeans.random(InvoiceStatusInfo.class, "id", "invoiceId"),
RandomBeans.randomListOf(3, InvoiceCart.class, "id", "invoiceId")))
RandomBeans.random(random.nextLong(), Invoice.class, "id"),
RandomBeans.random(random.nextLong(), InvoiceStatusInfo.class, "id", "invoiceId"),
RandomBeans.randomListOf(random.nextLong(), 3, InvoiceCart.class, "id", "invoiceId")))
.collect(Collectors.toList());

invoiceWrappers.forEach(iw -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@
import java.time.temporal.ChronoUnit;
import java.util.HashSet;
import java.util.List;
import java.util.Random;

import static dev.vality.daway.utils.JdbcUtil.countEntities;
import static dev.vality.daway.utils.JdbcUtil.countPaymentEntity;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;

@PostgresqlSpringBootITest
@Sql(scripts = {"classpath:sql/partition_idx.sql"}, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_CLASS)
@Sql(scripts = {"classpath:sql/partition_idx.sql"}, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
class PaymentWrapperServiceTest {

@Autowired
Expand Down Expand Up @@ -88,14 +89,15 @@ void duplicationTest() {
}

private List<PaymentWrapper> preparePaymentWrappers() {
Random random = new Random();
List<PaymentWrapper> paymentWrappers = RandomBeans.randomListOf(2, PaymentWrapper.class);
paymentWrappers.stream()
.map(PaymentWrapper::getPayment)
.forEach(payment -> payment.setEventCreatedAt(LocalDateTime.now().truncatedTo(ChronoUnit.SECONDS)));
paymentWrappers.forEach(pw -> {
pw.setCashFlowWrapper(new CashFlowWrapper(
RandomBeans.random(CashFlowLink.class),
RandomBeans.randomListOf(3, CashFlow.class)
RandomBeans.randomListOf(random.nextLong(100), 3, CashFlow.class)
));
pw.getCashFlowWrapper().getCashFlows().forEach(cf -> cf.setObjType(PaymentChangeType.payment));
PaymentWrapperTestUtil.setCurrent(pw, true);
Expand Down
5 changes: 3 additions & 2 deletions src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<root level="warn">
<appender-ref ref="CONSOLE"/>
</root>
<logger name="com.empayre" level="ALL"/>
<logger name="dev.vality" level="ALL"/>
<logger name="com.empayre" level="INFO"/>
<logger name="dev.vality" level="INFO"/>
<logger name="org.apache" level="ERROR"/>
</configuration>
Loading