-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Keep track of expired stripe sessions (#11)
* Add checkExpiredStripeSessions() method into StripePaymentServiceImpl * Add renewPaymentSession() method into PaymentController, StripePaymentServiceImpl * Add isAllowedToRentCar() method into RentalServiceImpl * remove field 'user' from 'Payment' * add CarServiceTest * add RentalServiceTest * add UserServiceTest * add TelegramUserServiceTest * add TelegramNotificationServiceTest * add StripePaymentServiceTest * add Dockerfile, docker-compose.yml * add columnDefinition = "TINYINT" to boolean fields * finish tests * add custom annotation @UserRoleDescription to print roles in swagger doc. * Update ci.yml * Update ci.yml * Update ci.yml
- Loading branch information
1 parent
86e6bb0
commit 70487ec
Showing
44 changed files
with
1,907 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Builder stage | ||
FROM openjdk:17-jdk-alpine as builder | ||
WORKDIR application | ||
ARG JAR_FILE=target/*.jar | ||
COPY ${JAR_FILE} application.jar | ||
RUN java -Djarmode=layertools -jar application.jar extract | ||
|
||
# Final stage | ||
FROM openjdk:17-jdk-alpine | ||
WORKDIR application | ||
COPY --from=builder application/dependencies/ ./ | ||
COPY --from=builder application/spring-boot-loader/ ./ | ||
COPY --from=builder application/snapshot-dependencies/ ./ | ||
COPY --from=builder application/application/ ./ | ||
ENTRYPOINT ["java", "org.springframework.boot.loader.launch.JarLauncher"] | ||
EXPOSE 8080 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: car-sharing-application | ||
services: | ||
mysqldb: | ||
image: mysql:8.0.36-oracle | ||
restart: unless-stopped | ||
env_file: | ||
- ./.env | ||
environment: | ||
- MYSQL_DATABASE=$MYSQLDB_DATABASE | ||
- MYSQL_ROOT_PASSWORD=$MYSQLDB_ROOT_PASSWORD | ||
ports: | ||
- $MYSQLDB_LOCAL_PORT:$MYSQLDB_DOCKER_PORT | ||
healthcheck: | ||
test: [ "CMD-SHELL", "mysqladmin ping -h localhost -u${MYSQLDB_USER} -p${MYSQLDB_ROOT_PASSWORD}" ] | ||
interval: 30s | ||
timeout: 30s | ||
retries: 30 | ||
app: | ||
depends_on: | ||
- mysqldb | ||
image: car-sharing-image | ||
restart: on-failure | ||
container_name: app | ||
build: . | ||
env_file: ./.env | ||
ports: | ||
- $SPRING_LOCAL_PORT:$SPRING_DOCKER_PORT | ||
- $DEBUG_PORT:$DEBUG_PORT | ||
environment: | ||
SPRING_APPLICATION_JSON: '{ | ||
"spring.datasource.url" : "jdbc:mysql://mysqldb:$MYSQLDB_DOCKER_PORT/$MYSQLDB_DATABASE?createDatabaseIfNotExist=true&characterEncoding=UTF-8&serverTimezone=UTC", | ||
"spring.datasource.username" : "$MYSQLDB_USER", | ||
"spring.datasource.password" : "$MYSQLDB_ROOT_PASSWORD", | ||
"spring.jpa.hibernate.ddl-auto" : "validate", | ||
"spring.jpa.show-sql" : "true", | ||
"jwt.expiration" : "$JWT_EXPIRATION_TIME", | ||
"jwt.secret" : "$JWT_SECRET", | ||
"STRIPE_APY_KEY" : "$STRIPE_APY_KEY", | ||
"STRIPE_SUCCESS_LINK" : "$STRIPE_SUCCESS_LINK", | ||
"STRIPE_CANCEL_LINK" : "$STRIPE_CANCEL_LINK", | ||
"TELEGRAM_BOT_TOKEN" : "$TELEGRAM_BOT_TOKEN", | ||
"TELEGRAM_BOT_USERNAME" : "$TELEGRAM_BOT_USERNAME" | ||
}' | ||
JAVA_TOOL_OPTIONS: "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/main/java/mate/academy/carsharing/annotation/UserRoleDescription.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package mate.academy.carsharing.annotation; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Target({ElementType.METHOD}) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface UserRoleDescription { | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/mate/academy/carsharing/annotation/UserRoleDescriptionCustomizer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package mate.academy.carsharing.annotation; | ||
|
||
import io.swagger.v3.oas.models.Operation; | ||
import org.springdoc.core.customizers.OperationCustomizer; | ||
import org.springframework.security.access.prepost.PreAuthorize; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.method.HandlerMethod; | ||
|
||
@Component | ||
public class UserRoleDescriptionCustomizer implements OperationCustomizer { | ||
@Override | ||
public Operation customize(Operation operation, HandlerMethod handlerMethod) { | ||
UserRoleDescription userRoleAnnotation = | ||
handlerMethod.getMethodAnnotation(UserRoleDescription.class); | ||
if (userRoleAnnotation != null) { | ||
PreAuthorize preAuthorizeAnnotation = | ||
handlerMethod.getMethodAnnotation(PreAuthorize.class); | ||
if (preAuthorizeAnnotation != null | ||
&& preAuthorizeAnnotation.value().contains("ROLE_")) { | ||
String description = operation.getDescription() == null | ||
? "" : (operation.getDescription()/* + "\n"*/); | ||
int firstBraceIndex = preAuthorizeAnnotation.value().indexOf('('); | ||
int lastBraceIndex = preAuthorizeAnnotation.value().lastIndexOf(')'); | ||
String rolesString = preAuthorizeAnnotation.value() | ||
.substring(firstBraceIndex + 1, lastBraceIndex); | ||
operation.setDescription(description + " Required roles: " + rolesString + '.'); | ||
} | ||
} | ||
return operation; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/mate/academy/carsharing/config/OpenApiConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package mate.academy.carsharing.config; | ||
|
||
import io.swagger.v3.oas.annotations.OpenAPIDefinition; | ||
import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; | ||
import io.swagger.v3.oas.annotations.info.Info; | ||
import io.swagger.v3.oas.annotations.security.SecurityRequirement; | ||
import io.swagger.v3.oas.annotations.security.SecurityScheme; | ||
import io.swagger.v3.oas.annotations.security.SecuritySchemes; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
@OpenAPIDefinition(info = @Info(title = "Car-Sharing-App REST API", version = "1.0", | ||
description = "REST API for Car-Sharing-App. Register, Login and use JWT token."), | ||
security = {@SecurityRequirement(name = "bearerToken")} | ||
) | ||
@SecuritySchemes({@SecurityScheme(name = "bearerToken", type = SecuritySchemeType.HTTP, | ||
scheme = "bearer", bearerFormat = "JWT")} | ||
) | ||
public class OpenApiConfig { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.