Skip to content

Commit

Permalink
Bring back autoreset feature flag (#20142)
Browse files Browse the repository at this point in the history
  • Loading branch information
zapu committed Oct 4, 2019
1 parent 7161bf2 commit 51cae43
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 9 deletions.
8 changes: 5 additions & 3 deletions go/engine/login.go
Expand Up @@ -112,9 +112,11 @@ func (e *Login) Run(m libkb.MetaContext) (err error) {
if err != nil {
m.Debug("loginProvisionedDevice error: %s", err)

// Suggest autoreset if user failed to log in and we're provisioned
if _, ok := err.(libkb.PassphraseError); ok {
return e.suggestRecoveryForgotPassword(m)
if m.G().Env.GetFeatureFlags().HasFeature(libkb.EnvironmentFeatureAutoresetPipeline) {
// Suggest autoreset if user failed to log in and we're provisioned
if _, ok := err.(libkb.PassphraseError); ok {
return e.suggestRecoveryForgotPassword(m)
}
}

return err
Expand Down
2 changes: 1 addition & 1 deletion go/engine/login_provision.go
Expand Up @@ -767,7 +767,7 @@ func (e *loginProvision) chooseDevice(m libkb.MetaContext, pgp bool) (err error)
}

// TODO: Y2K-3 cleanup for autoreset.
autoresetEnabled := true
autoresetEnabled := m.G().Env.GetFeatureFlags().HasFeature(libkb.EnvironmentFeatureAutoresetPipeline)

// check to see if they have a PUK, in which case they must select a device
hasPUK, err := e.hasPerUserKey(m)
Expand Down
2 changes: 2 additions & 0 deletions go/engine/login_test.go
Expand Up @@ -581,6 +581,7 @@ func TestProvisionAutoreset(t *testing.T) {
// device X (provisioner) context:
tcX := SetupEngineTest(t, "provision_x")
defer tcX.Cleanup()
libkb.AddEnvironmentFeatureForTest(tcX, libkb.EnvironmentFeatureAutoresetPipeline)

// create user (and device X)
userX := CreateAndSignupFakeUser(tcX, "login")
Expand All @@ -590,6 +591,7 @@ func TestProvisionAutoreset(t *testing.T) {
// device Y (provisionee) context:
tcY := SetupEngineTest(t, "provision_y")
defer tcY.Cleanup()
libkb.AddEnvironmentFeatureForTest(tcY, libkb.EnvironmentFeatureAutoresetPipeline)

uis := libkb.UIs{
ProvisionUI: newTestProvisionUIChooseNoDevice(),
Expand Down
4 changes: 2 additions & 2 deletions go/engine/passphrase_recover.go
Expand Up @@ -65,10 +65,10 @@ func (e *PassphraseRecover) Run(mctx libkb.MetaContext) (err error) {
}

// If the reset pipeline is not enabled, we'll want this to act exactly the same way as before
// Autoreset hardcoded on for now.
// TODO: Y2K-3 cleanup for autoreset.
autoresetEnabled := mctx.G().Env.GetFeatureFlags().HasFeature(libkb.EnvironmentFeatureAutoresetPipeline)

if false {
if !autoresetEnabled {
// The device has to be preprovisioned for this account in this flow
if !e.usernameFound {
return libkb.NotProvisionedError{}
Expand Down
6 changes: 5 additions & 1 deletion go/engine/passphrase_recover_test.go
Expand Up @@ -16,7 +16,7 @@ import (

func TestPassphraseRecoverLegacy(t *testing.T) {
// Legacy flow hardcoded off
t.Skip()
// TODO Y2K-3 might have to skip this when feature flag is removed
tc := SetupEngineTest(t, "PassphraseRecoverLegacy")
defer tc.Cleanup()
u, paperkey := CreateAndSignupLPK(tc, "pprec")
Expand Down Expand Up @@ -92,6 +92,7 @@ func TestPassphraseRecoverLoggedIn(t *testing.T) {
tc := SetupEngineTest(t, "PassphraseRecoverGuideAndReset")
defer tc.Cleanup()
u := CreateAndSignupFakeUser(tc, "pprec")
libkb.AddEnvironmentFeatureForTest(tc, libkb.EnvironmentFeatureAutoresetPipeline)

loginUI := &TestLoginUIRecover{}
uis := libkb.UIs{
Expand Down Expand Up @@ -123,6 +124,7 @@ func TestPassphraseRecoverLoggedIn(t *testing.T) {
func TestPassphraseRecoverGuideAndReset(t *testing.T) {
tc := SetupEngineTest(t, "PassphraseRecoverGuideAndReset")
defer tc.Cleanup()
libkb.AddEnvironmentFeatureForTest(tc, libkb.EnvironmentFeatureAutoresetPipeline)
u := CreateAndSignupFakeUser(tc, "pprec")
Logout(tc)

Expand Down Expand Up @@ -192,6 +194,7 @@ func TestPassphraseRecoverGuideAndReset(t *testing.T) {
func TestPassphraseRecoverNoDevices(t *testing.T) {
tc := SetupEngineTest(t, "PassphraseRecoverNoDevices")
defer tc.Cleanup()
libkb.AddEnvironmentFeatureForTest(tc, libkb.EnvironmentFeatureAutoresetPipeline)
u := createFakeUserWithPGPOnly(t, tc)

// If the only way to provision the account is to do it with a password,
Expand Down Expand Up @@ -222,6 +225,7 @@ func TestPassphraseRecoverNoDevices(t *testing.T) {
func TestPassphraseRecoverChangeWithPaper(t *testing.T) {
tc1 := SetupEngineTest(t, "PassphraseRecoverChangeWithPaper")
defer tc1.Cleanup()
libkb.AddEnvironmentFeatureForTest(tc1, libkb.EnvironmentFeatureAutoresetPipeline)

// Prepare two accounts on the same device
u1, paperkey1 := CreateAndSignupLPK(tc1, "pprec")
Expand Down
5 changes: 3 additions & 2 deletions go/libkb/features.go
Expand Up @@ -13,8 +13,9 @@ type Feature string
type FeatureFlags []Feature

const (
EnvironmentFeatureAllowHighSkips = Feature("env_allow_high_skips")
EnvironmentFeatureMerkleCheckpoint = Feature("merkle_checkpoint")
EnvironmentFeatureAllowHighSkips = Feature("env_allow_high_skips")
EnvironmentFeatureAutoresetPipeline = Feature("env_autoreset")
EnvironmentFeatureMerkleCheckpoint = Feature("merkle_checkpoint")
)

// StringToFeatureFlags returns a set of feature flags
Expand Down

0 comments on commit 51cae43

Please sign in to comment.