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();
}
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));
}
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());
}
Aggregations