mirror of
https://github.com/bitechdev/ResolveSpec.git
synced 2025-12-13 17:10:36 +00:00
Fixed test for session id changes
This commit is contained in:
parent
a4dd2a7086
commit
dc3b621380
@ -16,8 +16,8 @@ import (
|
|||||||
|
|
||||||
// MockDatabase implements common.Database interface for testing
|
// MockDatabase implements common.Database interface for testing
|
||||||
type MockDatabase struct {
|
type MockDatabase struct {
|
||||||
QueryFunc func(ctx context.Context, dest interface{}, query string, args ...interface{}) error
|
QueryFunc func(ctx context.Context, dest interface{}, query string, args ...interface{}) error
|
||||||
ExecFunc func(ctx context.Context, query string, args ...interface{}) (common.Result, error)
|
ExecFunc func(ctx context.Context, query string, args ...interface{}) (common.Result, error)
|
||||||
RunInTransactionFunc func(ctx context.Context, fn func(common.Database) error) error
|
RunInTransactionFunc func(ctx context.Context, fn func(common.Database) error) error
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,9 +161,9 @@ func TestExtractInputVariables(t *testing.T) {
|
|||||||
handler := NewHandler(&MockDatabase{})
|
handler := NewHandler(&MockDatabase{})
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
sqlQuery string
|
sqlQuery string
|
||||||
expectedVars []string
|
expectedVars []string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "No variables",
|
name: "No variables",
|
||||||
@ -340,9 +340,9 @@ func TestSqlQryWhere(t *testing.T) {
|
|||||||
// TestGetIPAddress tests IP address extraction
|
// TestGetIPAddress tests IP address extraction
|
||||||
func TestGetIPAddress(t *testing.T) {
|
func TestGetIPAddress(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
setupReq func() *http.Request
|
setupReq func() *http.Request
|
||||||
expected string
|
expected string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "X-Forwarded-For header",
|
name: "X-Forwarded-For header",
|
||||||
@ -782,9 +782,10 @@ func TestReplaceMetaVariables(t *testing.T) {
|
|||||||
handler := NewHandler(&MockDatabase{})
|
handler := NewHandler(&MockDatabase{})
|
||||||
|
|
||||||
userCtx := &security.UserContext{
|
userCtx := &security.UserContext{
|
||||||
UserID: 123,
|
UserID: 123,
|
||||||
UserName: "testuser",
|
UserName: "testuser",
|
||||||
SessionID: "456",
|
SessionID: "ABC456",
|
||||||
|
SessionRID: 456,
|
||||||
}
|
}
|
||||||
|
|
||||||
metainfo := map[string]interface{}{
|
metainfo := map[string]interface{}{
|
||||||
@ -821,6 +822,12 @@ func TestReplaceMetaVariables(t *testing.T) {
|
|||||||
expectedCheck: func(result string) bool {
|
expectedCheck: func(result string) bool {
|
||||||
return strings.Contains(result, "456")
|
return strings.Contains(result, "456")
|
||||||
},
|
},
|
||||||
|
}, {
|
||||||
|
name: "Replace [id_session]",
|
||||||
|
sqlQuery: "SELECT * FROM sessions WHERE session_id = [id_session]",
|
||||||
|
expectedCheck: func(result string) bool {
|
||||||
|
return strings.Contains(result, "ABC456")
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user