mirror of
https://git.rwth-aachen.de/acs/public/villas/web-backend-go/
synced 2025-03-30 00:00:12 +01:00
fix header settings upon auth. failure, add amqp connection to user/ scenario duplication test
This commit is contained in:
parent
d6ab81a0f9
commit
9af822b801
2 changed files with 22 additions and 2 deletions
|
@ -126,7 +126,8 @@ func authenticate(c *gin.Context) {
|
|||
case "internal":
|
||||
myUser, err = authenticateInternal(c)
|
||||
if err != nil {
|
||||
helper.BadRequestError(c, err.Error())
|
||||
log.Println("internal auth. failed with error: ", err.Error())
|
||||
return
|
||||
}
|
||||
case "external":
|
||||
var authExternal bool
|
||||
|
@ -134,13 +135,16 @@ func authenticate(c *gin.Context) {
|
|||
if err == nil && authExternal {
|
||||
myUser, err = authenticateExternal(c)
|
||||
if err != nil {
|
||||
helper.BadRequestError(c, err.Error())
|
||||
log.Println("external auth. failed with error: ", err)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
helper.BadRequestError(c, "External authentication is not activated")
|
||||
return
|
||||
}
|
||||
default:
|
||||
helper.BadRequestError(c, "Invalid authentication mechanism")
|
||||
return
|
||||
}
|
||||
|
||||
// Check if this is an active user
|
||||
|
|
|
@ -25,11 +25,13 @@ import (
|
|||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
infrastructure_component "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/infrastructure-component"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.rwth-aachen.de/acs/public/villas/web-backend-go/helper"
|
||||
|
||||
|
@ -835,6 +837,20 @@ func TestDuplicateScenarioForUser(t *testing.T) {
|
|||
database.MigrateModels()
|
||||
assert.NoError(t, database.AddTestUsers())
|
||||
|
||||
// connect AMQP client
|
||||
// Make sure that AMQP_HOST, AMQP_USER, AMQP_PASS are set
|
||||
host, _ := configuration.GlobalConfig.String("amqp.host")
|
||||
usr, _ := configuration.GlobalConfig.String("amqp.user")
|
||||
pass, _ := configuration.GlobalConfig.String("amqp.pass")
|
||||
amqpURI := "amqp://" + usr + ":" + pass + "@" + host
|
||||
|
||||
// AMQP Connection startup is tested here
|
||||
// Not repeated in other tests because it is only needed once
|
||||
session = helper.NewAMQPSession("villas-test-session", amqpURI, "villas", infrastructure_component.ProcessMessage)
|
||||
SetAMQPSession(session)
|
||||
|
||||
time.Sleep(3 * time.Second)
|
||||
|
||||
// TODO test duplicate scenario for user function here!!
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue