public ProjectDto validateProjectKey(String projectKey) {
    try (DbSession dbSession = dbClient.openSession(false)) {
      return componentFinder.getProjectByKey(dbSession, projectKey);
    } catch (NotFoundException e) {
      // To hide information about the existence or not of the project.
      throw insufficientPrivilegesException();
    }
  }
@Test
  public void givenInvalidProjectKey_whenValidateProjectKey_thenThrowForbiddenException() {
    // given
    String projectKey = "invalidProjectKey";
    DbSession dbSession = mockDbSession();
    doThrow(NotFoundException.class).when(componentFinder).getProjectByKey(dbSession, projectKey);

    // when then
    assertThatThrownBy(() -> underTest.validateProjectKey(projectKey))
      .withFailMessage("Insufficient privileges")
      .isInstanceOf(ForbiddenException.class);

  }