Search in sources :

Example 1 with SubjectOperations

use of ddf.security.SubjectOperations in project ddf by codice.

the class HistorianTest method setup.

@Before
public void setup() {
    historian = new Historian();
    uuidGenerator = mock(UuidGenerator.class);
    when(uuidGenerator.generateUuid()).thenReturn(UUID.randomUUID().toString());
    historian.setUuidGenerator(uuidGenerator);
    catalogProvider = mock(CatalogProvider.class);
    historian.setCatalogProviders(Collections.singletonList(catalogProvider));
    storageProvider = new InMemoryStorageProvider();
    historian.setStorageProviders(Collections.singletonList(storageProvider));
    historian.setMetacardTypes(Collections.singletonList(MetacardImpl.BASIC_METACARD));
    SubjectIdentity subjectIdentity = mock(SubjectIdentity.class);
    when(subjectIdentity.getUniqueIdentifier(any())).thenReturn("test");
    historian.setSubjectIdentity(subjectIdentity);
    SubjectOperations subjectOperations = mock(SubjectOperations.class);
    when(subjectOperations.getEmailAddress(any(Subject.class))).thenReturn("test@test.com");
    when(subjectOperations.getName(any(Subject.class))).thenReturn("test");
    historian.setSubjectOperations(subjectOperations);
    historian.setSecurityLogger(mock(SecurityLogger.class));
    Security security = mock(Security.class);
    Subject subject = mock(MockSubject.class);
    when(subject.execute(any(Callable.class))).thenCallRealMethod();
    when(security.runAsAdmin(any(PrivilegedAction.class))).thenReturn(subject);
    historian.setSecurity(security);
}
Also used : SubjectOperations(ddf.security.SubjectOperations) UuidGenerator(org.codice.ddf.platform.util.uuidgenerator.UuidGenerator) CatalogProvider(ddf.catalog.source.CatalogProvider) PrivilegedAction(java.security.PrivilegedAction) SubjectIdentity(ddf.security.SubjectIdentity) Security(org.codice.ddf.security.Security) Subject(ddf.security.Subject) Callable(java.util.concurrent.Callable) SecurityLogger(ddf.security.audit.SecurityLogger) Before(org.junit.Before)

Aggregations

CatalogProvider (ddf.catalog.source.CatalogProvider)1 Subject (ddf.security.Subject)1 SubjectIdentity (ddf.security.SubjectIdentity)1 SubjectOperations (ddf.security.SubjectOperations)1 SecurityLogger (ddf.security.audit.SecurityLogger)1 PrivilegedAction (java.security.PrivilegedAction)1 Callable (java.util.concurrent.Callable)1 UuidGenerator (org.codice.ddf.platform.util.uuidgenerator.UuidGenerator)1 Security (org.codice.ddf.security.Security)1 Before (org.junit.Before)1