mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-10 04:36:43 +00:00
feat(BRIDGE-37): Remote notification support
This commit is contained in:
17
tests/features/observability/remote_notification.feature
Normal file
17
tests/features/observability/remote_notification.feature
Normal file
@ -0,0 +1,17 @@
|
||||
Feature: Bridge send remote notification observability metrics
|
||||
Background:
|
||||
Given there exists an account with username "[user:user1]" and password "password"
|
||||
And there exists an account with username "[user:user2]" and password "password"
|
||||
Then it succeeds
|
||||
When bridge starts
|
||||
Then it succeeds
|
||||
|
||||
|
||||
Scenario: Send notification 'received' and 'processed' observability metric
|
||||
When the user logs in with username "[user:user1]" and password "password"
|
||||
And the user with username "[user:user1]" sends the following remote notification observability metric "received"
|
||||
Then it succeeds
|
||||
And the user with username "[user:user1]" sends the following remote notification observability metric "processed"
|
||||
Then it succeeds
|
||||
|
||||
|
||||
@ -216,4 +216,8 @@ func (s *scenario) steps(ctx *godog.ScenarioContext) {
|
||||
ctx.Step(`^the contact "([^"]*)" of user "([^"]*)" has encryption "([^"]*)"$`, s.contactOfUserHasEncryption)
|
||||
ctx.Step(`^the contact "([^"]*)" of user "([^"]*)" has public key:$`, s.contactOfUserHasPubKey)
|
||||
ctx.Step(`^the contact "([^"]*)" of user "([^"]*)" has public key from file "([^"]*)"$`, s.contactOfUserHasPubKeyFromFile)
|
||||
|
||||
// ==== OBSERVABILITY METRICS ====
|
||||
ctx.Step(`^the user with username "([^"]*)" sends the following remote notification observability metric "([^"]*)"`,
|
||||
s.userRemoteNotificationMetricTest)
|
||||
}
|
||||
|
||||
@ -23,11 +23,13 @@ import (
|
||||
"fmt"
|
||||
"net/mail"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/ProtonMail/gluon/rfc822"
|
||||
"github.com/ProtonMail/go-proton-api"
|
||||
"github.com/ProtonMail/gopenpgp/v2/crypto"
|
||||
"github.com/ProtonMail/proton-bridge/v3/internal/bridge"
|
||||
"github.com/ProtonMail/proton-bridge/v3/internal/services/notifications"
|
||||
"github.com/ProtonMail/proton-bridge/v3/internal/vault"
|
||||
"github.com/ProtonMail/proton-bridge/v3/pkg/algo"
|
||||
"github.com/bradenaw/juniper/iterator"
|
||||
@ -690,3 +692,24 @@ func matchSettings(have proton.MailSettings, want MailSettings) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *scenario) userRemoteNotificationMetricTest(username string, metricName string) error {
|
||||
var metricToTest proton.ObservabilityMetric
|
||||
switch strings.ToLower(metricName) {
|
||||
case "processed":
|
||||
metricToTest = notifications.GenerateProcessedMetric(1)
|
||||
case "received":
|
||||
metricToTest = notifications.GenerateReceivedMetric(1)
|
||||
default:
|
||||
return fmt.Errorf("invalid metric name specified")
|
||||
}
|
||||
|
||||
// Account for endpoint throttle
|
||||
time.Sleep(time.Second * 5)
|
||||
|
||||
return s.t.withClientPass(context.Background(), username, s.t.getUserByName(username).userPass, func(ctx context.Context, c *proton.Client) error {
|
||||
batch := proton.ObservabilityBatch{Metrics: []proton.ObservabilityMetric{metricToTest}}
|
||||
err := c.SendObservabilityBatch(ctx, batch)
|
||||
return err
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user