mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-11 05:06:51 +00:00
feat(GODT-2554): Compute telemetry availability from API UserSettings.
This commit is contained in:
@ -153,6 +153,8 @@ func TestFeatures(testingT *testing.T) {
|
||||
ctx.Step(`^bridge sends an update not available event$`, s.bridgeSendsAnUpdateNotAvailableEvent)
|
||||
ctx.Step(`^bridge sends a forced update event$`, s.bridgeSendsAForcedUpdateEvent)
|
||||
ctx.Step(`^bridge reports a message with "([^"]*)"$`, s.bridgeReportsMessage)
|
||||
ctx.Step(`^bridge telemetry feature is enabled$`, s.bridgeTelemetryFeatureEnabled)
|
||||
ctx.Step(`^bridge telemetry feature is disabled$`, s.bridgeTelemetryFeatureDisabled)
|
||||
|
||||
// ==== FRONTEND ====
|
||||
ctx.Step(`^frontend sees that bridge is version "([^"]*)"$`, s.frontendSeesThatBridgeIsVersion)
|
||||
@ -166,6 +168,7 @@ func TestFeatures(testingT *testing.T) {
|
||||
ctx.Step(`^user "([^"]*)" is listed but not connected$`, s.userIsListedButNotConnected)
|
||||
ctx.Step(`^user "([^"]*)" is not listed$`, s.userIsNotListed)
|
||||
ctx.Step(`^user "([^"]*)" finishes syncing$`, s.userFinishesSyncing)
|
||||
ctx.Step(`^user "([^"]*)" has telemetry set to (\d+)$`, s.userHasTelemetrySetTo)
|
||||
|
||||
// ==== IMAP ====
|
||||
ctx.Step(`^user "([^"]*)" connects IMAP client "([^"]*)"$`, s.userConnectsIMAPClient)
|
||||
|
||||
@ -284,6 +284,22 @@ func (s *scenario) bridgeReportsMessage(message string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *scenario) bridgeTelemetryFeatureEnabled() error {
|
||||
return s.checkTelemetry(true)
|
||||
}
|
||||
|
||||
func (s *scenario) bridgeTelemetryFeatureDisabled() error {
|
||||
return s.checkTelemetry(false)
|
||||
}
|
||||
|
||||
func (s *scenario) checkTelemetry(expect bool) error {
|
||||
res := s.t.bridge.ComputeTelemetry()
|
||||
if res != expect {
|
||||
return fmt.Errorf("expected telemetry feature %v but got %v ", expect, res)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *scenario) theUserHidesAllMail() error {
|
||||
return s.t.bridge.SetShowAllMail(false)
|
||||
}
|
||||
|
||||
18
tests/features/user/telemetry.feature
Normal file
18
tests/features/user/telemetry.feature
Normal file
@ -0,0 +1,18 @@
|
||||
Feature: Bridge send usage 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"
|
||||
And bridge starts
|
||||
|
||||
|
||||
Scenario: Telemetry availability - No user
|
||||
Then bridge telemetry feature is enabled
|
||||
|
||||
Scenario: Telemetry availability - Multi user
|
||||
When the user logs in with username "[user:user1]" and password "password"
|
||||
And user "[user:user1]" finishes syncing
|
||||
Then bridge telemetry feature is enabled
|
||||
When the user logs in with username "[user:user2]" and password "password"
|
||||
And user "[user:user2]" finishes syncing
|
||||
When user "[user:user2]" has telemetry set to 0
|
||||
Then bridge telemetry feature is disabled
|
||||
@ -414,6 +414,18 @@ func (s *scenario) userFinishesSyncing(username string) error {
|
||||
return s.bridgeSendsSyncStartedAndFinishedEventsForUser(username)
|
||||
}
|
||||
|
||||
func (s *scenario) userHasTelemetrySetTo(username string, telemetry int) error {
|
||||
return s.t.withClientPass(context.Background(), username, s.t.getUserByName(username).userPass, func(ctx context.Context, c *proton.Client) error {
|
||||
var req proton.SetTelemetryReq
|
||||
req.Telemetry = proton.SettingsBool(telemetry)
|
||||
_, err := c.SetUserSettingsTelemetry(ctx, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func (s *scenario) addAdditionalAddressToAccount(username, address string, disabled bool) error {
|
||||
userID := s.t.getUserByName(username).getUserID()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user