Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

Commit

Permalink
add, mod tests
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-stauffer committed Feb 6, 2024
1 parent 2d1c82d commit b04a1fe
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 1 deletion.
83 changes: 83 additions & 0 deletions apiservices/api_configuration_service_test.go
Original file line number Diff line number Diff line change
@@ -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) {

}
2 changes: 1 addition & 1 deletion app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
)
Expand Down
11 changes: 11 additions & 0 deletions eliona/others_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,24 @@
package eliona_test

import (
"os"
"saml-sso/eliona"
"testing"

"github.com/eliona-smart-building-assistant/go-utils/log"
)

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)
Expand Down

0 comments on commit b04a1fe

Please sign in to comment.