refactor:Added Integration test and tiny refactoring (#23)

* Refactoring name convention

* Added integration test

* Added Makefile

* Bump golang.org/x/crypto from 0.0.0-20220826181053-bd7e27e6170d to 0.6.0

Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.0.0-20220826181053-bd7e27e6170d to 0.6.0.
- [Release notes](https://github.com/golang/crypto/releases)
- [Commits](https://github.com/golang/crypto/commits/v0.6.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

* Upgrade go from 1.16 to 1.20

* Added integration test: HTTP, TCP, SSH

* Added Makefile Improve README.md

* Fixed unit test CI

* Fixed go-version

* Added integration test into C.I. actions

---------

Signed-off-by: Mario Candela <m4r10.php@gmail.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
Mario Candela
2023-02-26 18:04:05 +01:00
committed by GitHub
parent bbcc8c9094
commit 6468b5aa6f
23 changed files with 282 additions and 40 deletions

View File

@ -1,4 +1,4 @@
package protocols
package strategies
import (
"beelzebub/parser"

View File

@ -1,8 +1,8 @@
package protocols
package strategies
import (
"beelzebub/parser"
"beelzebub/plugin"
"beelzebub/plugins"
"beelzebub/tracer"
"fmt"
"github.com/gliderlabs/ssh"
@ -40,7 +40,7 @@ func (SSHStrategy *SecureShellStrategy) Init(beelzebubServiceConfiguration parse
})
term := terminal.NewTerminal(sess, buildPrompt(sess.User(), beelzebubServiceConfiguration.ServerName))
var histories []plugin.History
var histories []plugins.History
for {
commandInput, err := term.ReadLine()
if err != nil {
@ -68,8 +68,8 @@ func (SSHStrategy *SecureShellStrategy) Init(beelzebubServiceConfiguration parse
if matched {
commandOutput := command.Handler
if command.Plugin == plugin.ChatGPTPluginName {
openAIGPTVirtualTerminal := plugin.OpenAIGPTVirtualTerminal{Histories: histories, OpenAPIChatGPTSecretKey: beelzebubServiceConfiguration.Plugin.OpenAPIChatGPTSecretKey}
if command.Plugin == plugins.ChatGPTPluginName {
openAIGPTVirtualTerminal := plugins.OpenAIGPTVirtualTerminal{Histories: histories, OpenAPIChatGPTSecretKey: beelzebubServiceConfiguration.Plugin.OpenAPIChatGPTSecretKey}
openAIGPTVirtualTerminal.InjectDependency()
if commandOutput, err = openAIGPTVirtualTerminal.GetCompletions(commandInput); err != nil {
@ -78,7 +78,7 @@ func (SSHStrategy *SecureShellStrategy) Init(beelzebubServiceConfiguration parse
}
}
histories = append(histories, plugin.History{Input: commandInput, Output: commandOutput})
histories = append(histories, plugins.History{Input: commandInput, Output: commandOutput})
term.Write(append([]byte(commandOutput), '\n'))
break

View File

@ -1,4 +1,4 @@
package protocols
package strategies
import (
"beelzebub/parser"