use of org.killbill.billing.tenant.api.DefaultTenant in project killbill by killbill.
the class TestKillbillJdbcTenantRealm method beforeMethod.
@Override
@BeforeMethod(groups = "slow")
public void beforeMethod() throws Exception {
super.beforeMethod();
// Create the tenant
final DefaultTenantDao tenantDao = new DefaultTenantDao(dbi, clock, cacheControllerDispatcher, new DefaultNonEntityDao(dbi), Mockito.mock(InternalCallContextFactory.class), securityConfig);
tenant = new DefaultTenant(UUID.randomUUID(), null, null, UUID.randomUUID().toString(), UUID.randomUUID().toString(), UUID.randomUUID().toString());
tenantDao.create(new TenantModelDao(tenant), internalCallContext);
// Setup the security manager
final HikariConfig dbConfig = new HikariConfig();
dbConfig.setJdbcUrl(helper.getJdbcConnectionString());
dbConfig.setUsername(helper.getUsername());
dbConfig.setPassword(helper.getPassword());
final KillbillJdbcTenantRealm jdbcRealm = new KillbillJdbcTenantRealm(shiroDataSource, securityConfig);
jdbcRealm.setDataSource(new HikariDataSource(dbConfig));
securityManager = new DefaultSecurityManager(jdbcRealm);
}
use of org.killbill.billing.tenant.api.DefaultTenant in project killbill by killbill.
the class TestIntegrationWithCatalogUpdate method setupTenant.
private void setupTenant() throws TenantApiException {
final UUID uuid = UUID.randomUUID();
final String externalKey = uuid.toString();
final String apiKey = externalKey + "-Key";
final String apiSecret = externalKey + "-$3cr3t";
// Only place where we use callContext
tenant = tenantUserApi.createTenant(new DefaultTenant(uuid, init, init, externalKey, apiKey, apiSecret), callContext);
testCallContext = new DefaultCallContext(tenant.getId(), "tester", CallOrigin.EXTERNAL, UserType.TEST, "good reason", "trust me", uuid, clock);
}
use of org.killbill.billing.tenant.api.DefaultTenant in project killbill by killbill.
the class TestDefaultTenantDao method testTenantKeyValue.
@Test(groups = "slow")
public void testTenantKeyValue() throws Exception {
final DefaultTenant tenant = new DefaultTenant(UUID.randomUUID(), null, null, UUID.randomUUID().toString(), UUID.randomUUID().toString(), UUID.randomUUID().toString());
tenantDao.create(new TenantModelDao(tenant), internalCallContext);
tenantDao.addTenantKeyValue("THE_KEY", "TheValue", false, internalCallContext);
List<String> value = tenantDao.getTenantValueForKey("THE_KEY", internalCallContext);
Assert.assertEquals(value.size(), 1);
Assert.assertEquals(value.get(0), "TheValue");
tenantDao.addTenantKeyValue("THE_KEY", "TheSecondValue", false, internalCallContext);
value = tenantDao.getTenantValueForKey("THE_KEY", internalCallContext);
Assert.assertEquals(value.size(), 2);
value = tenantDao.getTenantValueForKey("THE_KEY", internalCallContext);
Assert.assertEquals(value.size(), 2);
tenantDao.deleteTenantKey("THE_KEY", internalCallContext);
value = tenantDao.getTenantValueForKey("THE_KEY", internalCallContext);
Assert.assertEquals(value.size(), 0);
}
use of org.killbill.billing.tenant.api.DefaultTenant in project killbill by killbill.
the class TestDefaultTenantDao method testTenantSearch.
@Test(groups = "slow")
public void testTenantSearch() throws Exception {
final DefaultTenant tenant = new DefaultTenant(UUID.randomUUID(), null, null, UUID.randomUUID().toString(), UUID.randomUUID().toString(), UUID.randomUUID().toString());
tenantDao.create(new TenantModelDao(tenant), internalCallContext);
tenantDao.addTenantKeyValue("foobar", "foobar1", false, internalCallContext);
tenantDao.addTenantKeyValue("foobar", "foobar2", false, internalCallContext);
tenantDao.addTenantKeyValue("foobar", "foobar3", false, internalCallContext);
tenantDao.updateTenantLastKeyValue("foo", "foo1", internalCallContext);
tenantDao.updateTenantLastKeyValue("fooXX", "fooXX1", internalCallContext);
tenantDao.updateTenantLastKeyValue("bar", "bar", internalCallContext);
final List<TenantKVModelDao> result = tenantDao.searchTenantKeyValues("foo", internalCallContext);
Assert.assertEquals(result.size(), 5);
}
use of org.killbill.billing.tenant.api.DefaultTenant in project killbill by killbill.
the class TestDefaultTenantUserApi method testCreateTenantWithExternalKeyOverLimit.
@Test(groups = "slow", description = "Test Tenant creation with External Key over limit")
public void testCreateTenantWithExternalKeyOverLimit() throws Exception {
final TenantData tenantdata = new DefaultTenant(UUID.randomUUID(), clock.getUTCNow(), clock.getUTCNow(), "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis,.", "TTR445ee2", "dskjhfs^^54R");
try {
tenantUserApi.createTenant(tenantdata, callContext);
Assert.fail();
} catch (final TenantApiException e) {
Assert.assertEquals(e.getCode(), ErrorCode.EXTERNAL_KEY_LIMIT_EXCEEDED.getCode());
}
}
Aggregations