Merge pull request 'tibor' (#1) from tibor into master

Reviewed-on: https://git.workouttest.org/bossanyit/aitrainer_server/pulls/1
This commit is contained in:
bossanyit 2022-11-25 17:26:41 +00:00
commit 0fd8bc7502
14 changed files with 52 additions and 17 deletions

View File

@ -11,7 +11,7 @@ plugins {
} }
group = "com.aitrainer" group = "com.aitrainer"
version = "1.0.56" version = "1.0.57"
java.sourceCompatibility = JavaVersion.VERSION_1_8 java.sourceCompatibility = JavaVersion.VERSION_1_8
repositories { repositories {

View File

@ -0,0 +1,5 @@
START TRANSACTION;
UPDATE configuration set config_value = "1.0.57", date_change=CURRENT_DATE WHERE config_key = "db_version";
COMMIT;

View File

@ -9,7 +9,6 @@ import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.builder.SpringApplicationBuilder import org.springframework.boot.builder.SpringApplicationBuilder
import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Bean
@SpringBootApplication @SpringBootApplication
class ApiApplication { class ApiApplication {
@Bean(name = ["jasyptStringEncryptor"]) @Bean(name = ["jasyptStringEncryptor"])

View File

@ -83,6 +83,17 @@ class CustomerController ( private val customerRepository: CustomerRepository) {
return ResponseEntity.ok().body(customerRepository.save(returnCustomer)) return ResponseEntity.ok().body(customerRepository.save(returnCustomer))
} }
@Secured
@PostMapping("customers/deactivate/{id}")
fun deactivateCustomer(@PathVariable(value = "id") customerId: Long): ResponseEntity<Customer> {
logger.info("Get customer id: $customerId")
val returnCustomer: Customer = customerRepository.findById(customerId).orElse(null)
?: return ResponseEntity.notFound().build()
returnCustomer.active = "N"
return ResponseEntity.ok().body(customerRepository.save(returnCustomer))
}
@Secured @Secured
@PostMapping("/customers/{id}") @PostMapping("/customers/{id}")
fun updateCustomerById(@PathVariable(value = "id") customerId: Long, fun updateCustomerById(@PathVariable(value = "id") customerId: Long,

View File

@ -22,3 +22,4 @@ class PropertyServiceForJasyptStarter {
return environment.getProperty("server.ssl.key-store-password") return environment.getProperty("server.ssl.key-store-password")
} }
} }

View File

@ -1,6 +1,8 @@
spring.config.activate.on-profile=prod spring.config.activate.on-profile=prod
spring.config.use-legacy-processing = true spring.config.use-legacy-processing = true
## Spring DATASOURCE (DataSourceAutoConfiguration & DataSourceProperties)
spring.datasource.url = jdbc:mysql://mariadb-galera.db.svc.cluster.local:3307/aitrainer?serverTimezone=CET&useSSL=true&characterEncoding=UTF-8&allowPublicKeyRetrieval=true&allowMultiQueries=true
spring.datasource.username = aitrainer spring.datasource.username = aitrainer
spring.datasource.password = ENC(WZplPYr8WmrLHshesY4T6oXplK3MlUVJ) spring.datasource.password = ENC(WZplPYr8WmrLHshesY4T6oXplK3MlUVJ)
@ -12,6 +14,6 @@ logging.config=classpath:logback-spring.xml
logging.file=logs logging.file=logs
# if the database structue has been changed, increment this version number # if the database structue has been changed, increment this version number
application.version=1.0.56 application.version=1.0.57
jwt.secret=aitrainer jwt.secret=aitrainer

View File

@ -17,6 +17,6 @@ logging.config=classpath:logback-spring.xml
logging.file=logs logging.file=logs
# if the database structure has been changed, increment this version number # if the database structure has been changed, increment this version number
application.version=1.0.56 application.version=1.0.57
jwt.secret=aitrainer jwt.secret=aitrainer

View File

@ -1,6 +1,6 @@
http.port=8088 http.port=8088
server.port=8443 server.port=8443
server.ssl.enabled=true server.ssl.enabled=false
jasypt.encryptor.bean=jasyptStringEncryptor jasypt.encryptor.bean=jasyptStringEncryptor
# The format used for the keystore. It could be set to JKS in case it is a JKS file # The format used for the keystore. It could be set to JKS in case it is a JKS file

View File

@ -29,7 +29,10 @@
<!-- <logger name="org.springframework" level="DEBUG" /> <!-- <logger name="org.springframework" level="DEBUG" />
<logger name="com.github.ulisesbocchio" level="DEBUG" /> --> <logger name="org.apache.tomcat" level="DEBUG"/>
<logger name="org.apache.coyote" level="DEBUG"/>
<logger name="com.github.ulisesbocchio" level="DEBUG" />
<logger name="javax.net.ssl" level="DEBUG"/> -->
<logger name="com.aitrainer" level="INFO" /> <logger name="com.aitrainer" level="INFO" />
<logger name="org.hibernate" level="INFO" /> <logger name="org.hibernate" level="INFO" />

View File

@ -75,7 +75,6 @@ class AppCustomerPackageTest {
assertEquals(customer.trialDate, "2021-08-07 08:00:00") assertEquals(customer.trialDate, "2021-08-07 08:00:00")
assertEquals(customer.syncedDate, "2021-08-06 08:00:00") assertEquals(customer.syncedDate, "2021-08-06 08:00:00")
assertEquals(customer.firebaseRegToken, "123456789asdfghjkl") assertEquals(customer.firebaseRegToken, "123456789asdfghjkl")
assertEquals(customer.lang!!.uppercase(), "HU")
assertEquals(customer.phone, "123456") assertEquals(customer.phone, "123456")
assertEquals(customer.lifeLong, 1) assertEquals(customer.lifeLong, 1)
} }

View File

@ -182,7 +182,7 @@ class AppPackageTest {
val trainingPlanJson: String = record[1] val trainingPlanJson: String = record[1]
val type = object : TypeToken<List<TrainingPlan?>?>() {}.type val type = object : TypeToken<List<TrainingPlan?>?>() {}.type
val plans: List<TrainingPlan> = gson.fromJson(trainingPlanJson, type) val plans: List<TrainingPlan> = gson.fromJson(trainingPlanJson, type)
assertEquals(plans.size,40) assertEquals(plans.size,41)
assertEquals(plans[1].name, "Beginner Mens workout") assertEquals(plans[1].name, "Beginner Mens workout")
assertEquals(plans[1].internalName, "beginner_man") assertEquals(plans[1].internalName, "beginner_man")
assertEquals(plans[1].free, true) assertEquals(plans[1].free, true)

View File

@ -7,6 +7,8 @@ import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest import org.springframework.boot.test.context.SpringBootTest
import org.springframework.http.HttpStatus import org.springframework.http.HttpStatus
import org.springframework.http.ResponseEntity import org.springframework.http.ResponseEntity
import org.springframework.mock.web.MockHttpServletRequest
import javax.servlet.http.HttpServletRequest
import kotlin.test.assertEquals import kotlin.test.assertEquals
@SpringBootTest @SpringBootTest
@ -17,8 +19,9 @@ class AuthenticationTest {
@Test @Test
fun testAuthentication() { fun testAuthentication() {
val response: ResponseEntity<*> val response: ResponseEntity<*>
val request: HttpServletRequest = MockHttpServletRequest()
val jwtRequest = JwtRequest("bosi", "andio2009") val jwtRequest = JwtRequest("bosi", "andio2009")
response = authController.generateAuthenticationToken(jwtRequest) response = authController.generateAuthenticationToken(jwtRequest, request)
assertEquals(response.statusCode, HttpStatus.OK) assertEquals(response.statusCode, HttpStatus.OK)
} }

View File

@ -1,20 +1,13 @@
package com.aitrainer.api.test package com.aitrainer.api.test
import com.aitrainer.api.controller.CustomerActivityController import com.aitrainer.api.controller.CustomerActivityController
import com.aitrainer.api.controller.CustomerExerciseDeviceController
import com.aitrainer.api.controller.PurchaseController
import com.aitrainer.api.model.Customer
import com.aitrainer.api.model.CustomerActivity import com.aitrainer.api.model.CustomerActivity
import com.aitrainer.api.model.CustomerExerciseDevice
import com.aitrainer.api.repository.CustomerActivityRepository import com.aitrainer.api.repository.CustomerActivityRepository
import com.aitrainer.api.repository.CustomerExerciseDeviceRepository
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance import org.junit.jupiter.api.TestInstance
import org.springframework.beans.factory.annotation.Autowired import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest import org.springframework.boot.test.context.SpringBootTest
import org.springframework.http.HttpStatus
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertTrue
@SpringBootTest @SpringBootTest
@TestInstance(TestInstance.Lifecycle.PER_CLASS) @TestInstance(TestInstance.Lifecycle.PER_CLASS)

View File

@ -93,6 +93,25 @@ class CustomerTests {
customerRepository.delete(updatedCustomer) customerRepository.delete(updatedCustomer)
} }
@Test
fun testDeactivateCustomer() {
val id: Long = 90
val controller: CustomerController = CustomerController(customerRepository)
controller.deactivateCustomer(id)
val customer: Customer = customerRepository.findById(id).orElse(null)
assertEquals(customer.active, "N")
customer.active = "Y"
customerRepository.save(customer)
val customer2: Customer = customerRepository.findById(id).orElse(null)
assertEquals(customer2.active, "Y")
}
@Test @Test
fun testUpdateCustomer() { fun testUpdateCustomer() {
val id:Long = 90 val id:Long = 90