Search in sources :

Example 46 with CustomerData

use of io.codekvast.common.customer.CustomerData in project codekvast by crispab.

the class DashboardServiceImpl method getMethodsFormData.

@Override
@Transactional(readOnly = true)
@NotNull
public GetMethodsFormData getMethodsFormData() {
    Long customerId = customerIdProvider.getCustomerId();
    CustomerData customerData = customerService.getCustomerDataByCustomerId(customerId);
    List<String> applications = jdbcTemplate.queryForList("SELECT DISTINCT name FROM applications WHERE customerId = ? ", String.class, customerId);
    List<String> environments = jdbcTemplate.queryForList("SELECT DISTINCT name FROM environments WHERE customerId = ? ", String.class, customerId);
    List<String> locations = jdbcTemplate.queryForList("SELECT DISTINCT locationNoVersion FROM method_locations WHERE customerId = ? ", String.class, customerId);
    return GetMethodsFormData.builder().applications(applications).environments(environments).locations(locations).retentionPeriodDays(customerData.getPricePlan().getRetentionPeriodDays()).build();
}
Also used : CustomerData(io.codekvast.common.customer.CustomerData) NotNull(javax.validation.constraints.NotNull) Transactional(org.springframework.transaction.annotation.Transactional)

Example 47 with CustomerData

use of io.codekvast.common.customer.CustomerData in project codekvast by crispab.

the class CustomerServiceImplTest method should_reject_too_big_codeBasePublication.

@Test
public void should_reject_too_big_codeBasePublication() {
    CustomerData customerData = service.getCustomerDataByLicenseKey("");
    LicenseViolationException exception = assertThrows(LicenseViolationException.class, () -> service.assertPublicationSize(customerData, 100_000));
    assertThat(exception.getMessage(), containsString("100000"));
    verify(eventService).send(any(LicenseViolationEvent.class));
}
Also used : CustomerData(io.codekvast.common.customer.CustomerData) LicenseViolationException(io.codekvast.common.customer.LicenseViolationException) LicenseViolationEvent(io.codekvast.common.messaging.model.LicenseViolationEvent) Test(org.junit.jupiter.api.Test)

Example 48 with CustomerData

use of io.codekvast.common.customer.CustomerData in project codekvast by crispab.

the class SecurityServiceImplTest method should_do_Heroku_SSO_when_valid_token_and_timestamp.

@Test
public void should_do_Heroku_SSO_when_valid_token_and_timestamp() {
    // given
    long timestampSeconds = Instant.now().getEpochSecond();
    String token = securityService.makeHerokuSsoToken("externalId", timestampSeconds, "salt");
    CustomerData customerData = CustomerData.builder().customerId(1L).customerName("someCustomerName").source("heroku").pricePlan(PricePlan.of(PricePlanDefaults.DEMO)).build();
    when(customerService.getCustomerDataByExternalId("heroku", "externalId")).thenReturn(customerData);
    // when
    String jwt = securityService.doHerokuSingleSignOn(token, "externalId", "someEmail", timestampSeconds, "salt");
    // then
    assertThat(jwt, not(nullValue()));
    verify(customerService).registerLogin(CustomerService.LoginRequest.builder().customerId(1L).email("someEmail").source("heroku").build());
}
Also used : CustomerData(io.codekvast.common.customer.CustomerData) Test(org.junit.jupiter.api.Test)

Aggregations

CustomerData (io.codekvast.common.customer.CustomerData)48 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)28 Sql (org.springframework.test.context.jdbc.Sql)28 Test (org.junit.Test)22 Instant (java.time.Instant)13 Test (org.junit.jupiter.api.Test)10 Transactional (org.springframework.transaction.annotation.Transactional)9 PricePlanDefaults (io.codekvast.common.customer.PricePlanDefaults)4 PricePlan (io.codekvast.common.customer.PricePlan)3 GetStatusResponse (io.codekvast.dashboard.dashboard.model.status.GetStatusResponse)3 Timestamp (java.sql.Timestamp)3 CollectionStartedEvent (io.codekvast.common.messaging.model.CollectionStartedEvent)2 User (io.codekvast.login.model.User)2 CacheEvict (org.springframework.cache.annotation.CacheEvict)2 LicenseViolationException (io.codekvast.common.customer.LicenseViolationException)1 LicenseViolationEvent (io.codekvast.common.messaging.model.LicenseViolationEvent)1 GetMethodsFormData (io.codekvast.dashboard.dashboard.model.methods.GetMethodsFormData)1 AgentDescriptor (io.codekvast.dashboard.dashboard.model.status.AgentDescriptor)1 ApplicationDescriptor2 (io.codekvast.dashboard.dashboard.model.status.ApplicationDescriptor2)1 EnvironmentStatusDescriptor (io.codekvast.dashboard.dashboard.model.status.EnvironmentStatusDescriptor)1