Implement secure communications
The communication towards the consumer is not secured in this commit.
Also changed the configuration so that the address of the DMaaP Message
Router is given in one variable, named DMAAP_MR_ADDR.
Issue-ID: NONRTRIC-601
Signed-off-by: elinuxhenrik <henrik.b.andersson@est.tech>
Change-Id: Icb5b3c255367e823fcae2168ab37603092815893
diff --git a/dmaap-mediator-producer/internal/config/config.go b/dmaap-mediator-producer/internal/config/config.go
index dfd2505..b31b334 100644
--- a/dmaap-mediator-producer/internal/config/config.go
+++ b/dmaap-mediator-producer/internal/config/config.go
@@ -32,8 +32,9 @@
InfoProducerHost string
InfoProducerPort int
InfoCoordinatorAddress string
- MRHost string
- MRPort int
+ DMaaPMRAddress string
+ ProducerCertPath string
+ ProducerKeyPath string
}
func New() *Config {
@@ -41,9 +42,10 @@
LogLevel: getLogLevel(),
InfoProducerHost: getEnv("INFO_PRODUCER_HOST", ""),
InfoProducerPort: getEnvAsInt("INFO_PRODUCER_PORT", 8085),
- InfoCoordinatorAddress: getEnv("INFO_COORD_ADDR", "http://enrichmentservice:8083"),
- MRHost: getEnv("MR_HOST", "http://message-router.onap"),
- MRPort: getEnvAsInt("MR_PORT", 3904),
+ InfoCoordinatorAddress: getEnv("INFO_COORD_ADDR", "https://enrichmentservice:8434"),
+ DMaaPMRAddress: getEnv("DMAAP_MR_ADDR", "https://message-router.onap:3905"),
+ ProducerCertPath: getEnv("PRODUCER_CERT_PATH", "configs/producer.crt"),
+ ProducerKeyPath: getEnv("PRODUCER_KEY_PATH", "configs/producer.key"),
}
}
diff --git a/dmaap-mediator-producer/internal/config/config_test.go b/dmaap-mediator-producer/internal/config/config_test.go
index fc64e57..9420a2a 100644
--- a/dmaap-mediator-producer/internal/config/config_test.go
+++ b/dmaap-mediator-producer/internal/config/config_test.go
@@ -36,8 +36,9 @@
os.Setenv("INFO_PRODUCER_HOST", "producerHost")
os.Setenv("INFO_PRODUCER_PORT", "8095")
os.Setenv("INFO_COORD_ADDR", "infoCoordAddr")
- os.Setenv("MR_HOST", "mrHost")
- os.Setenv("MR_PORT", "3908")
+ os.Setenv("DMAAP_MR_ADDR", "mrHost:3908")
+ os.Setenv("PRODUCER_CERT_PATH", "cert")
+ os.Setenv("PRODUCER_KEY_PATH", "key")
t.Cleanup(func() {
os.Clearenv()
})
@@ -46,8 +47,9 @@
InfoProducerHost: "producerHost",
InfoProducerPort: 8095,
InfoCoordinatorAddress: "infoCoordAddr",
- MRHost: "mrHost",
- MRPort: 3908,
+ DMaaPMRAddress: "mrHost:3908",
+ ProducerCertPath: "cert",
+ ProducerKeyPath: "key",
}
got := New()
@@ -68,9 +70,10 @@
LogLevel: log.InfoLevel,
InfoProducerHost: "",
InfoProducerPort: 8085,
- InfoCoordinatorAddress: "http://enrichmentservice:8083",
- MRHost: "http://message-router.onap",
- MRPort: 3904,
+ InfoCoordinatorAddress: "https://enrichmentservice:8434",
+ DMaaPMRAddress: "https://message-router.onap:3905",
+ ProducerCertPath: "configs/producer.crt",
+ ProducerKeyPath: "configs/producer.key",
}
if got := New(); !reflect.DeepEqual(got, &wantConfig) {
t.Errorf("New() = %v, want %v", got, &wantConfig)
@@ -94,9 +97,10 @@
LogLevel: log.InfoLevel,
InfoProducerHost: "",
InfoProducerPort: 8085,
- InfoCoordinatorAddress: "http://enrichmentservice:8083",
- MRHost: "http://message-router.onap",
- MRPort: 3904,
+ InfoCoordinatorAddress: "https://enrichmentservice:8434",
+ DMaaPMRAddress: "https://message-router.onap:3905",
+ ProducerCertPath: "configs/producer.crt",
+ ProducerKeyPath: "configs/producer.key",
}
got := New()
diff --git a/dmaap-mediator-producer/internal/config/registrator_test.go b/dmaap-mediator-producer/internal/config/registrator_test.go
index 2cffa2c..324aed0 100644
--- a/dmaap-mediator-producer/internal/config/registrator_test.go
+++ b/dmaap-mediator-producer/internal/config/registrator_test.go
@@ -57,7 +57,7 @@
assertions.Equal("http", actualRequest.URL.Scheme)
assertions.Equal("localhost:9990", actualRequest.URL.Host)
assertions.Equal("/data-producer/v1/info-types/Type1", actualRequest.URL.Path)
- assertions.Equal("application/json; charset=utf-8", actualRequest.Header.Get("Content-Type"))
+ assertions.Equal("application/json", actualRequest.Header.Get("Content-Type"))
body, _ := ioutil.ReadAll(actualRequest.Body)
expectedBody := []byte(`{"info_job_data_schema": {"type": "object","properties": {},"additionalProperties": false}}`)
assertions.Equal(expectedBody, body)
@@ -92,7 +92,7 @@
assertions.Equal("http", actualRequest.URL.Scheme)
assertions.Equal("localhost:9990", actualRequest.URL.Host)
assertions.Equal("/data-producer/v1/info-producers/Producer1", actualRequest.URL.Path)
- assertions.Equal("application/json; charset=utf-8", actualRequest.Header.Get("Content-Type"))
+ assertions.Equal("application/json", actualRequest.Header.Get("Content-Type"))
body, _ := ioutil.ReadAll(actualRequest.Body)
expectedBody := []byte(`{"info_producer_supervision_callback_url":"supervisionCallbackUrl","supported_info_types":["type1"],"info_job_callback_url":"jobCallbackUrl"}`)
assertions.Equal(expectedBody, body)