use of com.thoughtworks.go.util.SystemTimeClock in project gocd by gocd.
the class ServerVersionInfoManagerTest method shouldGetVersionInfoIflatestVersionIsBeingUpdatedForMoreThanHalfAnHour.
@Test
public void shouldGetVersionInfoIflatestVersionIsBeingUpdatedForMoreThanHalfAnHour() {
SystemTimeClock systemTimeClock = mock(SystemTimeClock.class);
Date yesterday = new Date(System.currentTimeMillis() - 24 * 60 * 60 * 1000);
DateTime halfAnHourFromNow = new DateTime(System.currentTimeMillis() - 35 * 60 * 1000);
VersionInfo versionInfo = new VersionInfo("go_server", new GoVersion("1.2.3-1"), new GoVersion("2.3.4-2"), yesterday);
when(builder.getServerVersionInfo()).thenReturn(versionInfo);
when(systemTimeClock.currentDateTime()).thenReturn(halfAnHourFromNow);
manager = new ServerVersionInfoManager(builder, versionInfoDao, systemTimeClock, goCache, systemEnvironment);
manager.initialize();
VersionInfo serverVersionInfo1 = manager.versionInfoForUpdate();
VersionInfo serverVersionInfo2 = manager.versionInfoForUpdate();
assertNotNull(serverVersionInfo1);
assertNotNull(serverVersionInfo2);
}
use of com.thoughtworks.go.util.SystemTimeClock in project gocd by gocd.
the class ServerVersionInfoManagerTest method shouldBeFalseIfVersionCheckIsDisabled.
@Test
public void shouldBeFalseIfVersionCheckIsDisabled() {
SystemEnvironment systemEnvironment = mock(SystemEnvironment.class);
when(builder.getServerVersionInfo()).thenReturn(new VersionInfo());
when(systemEnvironment.isProductionMode()).thenReturn(true);
when(systemEnvironment.isGOUpdateCheckEnabled()).thenReturn(false);
manager = new ServerVersionInfoManager(builder, versionInfoDao, new SystemTimeClock(), goCache, systemEnvironment);
manager.initialize();
assertFalse(manager.isUpdateCheckEnabled());
}
use of com.thoughtworks.go.util.SystemTimeClock in project gocd by gocd.
the class ServerVersionInfoManagerTest method updateCheckShouldBeDisabledForADevelopmentServer.
@Test
public void updateCheckShouldBeDisabledForADevelopmentServer() {
SystemEnvironment systemEnvironment = mock(SystemEnvironment.class);
when(builder.getServerVersionInfo()).thenReturn(new VersionInfo());
when(systemEnvironment.isProductionMode()).thenReturn(false);
when(systemEnvironment.isGOUpdateCheckEnabled()).thenReturn(true);
manager = new ServerVersionInfoManager(builder, versionInfoDao, new SystemTimeClock(), goCache, systemEnvironment);
manager.initialize();
assertFalse(manager.isUpdateCheckEnabled());
}
use of com.thoughtworks.go.util.SystemTimeClock in project gocd by gocd.
the class IsSecurityEnabledVoterTest method shouldNotVoteAccessGrantedIfSecurityIsEnabledButAnonymousIsNot.
@Test
public void shouldNotVoteAccessGrantedIfSecurityIsEnabledButAnonymousIsNot() {
configHelper.addSecurityWithBogusLdapConfig(false);
GoConfigService configService = new GoConfigService(goConfigDao, null, new SystemTimeClock(), mock(GoConfigMigration.class), null, null, ConfigElementImplementationRegistryMother.withNoPlugins(), new InstanceFactory(), mock(CachedGoPartials.class), null);
IsSecurityEnabledVoter voter = new IsSecurityEnabledVoter(configService);
int accessStatus = voter.vote(null, null, null);
assertThat(accessStatus, Is.is(AccessDecisionVoter.ACCESS_ABSTAIN));
}
use of com.thoughtworks.go.util.SystemTimeClock in project gocd by gocd.
the class ServerVersionInfoManagerTest method shouldGetGoUpdateFromCache.
@Test
public void shouldGetGoUpdateFromCache() {
String newRelease = "15.0.1-123";
GoCache goCache = mock(GoCache.class);
when(goCache.get("GOUpdate")).thenReturn(newRelease);
manager = new ServerVersionInfoManager(builder, versionInfoDao, new SystemTimeClock(), goCache, null);
assertThat(manager.getGoUpdate(), is(newRelease));
}
Aggregations