diff --git a/apiservices/api_configuration_service_test.go b/apiservices/api_configuration_service_test.go new file mode 100644 index 0000000..e840489 --- /dev/null +++ b/apiservices/api_configuration_service_test.go @@ -0,0 +1,83 @@ +// This file is part of the eliona project. +// Copyright © 2023 Eliona by IoTEC AG. All Rights Reserved. +// ______ _ _ +// | ____| (_) +// | |__ | |_ ___ _ __ __ _ +// | __| | | |/ _ \| '_ \ / _` | +// | |____| | | (_) | | | | (_| | +// |______|_|_|\___/|_| |_|\__,_| +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +package apiservices_test + +import ( + "context" + "database/sql" + "fmt" + "saml-sso/apiservices" + "saml-sso/conf" + "testing" + + "github.com/eliona-smart-building-assistant/go-eliona/app" + "github.com/eliona-smart-building-assistant/go-utils/db" +) + +func TestApp_Conf_InitDB(t *testing.T) { + err := conf.UserLeicomInit() + if err != nil { + t.Log("user leicom, ", err) + } + err = conf.DropOwnSchema() + if err != nil { + // no error, if schema not exist + t.Log("drop schema, ", err) + } + + execFunc := app.ExecSqlFile("../conf/init.sql") + err = execFunc(db.NewConnection()) + if err != nil { + t.Error("init.sql failed, ", err) + } +} + +func TestApp_AppApi_Configuration_GetBasicConfig(t *testing.T) { + apiService := apiservices.NewConfigurationApiService() + cnf, err := apiService.GetBasicConfiguration(context.Background()) + if err != sql.ErrNoRows { + t.Error(err) + } + fmt.Println(cnf) +} + +func TestApp_AppApi_Configuration_GetAdvancedConfig(t *testing.T) { + +} + +func TestApp_AppApi_Configuration_GetAttributeMapping(t *testing.T) { + +} + +func TestApp_AppApi_Configuration_GetPermissionMap(t *testing.T) { + +} + +func TestApp_AppApi_Configuration_PutBasicConfig(t *testing.T) { + +} + +func TestApp_AppApi_Configuration_PutAdvancedConfig(t *testing.T) { + +} + +func TestApp_AppApi_Configuration_PutAttributeMapping(t *testing.T) { + +} + +func TestApp_AppApi_Configuration_PutPermissionMap(t *testing.T) { + +} diff --git a/eliona/others_test.go b/eliona/others_test.go index c1967a0..5441e30 100644 --- a/eliona/others_test.go +++ b/eliona/others_test.go @@ -16,6 +16,7 @@ package eliona_test import ( + "os" "saml-sso/eliona" "testing" @@ -23,6 +24,16 @@ import ( ) func TestApp_Others(t *testing.T) { + + // this test needs a real eliona db to due missing tables + // in the test db + _, realDb := os.LookupEnv("REAL_DB") + if !realDb { + log.Warn("TestApp_Others", "test disabled because missing env var REAL_DB") + t.Log("TestApp_Others: test disabled because missing env var REAL_DB") + return + } + token, err := eliona.GetElionaJsonWebToken("su#@eliona.io") if err != nil { t.Error(err)