-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Not relying on status fetching to fetch About box information anymore
- Loading branch information
eskimo
committed
Apr 17, 2023
1 parent
1df4811
commit c8c8f70
Showing
6 changed files
with
292 additions
and
16 deletions.
There are no files selected for viewing
105 changes: 105 additions & 0 deletions
105
src/main/java/ch/niceideas/eskimo/controlers/AboutController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/* | ||
* This file is part of the eskimo project referenced at www.eskimo.sh. The licensing information below apply just as | ||
* well to this individual file than to the Eskimo Project as a whole. | ||
* | ||
* Copyright 2019 - 2023 eskimo.sh / https://www.eskimo.sh - All rights reserved. | ||
* Author : eskimo.sh / https://www.eskimo.sh | ||
* | ||
* Eskimo is available under a dual licensing model : commercial and GNU AGPL. | ||
* If you did not acquire a commercial licence for Eskimo, you can still use it and consider it free software under the | ||
* terms of the GNU Affero Public License. You can redistribute it and/or modify it under the terms of the GNU Affero | ||
* Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) | ||
* any later version. | ||
* Compliance to each and every aspect of the GNU Affero Public License is mandatory for users who did no acquire a | ||
* commercial license. | ||
* | ||
* Eskimo is distributed as a free software under GNU AGPL in the hope that it will be useful, but WITHOUT ANY | ||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Affero Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero Public License along with Eskimo. If not, | ||
* see <https://www.gnu.org/licenses/> or write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
* Boston, MA, 02110-1301 USA. | ||
* | ||
* You can be released from the requirements of the license by purchasing a commercial license. Buying such a | ||
* commercial license is mandatory as soon as : | ||
* - you develop activities involving Eskimo without disclosing the source code of your own product, software, | ||
* platform, use cases or scripts. | ||
* - you deploy eskimo as part of a commercial product, platform or software. | ||
* For more information, please contact eskimo.sh at https://www.eskimo.sh | ||
* | ||
* The above copyright notice and this licensing notice shall be included in all copies or substantial portions of the | ||
* Software. | ||
*/ | ||
|
||
package ch.niceideas.eskimo.controlers; | ||
|
||
import ch.niceideas.common.utils.Pair; | ||
import ch.niceideas.eskimo.services.ApplicationStatusService; | ||
import ch.niceideas.eskimo.services.ApplicationStatusServiceImpl; | ||
import ch.niceideas.eskimo.services.NotificationService; | ||
import ch.niceideas.eskimo.utils.ReturnStatusHelper; | ||
import org.apache.log4j.Logger; | ||
import org.json.JSONArray; | ||
import org.json.JSONException; | ||
import org.json.JSONObject; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.ResponseBody; | ||
|
||
import javax.annotation.Resource; | ||
import java.util.List; | ||
|
||
|
||
@Controller | ||
public class AboutController extends AbstractInformationController<JSONObject, List<JSONObject>> { | ||
|
||
private static final Logger logger = Logger.getLogger(AboutController.class); | ||
|
||
@Value("${build.version}") | ||
private String buildVersion; | ||
|
||
@Value("${build.timestamp}") | ||
private String buildTimestamp; | ||
|
||
@Value("${eskimo.enableKubernetesSubsystem}") | ||
private Boolean enableKubernetesSubsystem; | ||
|
||
@Value("${eskimo.demoMode}") | ||
private Boolean demoMode; | ||
|
||
@Value("${setup.packagesDownloadUrlRoot}") | ||
private String packagesDownloadUrlRoot; | ||
|
||
@GetMapping("/fetch-about-info") | ||
@ResponseBody | ||
public String fetchAboutInfo() { | ||
|
||
try { | ||
|
||
return ReturnStatusHelper.createOKStatus(map -> { | ||
|
||
map.put("about-eskimo-version", buildVersion); | ||
|
||
map.put("about-eskimo-build-timestamp", buildTimestamp); | ||
map.put("about-eskimo-runtime-timestamp", ApplicationStatusServiceImpl.getRuntimeStartDate()); | ||
map.put("about-eskimo-kube-enabled", enableKubernetesSubsystem); | ||
map.put("about-eskimo-demo-mode", demoMode); | ||
map.put("about-eskimo-packages-url", packagesDownloadUrlRoot); | ||
|
||
map.put("about-eskimo-java-home", System.getProperty("java.home")); | ||
map.put("about-eskimo-java-version", System.getProperty("java.version")); | ||
map.put("about-eskimo-working-dir", System.getProperty("user.dir")); | ||
map.put("about-eskimo-os-name", System.getProperty("os.name")); | ||
map.put("about-eskimo-os-version", System.getProperty("os.version")); | ||
}); | ||
|
||
} catch (JSONException e) { | ||
logger.error (e, e); | ||
throw new IllegalStateException(e); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
src/test/java/ch/niceideas/eskimo/controlers/AboutControllerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* This file is part of the eskimo project referenced at www.eskimo.sh. The licensing information below apply just as | ||
* well to this individual file than to the Eskimo Project as a whole. | ||
* | ||
* Copyright 2019 - 2023 eskimo.sh / https://www.eskimo.sh - All rights reserved. | ||
* Author : eskimo.sh / https://www.eskimo.sh | ||
* | ||
* Eskimo is available under a dual licensing model : commercial and GNU AGPL. | ||
* If you did not acquire a commercial licence for Eskimo, you can still use it and consider it free software under the | ||
* terms of the GNU Affero Public License. You can redistribute it and/or modify it under the terms of the GNU Affero | ||
* Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) | ||
* any later version. | ||
* Compliance to each and every aspect of the GNU Affero Public License is mandatory for users who did no acquire a | ||
* commercial license. | ||
* | ||
* Eskimo is distributed as a free software under GNU AGPL in the hope that it will be useful, but WITHOUT ANY | ||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Affero Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero Public License along with Eskimo. If not, | ||
* see <https://www.gnu.org/licenses/> or write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
* Boston, MA, 02110-1301 USA. | ||
* | ||
* You can be released from the requirements of the license by purchasing a commercial license. Buying such a | ||
* commercial license is mandatory as soon as : | ||
* - you develop activities involving Eskimo without disclosing the source code of your own product, software, | ||
* platform, use cases or scripts. | ||
* - you deploy eskimo as part of a commercial product, platform or software. | ||
* For more information, please contact eskimo.sh at https://www.eskimo.sh | ||
* | ||
* The above copyright notice and this licensing notice shall be included in all copies or substantial portions of the | ||
* Software. | ||
*/ | ||
|
||
|
||
package ch.niceideas.eskimo.controlers; | ||
|
||
import ch.niceideas.common.json.JsonWrapper; | ||
import ch.niceideas.eskimo.EskimoApplication; | ||
import ch.niceideas.eskimo.services.NotificationService; | ||
import org.json.JSONArray; | ||
import org.json.JSONObject; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.test.context.ActiveProfiles; | ||
import org.springframework.test.context.ContextConfiguration; | ||
import org.springframework.test.context.TestPropertySource; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
@ContextConfiguration(classes = EskimoApplication.class) | ||
@SpringBootTest(classes = EskimoApplication.class) | ||
@TestPropertySource("classpath:application-test.properties") | ||
@ActiveProfiles({"no-web-stack", "test-system", "test-setup"}) | ||
public class AboutControllerTest { | ||
|
||
@Autowired | ||
private AboutController aboutController; | ||
|
||
@Test | ||
public void testNominal() { | ||
|
||
JsonWrapper result = new JsonWrapper(aboutController.fetchAboutInfo()); | ||
|
||
assertEquals ("false", result.getValueForPathAsString("about-eskimo-demo-mode")); | ||
assertEquals ("true", result.getValueForPathAsString("about-eskimo-kube-enabled")); | ||
assertEquals ("https://www.eskimo.sh/eskimo/V0.4/", result.getValueForPathAsString("about-eskimo-packages-url")); | ||
assertEquals ("OK", result.getValueForPathAsString("status")); | ||
|
||
// all the rest can't be tested as it changes dynamically unfortunately | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters