use of net.nemerosa.ontrack.model.security.Account in project ontrack by nemerosa.
the class SecurityServiceIT method getCurrentAccount.
@Test
public void getCurrentAccount() throws Exception {
Account account = asUser().call(securityService::getCurrentAccount);
assertNotNull(account);
}
use of net.nemerosa.ontrack.model.security.Account in project ontrack by nemerosa.
the class BuildFilterServiceIT method saveFilter_predefined.
@Test
public void saveFilter_predefined() throws Exception {
// Branch
Branch branch = doCreateBranch();
// Account for the tests
Account account = doCreateAccount();
// Creates a predefined filter for this account
Ack filterCreated = asAccount(account).call(() -> buildFilterService.saveFilter(branch.getId(), false, "MyFilter", PromotionLevelBuildFilterProvider.class.getName(), JsonUtils.object().end()));
assertFalse("A predefined filter cannot be saved", filterCreated.isSuccess());
}
use of net.nemerosa.ontrack.model.security.Account in project ontrack by nemerosa.
the class BuildFilterServiceIT method copyToBranch.
@Test
public void copyToBranch() throws Exception {
// Source branch
Branch sourceBranch = doCreateBranch();
// Target branch
Branch targetBranch = doCreateBranch();
// Account for the tests
Account account = doCreateAccount();
// Creates a filter for this account
Ack filterCreated = asAccount(account).call(() -> buildFilterService.saveFilter(sourceBranch.getId(), false, "MyFilter", StandardBuildFilterProvider.class.getName(), JsonUtils.object().with("count", 1).end()));
assertTrue(filterCreated.isSuccess());
// Checks the filter is created
Collection<BuildFilterResource<?>> filters = asAccount(account).with(sourceBranch.projectId(), ProjectView.class).call(() -> buildFilterService.getBuildFilters(sourceBranch.getId()));
assertEquals(1, filters.size());
BuildFilterResource<?> filter = filters.iterator().next();
assertEquals("MyFilter", filter.getName());
assertEquals(StandardBuildFilterProvider.class.getName(), filter.getType());
// Copy of the branch
asUser().with(sourceBranch.projectId(), ProjectView.class).with(targetBranch.projectId(), BranchEdit.class).call(() -> copyService.copy(targetBranch, new BranchCopyRequest(sourceBranch.getId(), Collections.emptyList())));
// Gets the filter on the new branch
filters = asAccount(account).withView(targetBranch).call(() -> buildFilterService.getBuildFilters(targetBranch.getId()));
assertEquals(1, filters.size());
filter = filters.iterator().next();
assertEquals("MyFilter", filter.getName());
assertEquals(StandardBuildFilterProvider.class.getName(), filter.getType());
}
use of net.nemerosa.ontrack.model.security.Account in project ontrack by nemerosa.
the class BuildFilterServiceIT method delete_unshared_filter.
@Test
public void delete_unshared_filter() throws Exception {
// Branch
Branch branch = doCreateBranch();
// Account for the tests
Account account = doCreateAccount();
// Creates a filter for this account
Ack ack = asAccount(account).call(() -> buildFilterService.saveFilter(branch.getId(), false, "MyFilter", NamedBuildFilterProvider.class.getName(), objectMapper.valueToTree(NamedBuildFilterData.of("1"))));
assertTrue("Account filter saved", ack.isSuccess());
// The filter is present
Collection<BuildFilterResource<?>> filters = asAccount(account).withView(branch).call(() -> buildFilterService.getBuildFilters(branch.getId()));
assertEquals(1, filters.size());
BuildFilterResource<?> filter = filters.iterator().next();
assertEquals("MyFilter", filter.getName());
assertFalse(filter.isShared());
// Deletes the filter
asAccount(account).call(() -> buildFilterService.deleteFilter(branch.getId(), "MyFilter"));
// The filter is no longer there
filters = asAccount(account).withView(branch).call(() -> buildFilterService.getBuildFilters(branch.getId()));
assertEquals(0, filters.size());
}
Aggregations