mirror of
https://github.com/usual2970/certimate.git
synced 2025-06-08 13:39:53 +00:00
feat: add test cases
This commit is contained in:
parent
bd4aa4806f
commit
8014abc836
@ -1,4 +1,4 @@
|
|||||||
package baotapanelconsole
|
package ratpanelconsole
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package baotapanelconsole_test
|
package ratpanelconsole_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@ -8,33 +8,36 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
provider "github.com/usual2970/certimate/internal/pkg/core/deployer/providers/baotapanel-console"
|
provider "github.com/usual2970/certimate/internal/pkg/core/deployer/providers/ratpanel-console"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
fInputCertPath string
|
fInputCertPath string
|
||||||
fInputKeyPath string
|
fInputKeyPath string
|
||||||
fApiUrl string
|
fApiUrl string
|
||||||
fApiKey string
|
fTokenId uint
|
||||||
|
fToken string
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
argsPrefix := "CERTIMATE_DEPLOYER_BAOTAPANELCONSOLE_"
|
argsPrefix := "CERTIMATE_DEPLOYER_RATPANELCONSOLE_"
|
||||||
|
|
||||||
flag.StringVar(&fInputCertPath, argsPrefix+"INPUTCERTPATH", "", "")
|
flag.StringVar(&fInputCertPath, argsPrefix+"INPUTCERTPATH", "", "")
|
||||||
flag.StringVar(&fInputKeyPath, argsPrefix+"INPUTKEYPATH", "", "")
|
flag.StringVar(&fInputKeyPath, argsPrefix+"INPUTKEYPATH", "", "")
|
||||||
flag.StringVar(&fApiUrl, argsPrefix+"APIURL", "", "")
|
flag.StringVar(&fApiUrl, argsPrefix+"APIURL", "", "")
|
||||||
flag.StringVar(&fApiKey, argsPrefix+"APIKEY", "", "")
|
flag.UintVar(&fTokenId, argsPrefix+"TOKENID", 0, "")
|
||||||
|
flag.StringVar(&fToken, argsPrefix+"TOKEN", "", "")
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Shell command to run this test:
|
Shell command to run this test:
|
||||||
|
|
||||||
go test -v ./baotapanel_console_test.go -args \
|
go test -v ./baotapanel_console_test.go -args \
|
||||||
--CERTIMATE_DEPLOYER_BAOTAPANELCONSOLE_INPUTCERTPATH="/path/to/your-input-cert.pem" \
|
--CERTIMATE_DEPLOYER_RATPANELCONSOLE_INPUTCERTPATH="/path/to/your-input-cert.pem" \
|
||||||
--CERTIMATE_DEPLOYER_BAOTAPANELCONSOLE_INPUTKEYPATH="/path/to/your-input-key.pem" \
|
--CERTIMATE_DEPLOYER_RATPANELCONSOLE_INPUTKEYPATH="/path/to/your-input-key.pem" \
|
||||||
--CERTIMATE_DEPLOYER_BAOTAPANELCONSOLE_APIURL="http://127.0.0.1:8888" \
|
--CERTIMATE_DEPLOYER_RATPANELCONSOLE_APIURL="http://127.0.0.1:8888" \
|
||||||
--CERTIMATE_DEPLOYER_BAOTAPANELCONSOLE_APIKEY="your-api-key"
|
--CERTIMATE_DEPLOYER_RATPANELSITE_TOKENID="your-access-token-id" \
|
||||||
|
--CERTIMATE_DEPLOYER_RATPANELSITE_TOKEN="your-access-token" \
|
||||||
*/
|
*/
|
||||||
func TestDeploy(t *testing.T) {
|
func TestDeploy(t *testing.T) {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
@ -45,14 +48,15 @@ func TestDeploy(t *testing.T) {
|
|||||||
fmt.Sprintf("INPUTCERTPATH: %v", fInputCertPath),
|
fmt.Sprintf("INPUTCERTPATH: %v", fInputCertPath),
|
||||||
fmt.Sprintf("INPUTKEYPATH: %v", fInputKeyPath),
|
fmt.Sprintf("INPUTKEYPATH: %v", fInputKeyPath),
|
||||||
fmt.Sprintf("APIURL: %v", fApiUrl),
|
fmt.Sprintf("APIURL: %v", fApiUrl),
|
||||||
fmt.Sprintf("APIKEY: %v", fApiKey),
|
fmt.Sprintf("TOKENID: %v", fTokenId),
|
||||||
|
fmt.Sprintf("TOKEN: %v", fToken),
|
||||||
}, "\n"))
|
}, "\n"))
|
||||||
|
|
||||||
deployer, err := provider.NewDeployer(&provider.DeployerConfig{
|
deployer, err := provider.NewDeployer(&provider.DeployerConfig{
|
||||||
ApiUrl: fApiUrl,
|
ApiUrl: fApiUrl,
|
||||||
ApiKey: fApiKey,
|
AccessTokenId: fTokenId,
|
||||||
|
AccessToken: fToken,
|
||||||
AllowInsecureConnections: true,
|
AllowInsecureConnections: true,
|
||||||
AutoRestart: true,
|
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("err: %+v", err)
|
t.Errorf("err: %+v", err)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package baotapanelsite
|
package ratpanelsite
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package baotapanelsite_test
|
package ratpanelsite_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@ -8,26 +8,26 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
provider "github.com/usual2970/certimate/internal/pkg/core/deployer/providers/baotapanel-site"
|
provider "github.com/usual2970/certimate/internal/pkg/core/deployer/providers/ratpanel-site"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
fInputCertPath string
|
fInputCertPath string
|
||||||
fInputKeyPath string
|
fInputKeyPath string
|
||||||
fApiUrl string
|
fApiUrl string
|
||||||
fApiKey string
|
fTokenId uint
|
||||||
fSiteType string
|
fToken string
|
||||||
fSiteName string
|
fSiteName string
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
argsPrefix := "CERTIMATE_DEPLOYER_BAOTAPANELSITE_"
|
argsPrefix := "CERTIMATE_DEPLOYER_RATPANELSITE_"
|
||||||
|
|
||||||
flag.StringVar(&fInputCertPath, argsPrefix+"INPUTCERTPATH", "", "")
|
flag.StringVar(&fInputCertPath, argsPrefix+"INPUTCERTPATH", "", "")
|
||||||
flag.StringVar(&fInputKeyPath, argsPrefix+"INPUTKEYPATH", "", "")
|
flag.StringVar(&fInputKeyPath, argsPrefix+"INPUTKEYPATH", "", "")
|
||||||
flag.StringVar(&fApiUrl, argsPrefix+"APIURL", "", "")
|
flag.StringVar(&fApiUrl, argsPrefix+"APIURL", "", "")
|
||||||
flag.StringVar(&fApiKey, argsPrefix+"APIKEY", "", "")
|
flag.UintVar(&fTokenId, argsPrefix+"TOKENID", 0, "")
|
||||||
flag.StringVar(&fSiteType, argsPrefix+"SITETYPE", "", "")
|
flag.StringVar(&fToken, argsPrefix+"TOKEN", "", "")
|
||||||
flag.StringVar(&fSiteName, argsPrefix+"SITENAME", "", "")
|
flag.StringVar(&fSiteName, argsPrefix+"SITENAME", "", "")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,12 +35,12 @@ func init() {
|
|||||||
Shell command to run this test:
|
Shell command to run this test:
|
||||||
|
|
||||||
go test -v ./baotapanel_site_test.go -args \
|
go test -v ./baotapanel_site_test.go -args \
|
||||||
--CERTIMATE_DEPLOYER_BAOTAPANELSITE_INPUTCERTPATH="/path/to/your-input-cert.pem" \
|
--CERTIMATE_DEPLOYER_RATPANELSITE_INPUTCERTPATH="/path/to/your-input-cert.pem" \
|
||||||
--CERTIMATE_DEPLOYER_BAOTAPANELSITE_INPUTKEYPATH="/path/to/your-input-key.pem" \
|
--CERTIMATE_DEPLOYER_RATPANELSITE_INPUTKEYPATH="/path/to/your-input-key.pem" \
|
||||||
--CERTIMATE_DEPLOYER_BAOTAPANELSITE_APIURL="http://127.0.0.1:8888" \
|
--CERTIMATE_DEPLOYER_RATPANELSITE_APIURL="http://127.0.0.1:8888" \
|
||||||
--CERTIMATE_DEPLOYER_BAOTAPANELSITE_APIKEY="your-api-key" \
|
--CERTIMATE_DEPLOYER_RATPANELSITE_TOKENID="your-access-token-id" \
|
||||||
--CERTIMATE_DEPLOYER_BAOTAPANELSITE_SITETYPE="php" \
|
--CERTIMATE_DEPLOYER_RATPANELSITE_TOKEN="your-access-token" \
|
||||||
--CERTIMATE_DEPLOYER_BAOTAPANELSITE_SITENAME="your-site-name"
|
--CERTIMATE_DEPLOYER_RATPANELSITE_SITENAME="your-site-name"
|
||||||
*/
|
*/
|
||||||
func TestDeploy(t *testing.T) {
|
func TestDeploy(t *testing.T) {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
@ -51,18 +51,17 @@ func TestDeploy(t *testing.T) {
|
|||||||
fmt.Sprintf("INPUTCERTPATH: %v", fInputCertPath),
|
fmt.Sprintf("INPUTCERTPATH: %v", fInputCertPath),
|
||||||
fmt.Sprintf("INPUTKEYPATH: %v", fInputKeyPath),
|
fmt.Sprintf("INPUTKEYPATH: %v", fInputKeyPath),
|
||||||
fmt.Sprintf("APIURL: %v", fApiUrl),
|
fmt.Sprintf("APIURL: %v", fApiUrl),
|
||||||
fmt.Sprintf("APIKEY: %v", fApiKey),
|
fmt.Sprintf("TOKENID: %v", fTokenId),
|
||||||
fmt.Sprintf("SITETYPE: %v", fSiteType),
|
fmt.Sprintf("TOKEN: %v", fToken),
|
||||||
fmt.Sprintf("SITENAME: %v", fSiteName),
|
fmt.Sprintf("SITENAME: %v", fSiteName),
|
||||||
}, "\n"))
|
}, "\n"))
|
||||||
|
|
||||||
deployer, err := provider.NewDeployer(&provider.DeployerConfig{
|
deployer, err := provider.NewDeployer(&provider.DeployerConfig{
|
||||||
ApiUrl: fApiUrl,
|
ApiUrl: fApiUrl,
|
||||||
ApiKey: fApiKey,
|
AccessTokenId: fTokenId,
|
||||||
|
AccessToken: fToken,
|
||||||
AllowInsecureConnections: true,
|
AllowInsecureConnections: true,
|
||||||
SiteType: fSiteType,
|
|
||||||
SiteName: fSiteName,
|
SiteName: fSiteName,
|
||||||
SiteNames: []string{fSiteName},
|
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("err: %+v", err)
|
t.Errorf("err: %+v", err)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package btpanelsdk
|
package ratpanelsdk
|
||||||
|
|
||||||
import "net/http"
|
import "net/http"
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package btpanelsdk
|
package ratpanelsdk
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package btpanelsdk
|
package ratpanelsdk
|
||||||
|
|
||||||
type BaseResponse interface {
|
type BaseResponse interface {
|
||||||
GetMessage() string
|
GetMessage() string
|
||||||
|
Loading…
x
Reference in New Issue
Block a user