Skip to content

Commit c94b875

Browse files
Merge pull request #389 from MateSaary/fix-e2e-again
Fix interceptor e2e env issue & investigation name logging
2 parents d97da5a + 465aa7f commit c94b875

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

cadctl/cmd/investigate/investigate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ func run(cmd *cobra.Command, _ []string) error {
140140

141141
investigationResources := &investigation.Resources{Name: alertInvestigation.Name(), Cluster: cluster, ClusterDeployment: clusterDeployment, AwsClient: customerAwsClient, OcmClient: ocmClient, PdClient: pdClient}
142142

143-
logging.Infof("Starting investigation for %s", alertInvestigation.Name)
143+
logging.Infof("Starting investigation for %s", alertInvestigation.Name())
144144
result, err := alertInvestigation.Run(investigationResources)
145145
updateMetrics(alertInvestigation.Name(), &result)
146146
return err

interceptor/pkg/interceptor/pdinterceptor.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,6 @@ func (pdi *PagerDutyInterceptor) executeInterceptor(r *http.Request) ([]byte, er
110110

111111
var ireq triggersv1.InterceptorRequest
112112

113-
// logging request
114-
logging.Debug("Unwrapped Request header: %v", extractedRequest.Header)
115113
logging.Debug("Unwrapped Request body: ", originalReq.Body)
116114

117115
token, _ := os.LookupEnv("PD_SIGNATURE")
@@ -159,7 +157,7 @@ func (pdi *PagerDutyInterceptor) Process(ctx context.Context, r *triggersv1.Inte
159157
}
160158
}
161159

162-
logging.Infof("Incident %s is mapped to investigation '%s', returning InterceptorResponse `Continue: true`.", pdClient.GetIncidentID(), investigation.Name)
160+
logging.Infof("Incident %s is mapped to investigation '%s', returning InterceptorResponse `Continue: true`.", pdClient.GetIncidentID(), investigation.Name())
163161
return &triggersv1.InterceptorResponse{
164162
Continue: true,
165163
}

interceptor/test/e2e.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,19 @@ function test_interceptor {
2020

2121
local incident_id=$1
2222
local expected_response=$2
23+
local override_signature=$3
2324

2425
# Run the interceptor and print logs to temporary log file
26+
export PD_SIGNATURE="test"
2527
CAD_PD_TOKEN=$(echo $pd_test_token) CAD_SILENT_POLICY=$(echo $pd_test_silence_policy) ./../bin/interceptor > $temp_log_file 2>&1 &
26-
PD_SIGNATURE="test"
2728
PAYLOAD_BODY="{\\\"__pd_metadata\\\":{\\\"incident\\\":{\\\"id\\\":\\\"$incident_id\\\"}}}"
2829
PAYLOAD_BODY_FORMATTED='{"__pd_metadata":{"incident":{"id":"'$incident_id'"}}}'
30+
31+
# Allow for test 3; override the signature after correct one has already been added to env
32+
if [[ "$override_signature" != "" ]]; then
33+
export PD_SIGNATURE=$override_signature
34+
fi
35+
2936
SIGN=$(echo -n "$PAYLOAD_BODY_FORMATTED" | sha256hmac -K $PD_SIGNATURE | tr -d "[:space:]-")
3037

3138
# Store the PID of the interceptor process
@@ -85,4 +92,4 @@ test_interceptor "Q3722KGCG12ZWD" "$EXPECTED_RESPONSE_STOP"
8592
# Test for an alert with invalid signature
8693
echo "Test 3: expected failure due to invalid signature"
8794
PD_SIGNATURE="invalid-signature"
88-
test_interceptor "Q12WO44XJLR3H3" "$EXPECTED_RESPONSE_SIGNATURE_ERROR"
95+
test_interceptor "Q12WO44XJLR3H3" "$EXPECTED_RESPONSE_SIGNATURE_ERROR" "invalid-signature"

0 commit comments

Comments
 (0)