mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Add flags to sqs and s3 integration tests for key and secret
This commit is contained in:
committed by
Dan Christian Bogos
parent
9175431764
commit
857596e536
@@ -5,29 +5,24 @@
|
||||
"log_level": 7
|
||||
},
|
||||
|
||||
|
||||
"listen": {
|
||||
"rpc_json": ":22012",
|
||||
"rpc_gob": ":22013",
|
||||
"http": ":22080"
|
||||
},
|
||||
|
||||
|
||||
"data_db": {
|
||||
"db_type": "mongo",
|
||||
"db_name": "10",
|
||||
"db_port": 27017
|
||||
},
|
||||
|
||||
|
||||
"stor_db": {
|
||||
"db_type": "mongo",
|
||||
"db_name": "cgrates",
|
||||
"db_port": 27017
|
||||
},
|
||||
|
||||
|
||||
|
||||
"rpc_conns": {
|
||||
"cache_conn": {
|
||||
"strategy": "*broadcast_sync",
|
||||
|
||||
@@ -21,11 +21,11 @@
|
||||
{
|
||||
"id": "sqs_test_file",
|
||||
"type": "*sqs_json_map",
|
||||
"export_path": "https://sqs.eu-central-1.amazonaws.com/?awsRegion=eu-central-1&awsKey=AKIAYPZSIYZCZ5U45KEO&awsSecret=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",
|
||||
"export_path": "https://sqs.eu-central-1.amazonaws.com/",
|
||||
"opts": {
|
||||
"awsRegion": "eu-central-1",
|
||||
"awsKey": "AKIAYPZSIYZCZ5U45KEO",
|
||||
"awsSecret": "RIUlDyxh7qpoxSBomGOjymIZqSs/pgdXkW16HlKx",
|
||||
"awsKey": "set-using-flags",
|
||||
"awsSecret": "set-using-flags",
|
||||
"sqsQueueID": "testQueue"
|
||||
},
|
||||
"attempts": 1,
|
||||
@@ -38,11 +38,11 @@
|
||||
{
|
||||
"id": "s3_test_file",
|
||||
"type": "*s3_json_map",
|
||||
"export_path": "https://s3.eu-central-1.amazonaws.com/?awsRegion=eu-central-1&awsKey=AKIAYPZSIYZCZ5U45KEO&awsSecret=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",
|
||||
"export_path": "https://s3.eu-central-1.amazonaws.com/",
|
||||
"opts": {
|
||||
"awsRegion": "eu-central-1",
|
||||
"awsKey": "AKIAYPZSIYZCZ5U45KEO",
|
||||
"awsSecret": "RIUlDyxh7qpoxSBomGOjymIZqSs/pgdXkW16HlKx",
|
||||
"awsKey": "set-using-flags",
|
||||
"awsSecret": "set-using-flags",
|
||||
"s3BucketID": "cgrates-cdrs"
|
||||
},
|
||||
"attempts": 1,
|
||||
|
||||
@@ -22,6 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
package ees
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/rpc"
|
||||
"path"
|
||||
"testing"
|
||||
@@ -56,6 +57,10 @@ var (
|
||||
)
|
||||
|
||||
func TestS3Export(t *testing.T) {
|
||||
if awsKey == nil || *awsKey == utils.EmptyString ||
|
||||
awsSecret == nil || *awsSecret == utils.EmptyString {
|
||||
t.SkipNow()
|
||||
}
|
||||
s3ConfDir = "ees_s3&sqs"
|
||||
for _, stest := range sTestsS3 {
|
||||
t.Run(s3ConfDir, stest)
|
||||
@@ -68,6 +73,13 @@ func testS3LoadConfig(t *testing.T) {
|
||||
if s3Cfg, err = config.NewCGRConfigFromPath(s3CfgPath); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
for _, value := range s3Cfg.EEsCfg().Exporters {
|
||||
if value.ID == "sqs_test_file" {
|
||||
value.ExportPath = fmt.Sprintf("https://s3.eu-central-1.amazonaws.com/?awsRegion=eu-central-1&awsKey=%s&awsSecret=%s", *awsKey, *awsSecret)
|
||||
value.Opts.AWSKey = awsKey
|
||||
value.Opts.AWSSecret = awsSecret
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testS3ResetDataDB(t *testing.T) {
|
||||
@@ -131,10 +143,8 @@ func testS3ExportEvent(t *testing.T) {
|
||||
}
|
||||
|
||||
func testS3VerifyExport(t *testing.T) {
|
||||
endpoint := "https://s3.eu-central-1.amazonaws.com/?awsRegion=eu-central-1&awsKey=AKIAYPZSIYZCZ5U45KEO&awsSecret=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"
|
||||
endpoint := fmt.Sprintf("https://s3.eu-central-1.amazonaws.com/?awsRegion=eu-central-1&awsKey=%s&awsSecret=%s", *awsKey, *awsSecret)
|
||||
region := "eu-central-1"
|
||||
awsKey := "AKIAYPZSIYZCZ5U45KEO"
|
||||
awsSecret := "RIUlDyxh7qpoxSBomGOjymIZqSs/pgdXkW16HlKxt"
|
||||
qname := "cgrates-cdrs"
|
||||
|
||||
key := "key"
|
||||
@@ -143,7 +153,7 @@ func testS3VerifyExport(t *testing.T) {
|
||||
cfg := aws.Config{Endpoint: aws.String(endpoint)}
|
||||
cfg.Region = aws.String(region)
|
||||
|
||||
cfg.Credentials = credentials.NewStaticCredentials(awsKey, awsSecret, "")
|
||||
cfg.Credentials = credentials.NewStaticCredentials(*awsKey, *awsSecret, "")
|
||||
var err error
|
||||
sess, err = session.NewSessionWithOptions(
|
||||
session.Options{
|
||||
|
||||
@@ -22,6 +22,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
package ees
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"net/rpc"
|
||||
"path"
|
||||
"testing"
|
||||
@@ -38,6 +40,8 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
awsKey = flag.String("awsKey", utils.EmptyString, "Access key ID for IAM user")
|
||||
awsSecret = flag.String("awsSecret", utils.EmptyString, "Secret access key")
|
||||
sqsConfDir string
|
||||
sqsCfgPath string
|
||||
sqsCfg *config.CGRConfig
|
||||
@@ -56,6 +60,10 @@ var (
|
||||
)
|
||||
|
||||
func TestSQSExport(t *testing.T) {
|
||||
if awsKey == nil || *awsKey == utils.EmptyString ||
|
||||
awsSecret == nil || *awsSecret == utils.EmptyString {
|
||||
t.SkipNow()
|
||||
}
|
||||
sqsConfDir = "ees_s3&sqs"
|
||||
for _, stest := range sTestsSQS {
|
||||
t.Run(sqsConfDir, stest)
|
||||
@@ -68,6 +76,13 @@ func testSQSLoadConfig(t *testing.T) {
|
||||
if sqsCfg, err = config.NewCGRConfigFromPath(sqsCfgPath); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
for _, value := range sqsCfg.EEsCfg().Exporters {
|
||||
if value.ID == "sqs_test_file" {
|
||||
value.ExportPath = fmt.Sprintf("https://sqs.eu-central-1.amazonaws.com/?awsRegion=eu-central-1&awsKey=%s&awsSecret=%s", *awsKey, *awsSecret)
|
||||
value.Opts.AWSKey = awsKey
|
||||
value.Opts.AWSSecret = awsSecret
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testSQSResetDataDB(t *testing.T) {
|
||||
@@ -132,17 +147,15 @@ func testSQSExportEvent(t *testing.T) {
|
||||
}
|
||||
|
||||
func testSQSVerifyExport(t *testing.T) {
|
||||
endpoint := "https://sqs.eu-central-1.amazonaws.com/?awsRegion=eu-central-1&awsKey=AKIAYPZSIYZCZ5U45KEO&awsSecret=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"
|
||||
endpoint := fmt.Sprintf("https://sqs.eu-central-1.amazonaws.com/?awsRegion=eu-central-1&awsKey=%s&awsSecret=%s", *awsKey, *awsSecret)
|
||||
region := "eu-central-1"
|
||||
awsKey := "AKIAYPZSIYZCZ5U45KEO"
|
||||
awsSecret := "RIUlDyxh7qpoxSBomGOjymIZqSs/pgdXkW16HlKxt"
|
||||
qname := "testQueue"
|
||||
|
||||
var sess *session.Session
|
||||
cfg := aws.Config{Endpoint: aws.String(endpoint)}
|
||||
cfg.Region = aws.String(region)
|
||||
var err error
|
||||
cfg.Credentials = credentials.NewStaticCredentials(awsKey, awsSecret, "")
|
||||
cfg.Credentials = credentials.NewStaticCredentials(*awsKey, *awsSecret, "")
|
||||
sess, err = session.NewSessionWithOptions(
|
||||
session.Options{
|
||||
Config: cfg,
|
||||
|
||||
Reference in New Issue
Block a user