diff --git a/README.md b/README.md index 92cb1c7..b48eff6 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ This initialization can be handled by the `reset.sql` script. - `LOG_LEVEL`(optional): defines the minimum level that should be [logged](https://github.com/eliona-smart-building-assistant/go-utils/blob/main/log/README.md). The default level is `info`. -- `SSO_SERVER_PORT` (optional): defines the port for Single Sign On Services, here SAML 2.0. The default value is Port `8080`. +- `SSO_SERVER_PORT` (optional): defines the port for Single Sign On Services, here SAML 2.0. The default value is Port `80`. ### Database tables ### diff --git a/apiservices/api_configuration_service_test.go b/apiservices/api_configuration_service_test.go new file mode 100644 index 0000000..5068eb3 --- /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_AppApi_Configuration_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/app.go b/app.go index 2752db3..fed6a5b 100644 --- a/app.go +++ b/app.go @@ -33,7 +33,7 @@ import ( const ( LOG_REGIO = "app" API_SERVER_PORT = 3000 - SSO_SERVER_PORT = 8081 // Publicly accessible without auth. See wiki. + SSO_SERVER_PORT = 80 // Publicly accessible without auth. See wiki. SAML_SPECIFIC_ENDPOINT_PATH = "/saml/" ) 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)