mirror of
https://github.com/mariocandela/beelzebub.git
synced 2025-07-01 18:47:26 -04:00
Feat: beelzebub cloud integrations (#117)
* improve beelzebub cloud integration * refactoring cloud integration, fix unit test * add unit test get honeypots * improve code coverage
This commit is contained in:
@ -3,7 +3,6 @@ package parser
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/mariocandela/beelzebub/v3/plugins"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@ -15,9 +14,10 @@ import (
|
||||
// BeelzebubCoreConfigurations is the struct that contains the configurations of the core
|
||||
type BeelzebubCoreConfigurations struct {
|
||||
Core struct {
|
||||
Logging Logging `yaml:"logging"`
|
||||
Tracings Tracings `yaml:"tracings"`
|
||||
Prometheus Prometheus `yaml:"prometheus"`
|
||||
Logging Logging `yaml:"logging"`
|
||||
Tracings Tracings `yaml:"tracings"`
|
||||
Prometheus Prometheus `yaml:"prometheus"`
|
||||
BeelzebubCloud BeelzebubCloud `yaml:"beelzebub-cloud"`
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,8 +31,7 @@ type Logging struct {
|
||||
|
||||
// Tracings is the struct that contains the configurations of the tracings
|
||||
type Tracings struct {
|
||||
RabbitMQ `yaml:"rabbit-mq"`
|
||||
BeelzebubCloud `yaml:"beelzebub-cloud"`
|
||||
RabbitMQ `yaml:"rabbit-mq"`
|
||||
}
|
||||
|
||||
type BeelzebubCloud struct {
|
||||
@ -55,17 +54,6 @@ type Plugin struct {
|
||||
LLMModel string `yaml:"llmModel"`
|
||||
}
|
||||
|
||||
func FromString(llmModel string) (plugins.LLMModel, error) {
|
||||
switch llmModel {
|
||||
case "llama3":
|
||||
return plugins.LLAMA3, nil
|
||||
case "gpt4-o":
|
||||
return plugins.GPT4O, nil
|
||||
default:
|
||||
return -1, fmt.Errorf("model %s not found", llmModel)
|
||||
}
|
||||
}
|
||||
|
||||
// BeelzebubServiceConfiguration is the struct that contains the configurations of the honeypot service
|
||||
type BeelzebubServiceConfiguration struct {
|
||||
ApiVersion string `yaml:"apiVersion"`
|
||||
|
@ -2,7 +2,6 @@ package parser
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/mariocandela/beelzebub/v3/plugins"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
@ -21,10 +20,10 @@ core:
|
||||
rabbit-mq:
|
||||
enabled: true
|
||||
uri: "amqp://user:password@localhost/"
|
||||
beelzebub-cloud:
|
||||
enabled: true
|
||||
uri: "amqp://user:password@localhost/"
|
||||
auth-token: "iejfdjsl-aosdajosoidaj-dunfkjnfkjsdnkn"`)
|
||||
beelzebub-cloud:
|
||||
enabled: true
|
||||
uri: "amqp://user:password@localhost/"
|
||||
auth-token: "iejfdjsl-aosdajosoidaj-dunfkjnfkjsdnkn"`)
|
||||
return configurationsCoreBytes, nil
|
||||
}
|
||||
|
||||
@ -95,9 +94,9 @@ func TestReadConfigurationsCoreValid(t *testing.T) {
|
||||
assert.Equal(t, coreConfigurations.Core.Logging.LogsPath, "./logs")
|
||||
assert.Equal(t, coreConfigurations.Core.Tracings.RabbitMQ.Enabled, true)
|
||||
assert.Equal(t, coreConfigurations.Core.Tracings.RabbitMQ.URI, "amqp://user:password@localhost/")
|
||||
assert.Equal(t, coreConfigurations.Core.Tracings.BeelzebubCloud.Enabled, true)
|
||||
assert.Equal(t, coreConfigurations.Core.Tracings.BeelzebubCloud.URI, "amqp://user:password@localhost/")
|
||||
assert.Equal(t, coreConfigurations.Core.Tracings.BeelzebubCloud.AuthToken, "iejfdjsl-aosdajosoidaj-dunfkjnfkjsdnkn")
|
||||
assert.Equal(t, coreConfigurations.Core.BeelzebubCloud.Enabled, true)
|
||||
assert.Equal(t, coreConfigurations.Core.BeelzebubCloud.URI, "amqp://user:password@localhost/")
|
||||
assert.Equal(t, coreConfigurations.Core.BeelzebubCloud.AuthToken, "iejfdjsl-aosdajosoidaj-dunfkjnfkjsdnkn")
|
||||
}
|
||||
|
||||
func TestReadConfigurationsServicesFail(t *testing.T) {
|
||||
@ -186,16 +185,3 @@ func TestReadFileBytesByFilePath(t *testing.T) {
|
||||
|
||||
assert.Equal(t, "", string(bytes))
|
||||
}
|
||||
|
||||
func TestFromString(t *testing.T) {
|
||||
model, err := FromString("llama3")
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, plugins.LLAMA3, model)
|
||||
|
||||
model, err = FromString("gpt4-o")
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, plugins.GPT4O, model)
|
||||
|
||||
model, err = FromString("beelzebub-model")
|
||||
assert.Errorf(t, err, "model beelzebub-model not found")
|
||||
}
|
||||
|
Reference in New Issue
Block a user