public ConfigCheckResult checkConfig() {
    Optional<Long> appId = getAppId();
    if (appId.isEmpty()) {
      return failedApplicationStatus(INVALID_APP_ID_STATUS);
    }
    GithubAppConfiguration githubAppConfiguration = new GithubAppConfiguration(appId.get(), gitHubSettings.privateKey(), gitHubSettings.apiURLOrDefault());
    return checkConfig(githubAppConfiguration);
  }
@Test
  public void checkConfig_whenAppDoesntHaveAnyPermissions_shouldReturnFailedAppJitCheck() {
    mockGithubConfiguration();
    ArgumentCaptor<GithubAppConfiguration> appConfigurationCaptor = ArgumentCaptor.forClass(GithubAppConfiguration.class);
    GsonApp githubApp = mockGithubApp(appConfigurationCaptor);

    when(githubApp.getPermissions()).thenReturn(Permissions.builder().build());
    mockOrganizationsWithoutPermissions(appConfigurationCaptor, "org1", "org2");

    ConfigCheckResult checkResult = configValidator.checkConfig();

    assertThat(checkResult.application().autoProvisioning()).isEqualTo(ConfigStatus.failed(MISSING_ALL_PERMISSIONS));
    assertThat(checkResult.application().jit()).isEqualTo(ConfigStatus.failed(MISSING_EMAIL_PERMISSION));
    assertThat(checkResult.installations()).hasSize(2);
    assertThat(checkResult.installations())
      .extracting(InstallationStatus::jit, InstallationStatus::autoProvisioning)
      .containsExactly(
        tuple(ConfigStatus.failed(MISSING_EMAIL_PERMISSION), ConfigStatus.failed(MISSING_ALL_AUTOPROVISIONNING_PERMISSIONS)),
        tuple(ConfigStatus.failed(MISSING_EMAIL_PERMISSION), ConfigStatus.failed(MISSING_ALL_AUTOPROVISIONNING_PERMISSIONS)));
    verifyAppConfiguration(appConfigurationCaptor.getValue());

  }