MCPcopy
hub / github.com/syncthing/syncthing / TestCcCheckEncryption

Function TestCcCheckEncryption

lib/model/model_test.go:3841–3982  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

3839}
3840
3841func TestCcCheckEncryption(t *testing.T) {
3842 if testing.Short() {
3843 t.Skip("skipping on short testing - generating encryption tokens is slow")
3844 }
3845
3846 w, fcfg := newDefaultCfgWrapper(t)
3847 m := setupModel(t, w)
3848 m.cancel()
3849 defer cleanupModel(m)
3850
3851 pw := "foo"
3852 token := protocol.PasswordToken(m.keyGen, fcfg.ID, pw)
3853 m.folderEncryptionPasswordTokens[fcfg.ID] = token
3854
3855 testCases := []struct {
3856 tokenRemote, tokenLocal []byte
3857 isEncryptedRemote, isEncryptedLocal bool
3858 expectedErr error
3859 }{
3860 {
3861 tokenRemote: token,
3862 tokenLocal: token,
3863 expectedErr: errEncryptionInvConfigRemote,
3864 },
3865 {
3866 isEncryptedRemote: true,
3867 isEncryptedLocal: true,
3868 expectedErr: errEncryptionInvConfigLocal,
3869 },
3870 {
3871 tokenRemote: token,
3872 tokenLocal: nil,
3873 isEncryptedRemote: false,
3874 isEncryptedLocal: false,
3875 expectedErr: errEncryptionNotEncryptedLocal,
3876 },
3877 {
3878 tokenRemote: token,
3879 tokenLocal: nil,
3880 isEncryptedRemote: true,
3881 isEncryptedLocal: false,
3882 expectedErr: nil,
3883 },
3884 {
3885 tokenRemote: token,
3886 tokenLocal: nil,
3887 isEncryptedRemote: false,
3888 isEncryptedLocal: true,
3889 expectedErr: nil,
3890 },
3891 {
3892 tokenRemote: nil,
3893 tokenLocal: token,
3894 isEncryptedRemote: true,
3895 isEncryptedLocal: false,
3896 expectedErr: nil,
3897 },
3898 {

Callers

nothing calls this directly

Calls 7

PasswordTokenFunction · 0.92
newDefaultCfgWrapperFunction · 0.85
setupModelFunction · 0.85
cleanupModelFunction · 0.85
ShortMethod · 0.80
ccCheckEncryptionMethod · 0.80
CopyMethod · 0.45

Tested by

no test coverage detected