@Test public void shouldFetchManifest() { ManifestCms manifestCms = getRootManifestCms(); when(certificateRepositoryObjectFetcher.getManifest( eq(ROOT_SIA_MANIFEST_RSYNC_LOCATION), eq(taContext), isA(ValidationResult.class))) .thenReturn(manifestCms); assertEquals(manifestCms, subject.fetchManifest(ROOT_SIA_MANIFEST_RSYNC_LOCATION, taContext)); }
@Test public void shouldSkipInvalidObjects() { ManifestCms manifestCms = getRootManifestCms(); when(certificateRepositoryObjectFetcher.getObject( eq(ROOT_SIA_REPO_RSYNC_LOCATION.resolve("foo1")), eq(taContext), eq(manifestCms.getFileContentSpecification("foo1")), isA(ValidationResult.class))) .thenReturn(null); when(certificateRepositoryObjectFetcher.getObject( eq(ROOT_SIA_REPO_RSYNC_LOCATION.resolve("BaR")), eq(taContext), eq(manifestCms.getFileContentSpecification("BaR")), isA(ValidationResult.class))) .thenReturn(null); subject.processManifestFiles(taContext, manifestCms); assertTrue(workQueue.isEmpty()); }
@Test public void shouldNotProcessFilesWhenManifestIsNull() { when(certificateRepositoryObjectFetcher.getManifest( eq(ROOT_SIA_MANIFEST_RSYNC_LOCATION), eq(taContext), isA(ValidationResult.class))) .thenReturn(null); subject.processManifest(taContext); verify(certificateRepositoryObjectFetcher) .getManifest( eq(ROOT_SIA_MANIFEST_RSYNC_LOCATION), eq(taContext), isA(ValidationResult.class)); verifyNoMoreInteractions(certificateRepositoryObjectFetcher); }
@Test public void shouldAddFetchedObjectIssuerToWorkQueue() { ManifestCms manifestCms = getRootManifestCms(); X509Crl crl = getCrl(); when(certificateRepositoryObjectFetcher.getObject( eq(ROOT_SIA_REPO_RSYNC_LOCATION.resolve("foo1")), eq(taContext), eq(manifestCms.getFileContentSpecification("foo1")), isA(ValidationResult.class))) .thenReturn(ta); when(certificateRepositoryObjectFetcher.getObject( eq(ROOT_SIA_REPO_RSYNC_LOCATION.resolve("BaR")), eq(taContext), eq(manifestCms.getFileContentSpecification("BaR")), isA(ValidationResult.class))) .thenReturn(crl); subject.processManifestFiles(taContext, manifestCms); assertEquals(1, workQueue.size()); assertEquals(ta, workQueue.remove().getCertificate()); }