diff --git a/.docker/Dockerfile b/.docker/Dockerfile index 13ad47531a3d2ce2a6e733070ba72c284df1bf55..58037e1709c9c21bb889091a1fb62e0f92c73be0 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -19,5 +19,5 @@ RUN make install WORKDIR /caosdb-octaveinttest CMD cd test && \ - /wait-for-it.sh caosdb-server:10443 -t 500 -- \ + /wait-for-it.sh caosdb-server:8443 -t 500 -- \ octave Run_Test.m diff --git a/.docker/caosdb-client.json b/.docker/caosdb-client.json index 5da162e2561da384892fc62e02f2fdaddad2e6aa..50f3a797ec6bb8ef04a8a01ae2f008c92fdc3d1e 100644 --- a/.docker/caosdb-client.json +++ b/.docker/caosdb-client.json @@ -1,6 +1,17 @@ { "connections": { - "default": { + "default": "local-caosdb", + "local-caosdb-admin": { + "host": "caosdb-server", + "port": 8443, + "server_certificate_path": "/cert/caosdb.cert.pem", + "authentication": { + "type": "plain", + "username": "admin", + "password": "caosdb" + } + }, + "local-caosdb": { "host": "caosdb-server", "port": 8443, "server_certificate_path": "/cert/caosdb.cert.pem", @@ -10,5 +21,8 @@ "password": "caosdb" } } + }, + "extension": { + "this is my": "special option" } } diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..16cb33db67ad81cacbb8748e9736125f01f1666f --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +# -*- mode:conf; -*- +# local client config +test/caosdb_client.json diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..7ecd20e17822a9fad2bfbf43e3d8e5cbae7af724 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,26 @@ +# Changelog # + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] ## + +### Added ### + +### Changed ### + +### Deprecated ### + +### Removed ### + +### Fixed ### + +### Security ### + +## [0.0.1] - 2021-XX-XX ## + +### Added ### + +- Minimal working example with basic connection testing. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..b17768585402253487ad2f8606b990e2e95e6c66 --- /dev/null +++ b/Makefile @@ -0,0 +1,35 @@ +# ** header v3.0 +# This file is a part of the CaosDB Project. +# +# Copyright (C) 2021 IndiScale GmbH <info@indiscale.com> +# Copyright (C) 2021 Daniel Hornung <d.hornung@indiscale.com> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed 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 General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. +# +# ** end header + +# This Makefile is a wrapper for several other scripts. + +.PHONY: help +help: + @echo "Targets:" + @echo " test - run the test." + +############################################################################### +# Tests # +############################################################################### + +test: + cd test && octave Run_Test.m +.PHONY: test diff --git a/README.md b/README.md index d6682fded0d55be8a4d8332361095b7847e0dbf8..c4c87644345e279021aa651fe86820942f9db487 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,8 @@ Integration tests for caosdb-octavelib and the caosdb-server # Run tests +0. Create a customized `test/caosdb_client.json`, which must have the same connections as the + template in `.docker`. It must have paths to valid TLS certificates. 1. `cd test` 2. Run `octave Run_Test.m` diff --git a/test/Run_Test.m b/test/Run_Test.m index 964dfe6d02f157dd6cbe61d0687ecd745aa4fd05..e097828f4312afcdae669ced34b6e2f79282a88b 100644 --- a/test/Run_Test.m +++ b/test/Run_Test.m @@ -17,4 +17,7 @@ % along with this program. If not, see <https://www.gnu.org/licenses/>. pkg load caosdb; -moxunit_runtests -verbose test_caosdb.m +test_result = moxunit_runtests("-verbose", "test_caosdb.m"); +if not(test_result) + exit(1) +end diff --git a/test/test_caosdb.m b/test/test_caosdb.m index 2a9faa9b491221e84dc2249bc5077328cf895108..c163c371e299457441f08add207dcf5c640cbc95 100644 --- a/test/test_caosdb.m +++ b/test/test_caosdb.m @@ -1,9 +1,38 @@ -function test_suite=test_caosdb - try % assignment of 'localfunctions' is necessary in Matlab >= 2016 - test_functions=localfunctions(); - catch % no problem; early Matlab versions can use initTestSuite fine - end - initTestSuite; - -function test_print_version - caosdb("--test-connection") +function test_suite=test_caosdb() + try % assignment of 'localfunctions' is necessary in Matlab >= 2016 + test_functions=localfunctions(); + catch % no problem; early Matlab versions can use initTestSuite fine + end + initTestSuite; +end + +function test_connection() + % Default connection + c1 = Caosdb(); + info = c1.info(); + + % another working connection + c2 = Caosdb(connection = "local-caosdb-admin"); + c2.info(); + + % This connection should fail + % c3 = Caosdb(connection = "does-not-exist"); + % Error message is: + % maox_info: The ConnectionManager does not know any connection of this name. + % No connection named 'does-not-exist' present. + if moxunit_util_platform_is_octave() + assertExceptionThrown(@non_existing_connection); + else + assertExceptionThrown(@non_existing_connection,"16"); + end + expected_msg = ... + strjoin( + {"maox_info: The ConnectionManager does not know any connection of this name.", + "No connection named 'does-not-exist' present."}, "\n"); + assertEqual(lasterror().message, expected_msg) +end + +function info = non_existing_connection() + c = Caosdb(connection = "does-not-exist"); + info = c.info(); +end