github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/libkb/team_stub.go (about)

     1  package libkb
     2  
     3  import (
     4  	"fmt"
     5  	"time"
     6  
     7  	gregor "github.com/keybase/client/go/gregor"
     8  	keybase1 "github.com/keybase/client/go/protocol/keybase1"
     9  	context "golang.org/x/net/context"
    10  )
    11  
    12  type nullTeamLoader struct {
    13  	Contextified
    14  }
    15  
    16  var _ TeamLoader = (*nullTeamLoader)(nil)
    17  
    18  func newNullTeamLoader(g *GlobalContext) *nullTeamLoader {
    19  	return &nullTeamLoader{NewContextified(g)}
    20  }
    21  
    22  // VerifyTeamName verifies that id corresponds to name and returns an error
    23  // if it doesn't. Right now, it is a Noop (and therefore insecure) to get
    24  // tests to pass. Once we have an actual implementation, we should change this
    25  // to error out in all cases.
    26  func (n nullTeamLoader) VerifyTeamName(ctx context.Context, id keybase1.TeamID, name keybase1.TeamName) error {
    27  	return fmt.Errorf("null team loader")
    28  }
    29  
    30  func (n nullTeamLoader) ImplicitAdmins(ctx context.Context, teamID keybase1.TeamID) (impAdmins []keybase1.UserVersion, err error) {
    31  	return nil, fmt.Errorf("null team loader")
    32  }
    33  
    34  func (n nullTeamLoader) MapTeamAncestors(ctx context.Context, f func(t keybase1.TeamSigChainState, n keybase1.TeamName) error, teamID keybase1.TeamID, reason string, forceFullReloadOnceToAssert func(t keybase1.TeamSigChainState) bool) error {
    35  	return fmt.Errorf("null team loader")
    36  }
    37  
    38  // MapIDToName maps the team ID to the corresponding name, and can be serviced
    39  // from the team cache. If no entry is available in the cache, it is OK to return
    40  // an empty/nil TeamName, and callers are free to try again with a server access
    41  // (this actually happens in the Resolver).
    42  func (n nullTeamLoader) MapIDToName(ctx context.Context, id keybase1.TeamID) (keybase1.TeamName, error) {
    43  	return keybase1.TeamName{}, fmt.Errorf("null team loader")
    44  }
    45  
    46  func (n nullTeamLoader) NotifyTeamRename(ctx context.Context, id keybase1.TeamID, newName string) error {
    47  	return nil
    48  }
    49  
    50  func (n nullTeamLoader) Load(context.Context, keybase1.LoadTeamArg) (*keybase1.TeamData, *keybase1.HiddenTeamChain, error) {
    51  	return nil, nil, fmt.Errorf("null team loader")
    52  }
    53  
    54  func (n nullTeamLoader) Freeze(context.Context, keybase1.TeamID) error {
    55  	return fmt.Errorf("null team loader")
    56  }
    57  
    58  func (n nullTeamLoader) Tombstone(context.Context, keybase1.TeamID) error {
    59  	return fmt.Errorf("null team loader")
    60  }
    61  
    62  func (n *nullTeamLoader) HintLatestSeqno(ctx context.Context, id keybase1.TeamID, seqno keybase1.Seqno) error {
    63  	return nil
    64  }
    65  
    66  func (n *nullTeamLoader) ResolveNameToIDUntrusted(ctx context.Context, teamName keybase1.TeamName, public bool, allowCache bool) (id keybase1.TeamID, err error) {
    67  	return id, fmt.Errorf("null team loader")
    68  }
    69  
    70  func (n *nullTeamLoader) ForceRepollUntil(ctx context.Context, t gregor.TimeOrOffset) error {
    71  	return nil
    72  }
    73  
    74  func (n *nullTeamLoader) IsOpenCached(ctx context.Context, teamID keybase1.TeamID) (bool, error) {
    75  	return false, fmt.Errorf("null team loader")
    76  }
    77  
    78  func (n nullTeamLoader) ClearMem() {}
    79  
    80  type nullFastTeamLoader struct{}
    81  
    82  var _ FastTeamLoader = nullFastTeamLoader{}
    83  
    84  func (n nullFastTeamLoader) Load(MetaContext, keybase1.FastTeamLoadArg) (keybase1.FastTeamLoadRes, error) {
    85  	return keybase1.FastTeamLoadRes{}, fmt.Errorf("null fast team loader")
    86  }
    87  
    88  func (n nullFastTeamLoader) HintLatestSeqno(_ MetaContext, _ keybase1.TeamID, _ keybase1.Seqno) error {
    89  	return nil
    90  }
    91  
    92  func (n nullFastTeamLoader) VerifyTeamName(_ MetaContext, _ keybase1.TeamID, _ keybase1.TeamName, _ bool) error {
    93  	return nil
    94  }
    95  
    96  func (n nullFastTeamLoader) ForceRepollUntil(_ MetaContext, _ gregor.TimeOrOffset) error {
    97  	return nil
    98  }
    99  
   100  func (n nullFastTeamLoader) Freeze(MetaContext, keybase1.TeamID) error {
   101  	return fmt.Errorf("null fast team loader")
   102  }
   103  
   104  func (n nullFastTeamLoader) Tombstone(MetaContext, keybase1.TeamID) error {
   105  	return fmt.Errorf("null fast team loader")
   106  }
   107  
   108  func newNullFastTeamLoader() nullFastTeamLoader { return nullFastTeamLoader{} }
   109  
   110  type nullTeamAuditor struct{}
   111  
   112  var _ TeamAuditor = nullTeamAuditor{}
   113  
   114  func (n nullTeamAuditor) AuditTeam(m MetaContext, id keybase1.TeamID, isPublic bool, headMerkleSeqno keybase1.Seqno, chain map[keybase1.Seqno]keybase1.LinkID, hiddenChain map[keybase1.Seqno]keybase1.LinkID, maxSeqno keybase1.Seqno, maxHiddenSeqno keybase1.Seqno, lastMerkleRoot *MerkleRoot, auditMode keybase1.AuditMode) (err error) {
   115  	return fmt.Errorf("null team auditor")
   116  }
   117  
   118  func newNullTeamAuditor() nullTeamAuditor { return nullTeamAuditor{} }
   119  
   120  type TeamAuditParams struct {
   121  	RootFreshness time.Duration
   122  	// After this many new Merkle updates, another audit is triggered.
   123  	MerkleMovementTrigger keybase1.Seqno
   124  	NumPreProbes          int
   125  	NumPostProbes         int
   126  	Parallelism           int
   127  	LRUSize               int
   128  }
   129  
   130  type nullTeamBoxAuditor struct{}
   131  
   132  var errNullBoxAuditor = fmt.Errorf("No team box auditor configured.")
   133  
   134  func attemptNullBoxAuditor() *keybase1.BoxAuditAttempt {
   135  	msg := errNullBoxAuditor.Error()
   136  	return &keybase1.BoxAuditAttempt{Error: &msg}
   137  }
   138  
   139  var _ TeamBoxAuditor = nullTeamBoxAuditor{}
   140  
   141  func (n nullTeamBoxAuditor) AssertUnjailedOrReaudit(m MetaContext, id keybase1.TeamID) (bool, error) {
   142  	return false, errNullBoxAuditor
   143  }
   144  
   145  func (n nullTeamBoxAuditor) IsInJail(m MetaContext, id keybase1.TeamID) (bool, error) {
   146  	return false, errNullBoxAuditor
   147  }
   148  func (n nullTeamBoxAuditor) RetryNextBoxAudit(m MetaContext) (*keybase1.BoxAuditAttempt, error) {
   149  	return attemptNullBoxAuditor(), errNullBoxAuditor
   150  }
   151  func (n nullTeamBoxAuditor) BoxAuditRandomTeam(m MetaContext) (*keybase1.BoxAuditAttempt, error) {
   152  	return attemptNullBoxAuditor(), errNullBoxAuditor
   153  }
   154  func (n nullTeamBoxAuditor) BoxAuditTeam(m MetaContext, id keybase1.TeamID) (*keybase1.BoxAuditAttempt, error) {
   155  	return attemptNullBoxAuditor(), errNullBoxAuditor
   156  }
   157  func (n nullTeamBoxAuditor) Attempt(m MetaContext, id keybase1.TeamID, rotateBeforeAudit bool) keybase1.BoxAuditAttempt {
   158  	return *attemptNullBoxAuditor()
   159  }
   160  func (n nullTeamBoxAuditor) MaybeScheduleDelayedBoxAuditTeam(mctx MetaContext, teamID keybase1.TeamID) {
   161  }
   162  
   163  func newNullTeamBoxAuditor() nullTeamBoxAuditor { return nullTeamBoxAuditor{} }
   164  
   165  type nullHiddenTeamChainManager struct{}
   166  
   167  var _ HiddenTeamChainManager = nullHiddenTeamChainManager{}
   168  
   169  func (n nullHiddenTeamChainManager) Tail(mctx MetaContext, id keybase1.TeamID) (*keybase1.LinkTriple, error) {
   170  	return nil, nil
   171  }
   172  
   173  func (n nullHiddenTeamChainManager) Ratchet(MetaContext, keybase1.TeamID, keybase1.HiddenTeamChainRatchetSet) error {
   174  	return nil
   175  }
   176  func (n nullHiddenTeamChainManager) Advance(MetaContext, keybase1.HiddenTeamChain, *keybase1.LinkTriple) error {
   177  	return nil
   178  }
   179  func (n nullHiddenTeamChainManager) Load(MetaContext, keybase1.TeamID) (*keybase1.HiddenTeamChain, error) {
   180  	return nil, fmt.Errorf("null hidden team chain manager")
   181  }
   182  func (n nullHiddenTeamChainManager) Tombstone(MetaContext, keybase1.TeamID) error {
   183  	return nil
   184  }
   185  func (n nullHiddenTeamChainManager) Freeze(MetaContext, keybase1.TeamID) error {
   186  	return nil
   187  }
   188  func (n nullHiddenTeamChainManager) HintLatestSeqno(m MetaContext, id keybase1.TeamID, seqno keybase1.Seqno) error {
   189  	return nil
   190  }
   191  func (n nullHiddenTeamChainManager) Shutdown(m MetaContext) {}
   192  
   193  func (n nullHiddenTeamChainManager) TeamSupportsHiddenChain(m MetaContext, id keybase1.TeamID) (state bool, err error) {
   194  	return false, fmt.Errorf("null hidden team chain manager")
   195  }
   196  
   197  func (n nullHiddenTeamChainManager) ClearSupportFlagIfFalse(m MetaContext, id keybase1.TeamID) {}
   198  
   199  func newNullHiddenTeamChainManager() nullHiddenTeamChainManager {
   200  	return nullHiddenTeamChainManager{}
   201  }
   202  
   203  type nullTeamRoleMapManager struct{}
   204  
   205  var _ TeamRoleMapManager = nullTeamRoleMapManager{}
   206  
   207  func newNullTeamRoleMapManager() nullTeamRoleMapManager {
   208  	return nullTeamRoleMapManager{}
   209  }
   210  
   211  func (n nullTeamRoleMapManager) Get(m MetaContext, retryOnFail bool) (res keybase1.TeamRoleMapAndVersion, err error) {
   212  	return res, nil
   213  }
   214  func (n nullTeamRoleMapManager) Update(m MetaContext, version keybase1.UserTeamVersion) (err error) {
   215  	return nil
   216  }
   217  func (n nullTeamRoleMapManager) FlushCache() {}