mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-10 04:36:43 +00:00
refactor: make pmapi.Client the interface
This commit is contained in:
3
Makefile
3
Makefile
@ -149,9 +149,10 @@ coverage: test
|
||||
go tool cover -html=/tmp/coverage.out -o=coverage.html
|
||||
|
||||
mocks:
|
||||
mockgen --package mocks github.com/ProtonMail/proton-bridge/internal/bridge Configer,PreferenceProvider,PanicHandler,ClientManager,PMAPIProvider,CredentialsStorer > internal/bridge/mocks/mocks.go
|
||||
mockgen --package mocks github.com/ProtonMail/proton-bridge/internal/bridge Configer,PreferenceProvider,PanicHandler,CredentialsStorer > internal/bridge/mocks/mocks.go
|
||||
mockgen --package mocks github.com/ProtonMail/proton-bridge/internal/store PanicHandler,BridgeUser > internal/store/mocks/mocks.go
|
||||
mockgen --package mocks github.com/ProtonMail/proton-bridge/pkg/listener Listener > internal/store/mocks/utils_mocks.go
|
||||
mockgen --package mocks github.com/ProtonMail/proton-bridge/pkg/pmapi Client > pkg/pmapi/mocks/mocks.go
|
||||
|
||||
lint:
|
||||
which golangci-lint || $(MAKE) install-linter
|
||||
|
||||
@ -48,7 +48,7 @@ type Bridge struct {
|
||||
panicHandler PanicHandler
|
||||
events listener.Listener
|
||||
version string
|
||||
clientManager ClientManager
|
||||
clientManager *pmapi.ClientManager
|
||||
credStorer CredentialsStorer
|
||||
storeCache *store.Cache
|
||||
|
||||
@ -76,7 +76,7 @@ func New(
|
||||
panicHandler PanicHandler,
|
||||
eventListener listener.Listener,
|
||||
version string,
|
||||
clientManager ClientManager,
|
||||
clientManager *pmapi.ClientManager,
|
||||
credStorer CredentialsStorer,
|
||||
) *Bridge {
|
||||
log.Trace("Creating new bridge")
|
||||
@ -214,7 +214,7 @@ func (b *Bridge) closeAllConnections() {
|
||||
// * In case user `auth.HasMailboxPassword()`, ask for it, otherwise use `password`
|
||||
// and then finish the login procedure.
|
||||
// user, err := bridge.FinishLogin(client, auth, mailboxPassword)
|
||||
func (b *Bridge) Login(username, password string) (authClient PMAPIProvider, auth *pmapi.Auth, err error) {
|
||||
func (b *Bridge) Login(username, password string) (authClient pmapi.Client, auth *pmapi.Auth, err error) {
|
||||
b.crashBandicoot(username)
|
||||
|
||||
// We need to use anonymous client because we don't yet have userID and so can't save auth tokens yet.
|
||||
@ -236,7 +236,7 @@ func (b *Bridge) Login(username, password string) (authClient PMAPIProvider, aut
|
||||
|
||||
// FinishLogin finishes the login procedure and adds the user into the credentials store.
|
||||
// See `Login` for more details of the login flow.
|
||||
func (b *Bridge) FinishLogin(authClient PMAPIProvider, auth *pmapi.Auth, mbPassword string) (user *User, err error) { //nolint[funlen]
|
||||
func (b *Bridge) FinishLogin(authClient pmapi.Client, auth *pmapi.Auth, mbPassword string) (user *User, err error) { //nolint[funlen]
|
||||
defer func() {
|
||||
if err == pmapi.ErrUpgradeApplication {
|
||||
b.events.Emit(events.UpgradeApplicationEvent, "")
|
||||
@ -330,7 +330,7 @@ func (b *Bridge) addNewUser(user *pmapi.User, auth *pmapi.Auth, hashedPassword s
|
||||
return
|
||||
}
|
||||
|
||||
func getAPIUser(client PMAPIProvider, auth *pmapi.Auth, mbPassword string) (user *pmapi.User, hashedPassword string, err error) {
|
||||
func getAPIUser(client pmapi.Client, auth *pmapi.Auth, mbPassword string) (user *pmapi.User, hashedPassword string, err error) {
|
||||
hashedPassword, err = pmapi.HashMailboxPassword(mbPassword, auth.KeySalt)
|
||||
if err != nil {
|
||||
log.WithError(err).Error("Could not hash mailbox password")
|
||||
|
||||
@ -30,6 +30,7 @@ import (
|
||||
"github.com/ProtonMail/proton-bridge/internal/preferences"
|
||||
"github.com/ProtonMail/proton-bridge/internal/store"
|
||||
"github.com/ProtonMail/proton-bridge/pkg/pmapi"
|
||||
pmapimocks "github.com/ProtonMail/proton-bridge/pkg/pmapi/mocks"
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/stretchr/testify/require"
|
||||
@ -128,11 +129,12 @@ type mocks struct {
|
||||
config *bridgemocks.MockConfiger
|
||||
PanicHandler *bridgemocks.MockPanicHandler
|
||||
prefProvider *bridgemocks.MockPreferenceProvider
|
||||
pmapiClient *bridgemocks.MockPMAPIProvider
|
||||
clientManager *bridgemocks.MockClientManager
|
||||
credentialsStore *bridgemocks.MockCredentialsStorer
|
||||
eventListener *MockListener
|
||||
|
||||
pmapiClient *pmapimocks.MockClient
|
||||
clientManager *pmapimocks.MockClientManager
|
||||
|
||||
storeCache *store.Cache
|
||||
}
|
||||
|
||||
@ -148,11 +150,13 @@ func initMocks(t *testing.T) mocks {
|
||||
ctrl: mockCtrl,
|
||||
config: bridgemocks.NewMockConfiger(mockCtrl),
|
||||
PanicHandler: bridgemocks.NewMockPanicHandler(mockCtrl),
|
||||
pmapiClient: bridgemocks.NewMockPMAPIProvider(mockCtrl),
|
||||
prefProvider: bridgemocks.NewMockPreferenceProvider(mockCtrl),
|
||||
credentialsStore: bridgemocks.NewMockCredentialsStorer(mockCtrl),
|
||||
eventListener: NewMockListener(mockCtrl),
|
||||
|
||||
pmapiClient: pmapimocks.NewMockClient(mockCtrl),
|
||||
clientManager: pmapimocks.NewMockClientManager(mockCtrl),
|
||||
|
||||
storeCache: store.NewCache(cacheFile.Name()),
|
||||
}
|
||||
|
||||
|
||||
@ -1,14 +1,12 @@
|
||||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: github.com/ProtonMail/proton-bridge/internal/bridge (interfaces: Configer,PreferenceProvider,PanicHandler,ClientManager,PMAPIProvider,CredentialsStorer)
|
||||
// Source: github.com/ProtonMail/proton-bridge/internal/bridge (interfaces: Configer,PreferenceProvider,PanicHandler,CredentialsStorer)
|
||||
|
||||
// Package mocks is a generated GoMock package.
|
||||
package mocks
|
||||
|
||||
import (
|
||||
io "io"
|
||||
reflect "reflect"
|
||||
|
||||
crypto "github.com/ProtonMail/gopenpgp/crypto"
|
||||
credentials "github.com/ProtonMail/proton-bridge/internal/bridge/credentials"
|
||||
pmapi "github.com/ProtonMail/proton-bridge/pkg/pmapi"
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
@ -205,661 +203,6 @@ func (mr *MockPanicHandlerMockRecorder) HandlePanic() *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HandlePanic", reflect.TypeOf((*MockPanicHandler)(nil).HandlePanic))
|
||||
}
|
||||
|
||||
// MockClientManager is a mock of ClientManager interface
|
||||
type MockClientManager struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockClientManagerMockRecorder
|
||||
}
|
||||
|
||||
// MockClientManagerMockRecorder is the mock recorder for MockClientManager
|
||||
type MockClientManagerMockRecorder struct {
|
||||
mock *MockClientManager
|
||||
}
|
||||
|
||||
// NewMockClientManager creates a new mock instance
|
||||
func NewMockClientManager(ctrl *gomock.Controller) *MockClientManager {
|
||||
mock := &MockClientManager{ctrl: ctrl}
|
||||
mock.recorder = &MockClientManagerMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use
|
||||
func (m *MockClientManager) EXPECT() *MockClientManagerMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// AllowProxy mocks base method
|
||||
func (m *MockClientManager) AllowProxy() {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "AllowProxy")
|
||||
}
|
||||
|
||||
// AllowProxy indicates an expected call of AllowProxy
|
||||
func (mr *MockClientManagerMockRecorder) AllowProxy() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AllowProxy", reflect.TypeOf((*MockClientManager)(nil).AllowProxy))
|
||||
}
|
||||
|
||||
// DisallowProxy mocks base method
|
||||
func (m *MockClientManager) DisallowProxy() {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "DisallowProxy")
|
||||
}
|
||||
|
||||
// DisallowProxy indicates an expected call of DisallowProxy
|
||||
func (mr *MockClientManagerMockRecorder) DisallowProxy() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DisallowProxy", reflect.TypeOf((*MockClientManager)(nil).DisallowProxy))
|
||||
}
|
||||
|
||||
// GetAnonymousClient mocks base method
|
||||
func (m *MockClientManager) GetAnonymousClient() *pmapi.Client {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetAnonymousClient")
|
||||
ret0, _ := ret[0].(*pmapi.Client)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// GetAnonymousClient indicates an expected call of GetAnonymousClient
|
||||
func (mr *MockClientManagerMockRecorder) GetAnonymousClient() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAnonymousClient", reflect.TypeOf((*MockClientManager)(nil).GetAnonymousClient))
|
||||
}
|
||||
|
||||
// GetBridgeAuthChannel mocks base method
|
||||
func (m *MockClientManager) GetBridgeAuthChannel() chan pmapi.ClientAuth {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetBridgeAuthChannel")
|
||||
ret0, _ := ret[0].(chan pmapi.ClientAuth)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// GetBridgeAuthChannel indicates an expected call of GetBridgeAuthChannel
|
||||
func (mr *MockClientManagerMockRecorder) GetBridgeAuthChannel() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBridgeAuthChannel", reflect.TypeOf((*MockClientManager)(nil).GetBridgeAuthChannel))
|
||||
}
|
||||
|
||||
// GetClient mocks base method
|
||||
func (m *MockClientManager) GetClient(arg0 string) *pmapi.Client {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetClient", arg0)
|
||||
ret0, _ := ret[0].(*pmapi.Client)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// GetClient indicates an expected call of GetClient
|
||||
func (mr *MockClientManagerMockRecorder) GetClient(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetClient", reflect.TypeOf((*MockClientManager)(nil).GetClient), arg0)
|
||||
}
|
||||
|
||||
// MockPMAPIProvider is a mock of PMAPIProvider interface
|
||||
type MockPMAPIProvider struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockPMAPIProviderMockRecorder
|
||||
}
|
||||
|
||||
// MockPMAPIProviderMockRecorder is the mock recorder for MockPMAPIProvider
|
||||
type MockPMAPIProviderMockRecorder struct {
|
||||
mock *MockPMAPIProvider
|
||||
}
|
||||
|
||||
// NewMockPMAPIProvider creates a new mock instance
|
||||
func NewMockPMAPIProvider(ctrl *gomock.Controller) *MockPMAPIProvider {
|
||||
mock := &MockPMAPIProvider{ctrl: ctrl}
|
||||
mock.recorder = &MockPMAPIProviderMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use
|
||||
func (m *MockPMAPIProvider) EXPECT() *MockPMAPIProviderMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// Addresses mocks base method
|
||||
func (m *MockPMAPIProvider) Addresses() pmapi.AddressList {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Addresses")
|
||||
ret0, _ := ret[0].(pmapi.AddressList)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Addresses indicates an expected call of Addresses
|
||||
func (mr *MockPMAPIProviderMockRecorder) Addresses() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Addresses", reflect.TypeOf((*MockPMAPIProvider)(nil).Addresses))
|
||||
}
|
||||
|
||||
// Auth mocks base method
|
||||
func (m *MockPMAPIProvider) Auth(arg0, arg1 string, arg2 *pmapi.AuthInfo) (*pmapi.Auth, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Auth", arg0, arg1, arg2)
|
||||
ret0, _ := ret[0].(*pmapi.Auth)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// Auth indicates an expected call of Auth
|
||||
func (mr *MockPMAPIProviderMockRecorder) Auth(arg0, arg1, arg2 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Auth", reflect.TypeOf((*MockPMAPIProvider)(nil).Auth), arg0, arg1, arg2)
|
||||
}
|
||||
|
||||
// Auth2FA mocks base method
|
||||
func (m *MockPMAPIProvider) Auth2FA(arg0 string, arg1 *pmapi.Auth) (*pmapi.Auth2FA, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Auth2FA", arg0, arg1)
|
||||
ret0, _ := ret[0].(*pmapi.Auth2FA)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// Auth2FA indicates an expected call of Auth2FA
|
||||
func (mr *MockPMAPIProviderMockRecorder) Auth2FA(arg0, arg1 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Auth2FA", reflect.TypeOf((*MockPMAPIProvider)(nil).Auth2FA), arg0, arg1)
|
||||
}
|
||||
|
||||
// AuthInfo mocks base method
|
||||
func (m *MockPMAPIProvider) AuthInfo(arg0 string) (*pmapi.AuthInfo, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "AuthInfo", arg0)
|
||||
ret0, _ := ret[0].(*pmapi.AuthInfo)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// AuthInfo indicates an expected call of AuthInfo
|
||||
func (mr *MockPMAPIProviderMockRecorder) AuthInfo(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AuthInfo", reflect.TypeOf((*MockPMAPIProvider)(nil).AuthInfo), arg0)
|
||||
}
|
||||
|
||||
// AuthRefresh mocks base method
|
||||
func (m *MockPMAPIProvider) AuthRefresh(arg0 string) (*pmapi.Auth, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "AuthRefresh", arg0)
|
||||
ret0, _ := ret[0].(*pmapi.Auth)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// AuthRefresh indicates an expected call of AuthRefresh
|
||||
func (mr *MockPMAPIProviderMockRecorder) AuthRefresh(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AuthRefresh", reflect.TypeOf((*MockPMAPIProvider)(nil).AuthRefresh), arg0)
|
||||
}
|
||||
|
||||
// CountMessages mocks base method
|
||||
func (m *MockPMAPIProvider) CountMessages(arg0 string) ([]*pmapi.MessagesCount, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "CountMessages", arg0)
|
||||
ret0, _ := ret[0].([]*pmapi.MessagesCount)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// CountMessages indicates an expected call of CountMessages
|
||||
func (mr *MockPMAPIProviderMockRecorder) CountMessages(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CountMessages", reflect.TypeOf((*MockPMAPIProvider)(nil).CountMessages), arg0)
|
||||
}
|
||||
|
||||
// CreateAttachment mocks base method
|
||||
func (m *MockPMAPIProvider) CreateAttachment(arg0 *pmapi.Attachment, arg1, arg2 io.Reader) (*pmapi.Attachment, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "CreateAttachment", arg0, arg1, arg2)
|
||||
ret0, _ := ret[0].(*pmapi.Attachment)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// CreateAttachment indicates an expected call of CreateAttachment
|
||||
func (mr *MockPMAPIProviderMockRecorder) CreateAttachment(arg0, arg1, arg2 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateAttachment", reflect.TypeOf((*MockPMAPIProvider)(nil).CreateAttachment), arg0, arg1, arg2)
|
||||
}
|
||||
|
||||
// CreateDraft mocks base method
|
||||
func (m *MockPMAPIProvider) CreateDraft(arg0 *pmapi.Message, arg1 string, arg2 int) (*pmapi.Message, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "CreateDraft", arg0, arg1, arg2)
|
||||
ret0, _ := ret[0].(*pmapi.Message)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// CreateDraft indicates an expected call of CreateDraft
|
||||
func (mr *MockPMAPIProviderMockRecorder) CreateDraft(arg0, arg1, arg2 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateDraft", reflect.TypeOf((*MockPMAPIProvider)(nil).CreateDraft), arg0, arg1, arg2)
|
||||
}
|
||||
|
||||
// CreateLabel mocks base method
|
||||
func (m *MockPMAPIProvider) CreateLabel(arg0 *pmapi.Label) (*pmapi.Label, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "CreateLabel", arg0)
|
||||
ret0, _ := ret[0].(*pmapi.Label)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// CreateLabel indicates an expected call of CreateLabel
|
||||
func (mr *MockPMAPIProviderMockRecorder) CreateLabel(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateLabel", reflect.TypeOf((*MockPMAPIProvider)(nil).CreateLabel), arg0)
|
||||
}
|
||||
|
||||
// CurrentUser mocks base method
|
||||
func (m *MockPMAPIProvider) CurrentUser() (*pmapi.User, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "CurrentUser")
|
||||
ret0, _ := ret[0].(*pmapi.User)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// CurrentUser indicates an expected call of CurrentUser
|
||||
func (mr *MockPMAPIProviderMockRecorder) CurrentUser() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CurrentUser", reflect.TypeOf((*MockPMAPIProvider)(nil).CurrentUser))
|
||||
}
|
||||
|
||||
// DecryptAndVerifyCards mocks base method
|
||||
func (m *MockPMAPIProvider) DecryptAndVerifyCards(arg0 []pmapi.Card) ([]pmapi.Card, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "DecryptAndVerifyCards", arg0)
|
||||
ret0, _ := ret[0].([]pmapi.Card)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// DecryptAndVerifyCards indicates an expected call of DecryptAndVerifyCards
|
||||
func (mr *MockPMAPIProviderMockRecorder) DecryptAndVerifyCards(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DecryptAndVerifyCards", reflect.TypeOf((*MockPMAPIProvider)(nil).DecryptAndVerifyCards), arg0)
|
||||
}
|
||||
|
||||
// DeleteLabel mocks base method
|
||||
func (m *MockPMAPIProvider) DeleteLabel(arg0 string) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "DeleteLabel", arg0)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// DeleteLabel indicates an expected call of DeleteLabel
|
||||
func (mr *MockPMAPIProviderMockRecorder) DeleteLabel(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteLabel", reflect.TypeOf((*MockPMAPIProvider)(nil).DeleteLabel), arg0)
|
||||
}
|
||||
|
||||
// DeleteMessages mocks base method
|
||||
func (m *MockPMAPIProvider) DeleteMessages(arg0 []string) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "DeleteMessages", arg0)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// DeleteMessages indicates an expected call of DeleteMessages
|
||||
func (mr *MockPMAPIProviderMockRecorder) DeleteMessages(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteMessages", reflect.TypeOf((*MockPMAPIProvider)(nil).DeleteMessages), arg0)
|
||||
}
|
||||
|
||||
// EmptyFolder mocks base method
|
||||
func (m *MockPMAPIProvider) EmptyFolder(arg0, arg1 string) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "EmptyFolder", arg0, arg1)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// EmptyFolder indicates an expected call of EmptyFolder
|
||||
func (mr *MockPMAPIProviderMockRecorder) EmptyFolder(arg0, arg1 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EmptyFolder", reflect.TypeOf((*MockPMAPIProvider)(nil).EmptyFolder), arg0, arg1)
|
||||
}
|
||||
|
||||
// GetAttachment mocks base method
|
||||
func (m *MockPMAPIProvider) GetAttachment(arg0 string) (io.ReadCloser, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetAttachment", arg0)
|
||||
ret0, _ := ret[0].(io.ReadCloser)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetAttachment indicates an expected call of GetAttachment
|
||||
func (mr *MockPMAPIProviderMockRecorder) GetAttachment(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAttachment", reflect.TypeOf((*MockPMAPIProvider)(nil).GetAttachment), arg0)
|
||||
}
|
||||
|
||||
// GetContactByID mocks base method
|
||||
func (m *MockPMAPIProvider) GetContactByID(arg0 string) (pmapi.Contact, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetContactByID", arg0)
|
||||
ret0, _ := ret[0].(pmapi.Contact)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetContactByID indicates an expected call of GetContactByID
|
||||
func (mr *MockPMAPIProviderMockRecorder) GetContactByID(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetContactByID", reflect.TypeOf((*MockPMAPIProvider)(nil).GetContactByID), arg0)
|
||||
}
|
||||
|
||||
// GetContactEmailByEmail mocks base method
|
||||
func (m *MockPMAPIProvider) GetContactEmailByEmail(arg0 string, arg1, arg2 int) ([]pmapi.ContactEmail, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetContactEmailByEmail", arg0, arg1, arg2)
|
||||
ret0, _ := ret[0].([]pmapi.ContactEmail)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetContactEmailByEmail indicates an expected call of GetContactEmailByEmail
|
||||
func (mr *MockPMAPIProviderMockRecorder) GetContactEmailByEmail(arg0, arg1, arg2 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetContactEmailByEmail", reflect.TypeOf((*MockPMAPIProvider)(nil).GetContactEmailByEmail), arg0, arg1, arg2)
|
||||
}
|
||||
|
||||
// GetEvent mocks base method
|
||||
func (m *MockPMAPIProvider) GetEvent(arg0 string) (*pmapi.Event, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetEvent", arg0)
|
||||
ret0, _ := ret[0].(*pmapi.Event)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetEvent indicates an expected call of GetEvent
|
||||
func (mr *MockPMAPIProviderMockRecorder) GetEvent(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetEvent", reflect.TypeOf((*MockPMAPIProvider)(nil).GetEvent), arg0)
|
||||
}
|
||||
|
||||
// GetMailSettings mocks base method
|
||||
func (m *MockPMAPIProvider) GetMailSettings() (pmapi.MailSettings, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetMailSettings")
|
||||
ret0, _ := ret[0].(pmapi.MailSettings)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetMailSettings indicates an expected call of GetMailSettings
|
||||
func (mr *MockPMAPIProviderMockRecorder) GetMailSettings() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetMailSettings", reflect.TypeOf((*MockPMAPIProvider)(nil).GetMailSettings))
|
||||
}
|
||||
|
||||
// GetMessage mocks base method
|
||||
func (m *MockPMAPIProvider) GetMessage(arg0 string) (*pmapi.Message, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetMessage", arg0)
|
||||
ret0, _ := ret[0].(*pmapi.Message)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetMessage indicates an expected call of GetMessage
|
||||
func (mr *MockPMAPIProviderMockRecorder) GetMessage(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetMessage", reflect.TypeOf((*MockPMAPIProvider)(nil).GetMessage), arg0)
|
||||
}
|
||||
|
||||
// GetPublicKeysForEmail mocks base method
|
||||
func (m *MockPMAPIProvider) GetPublicKeysForEmail(arg0 string) ([]pmapi.PublicKey, bool, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetPublicKeysForEmail", arg0)
|
||||
ret0, _ := ret[0].([]pmapi.PublicKey)
|
||||
ret1, _ := ret[1].(bool)
|
||||
ret2, _ := ret[2].(error)
|
||||
return ret0, ret1, ret2
|
||||
}
|
||||
|
||||
// GetPublicKeysForEmail indicates an expected call of GetPublicKeysForEmail
|
||||
func (mr *MockPMAPIProviderMockRecorder) GetPublicKeysForEmail(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPublicKeysForEmail", reflect.TypeOf((*MockPMAPIProvider)(nil).GetPublicKeysForEmail), arg0)
|
||||
}
|
||||
|
||||
// Import mocks base method
|
||||
func (m *MockPMAPIProvider) Import(arg0 []*pmapi.ImportMsgReq) ([]*pmapi.ImportMsgRes, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Import", arg0)
|
||||
ret0, _ := ret[0].([]*pmapi.ImportMsgRes)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// Import indicates an expected call of Import
|
||||
func (mr *MockPMAPIProviderMockRecorder) Import(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Import", reflect.TypeOf((*MockPMAPIProvider)(nil).Import), arg0)
|
||||
}
|
||||
|
||||
// KeyRingForAddressID mocks base method
|
||||
func (m *MockPMAPIProvider) KeyRingForAddressID(arg0 string) *crypto.KeyRing {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "KeyRingForAddressID", arg0)
|
||||
ret0, _ := ret[0].(*crypto.KeyRing)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// KeyRingForAddressID indicates an expected call of KeyRingForAddressID
|
||||
func (mr *MockPMAPIProviderMockRecorder) KeyRingForAddressID(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "KeyRingForAddressID", reflect.TypeOf((*MockPMAPIProvider)(nil).KeyRingForAddressID), arg0)
|
||||
}
|
||||
|
||||
// LabelMessages mocks base method
|
||||
func (m *MockPMAPIProvider) LabelMessages(arg0 []string, arg1 string) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "LabelMessages", arg0, arg1)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// LabelMessages indicates an expected call of LabelMessages
|
||||
func (mr *MockPMAPIProviderMockRecorder) LabelMessages(arg0, arg1 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LabelMessages", reflect.TypeOf((*MockPMAPIProvider)(nil).LabelMessages), arg0, arg1)
|
||||
}
|
||||
|
||||
// ListLabels mocks base method
|
||||
func (m *MockPMAPIProvider) ListLabels() ([]*pmapi.Label, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ListLabels")
|
||||
ret0, _ := ret[0].([]*pmapi.Label)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// ListLabels indicates an expected call of ListLabels
|
||||
func (mr *MockPMAPIProviderMockRecorder) ListLabels() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListLabels", reflect.TypeOf((*MockPMAPIProvider)(nil).ListLabels))
|
||||
}
|
||||
|
||||
// ListMessages mocks base method
|
||||
func (m *MockPMAPIProvider) ListMessages(arg0 *pmapi.MessagesFilter) ([]*pmapi.Message, int, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ListMessages", arg0)
|
||||
ret0, _ := ret[0].([]*pmapi.Message)
|
||||
ret1, _ := ret[1].(int)
|
||||
ret2, _ := ret[2].(error)
|
||||
return ret0, ret1, ret2
|
||||
}
|
||||
|
||||
// ListMessages indicates an expected call of ListMessages
|
||||
func (mr *MockPMAPIProviderMockRecorder) ListMessages(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListMessages", reflect.TypeOf((*MockPMAPIProvider)(nil).ListMessages), arg0)
|
||||
}
|
||||
|
||||
// Logout mocks base method
|
||||
func (m *MockPMAPIProvider) Logout() {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "Logout")
|
||||
}
|
||||
|
||||
// Logout indicates an expected call of Logout
|
||||
func (mr *MockPMAPIProviderMockRecorder) Logout() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Logout", reflect.TypeOf((*MockPMAPIProvider)(nil).Logout))
|
||||
}
|
||||
|
||||
// MarkMessagesRead mocks base method
|
||||
func (m *MockPMAPIProvider) MarkMessagesRead(arg0 []string) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "MarkMessagesRead", arg0)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// MarkMessagesRead indicates an expected call of MarkMessagesRead
|
||||
func (mr *MockPMAPIProviderMockRecorder) MarkMessagesRead(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MarkMessagesRead", reflect.TypeOf((*MockPMAPIProvider)(nil).MarkMessagesRead), arg0)
|
||||
}
|
||||
|
||||
// MarkMessagesUnread mocks base method
|
||||
func (m *MockPMAPIProvider) MarkMessagesUnread(arg0 []string) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "MarkMessagesUnread", arg0)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// MarkMessagesUnread indicates an expected call of MarkMessagesUnread
|
||||
func (mr *MockPMAPIProviderMockRecorder) MarkMessagesUnread(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MarkMessagesUnread", reflect.TypeOf((*MockPMAPIProvider)(nil).MarkMessagesUnread), arg0)
|
||||
}
|
||||
|
||||
// ReportBugWithEmailClient mocks base method
|
||||
func (m *MockPMAPIProvider) ReportBugWithEmailClient(arg0, arg1, arg2, arg3, arg4, arg5, arg6 string) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ReportBugWithEmailClient", arg0, arg1, arg2, arg3, arg4, arg5, arg6)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// ReportBugWithEmailClient indicates an expected call of ReportBugWithEmailClient
|
||||
func (mr *MockPMAPIProviderMockRecorder) ReportBugWithEmailClient(arg0, arg1, arg2, arg3, arg4, arg5, arg6 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReportBugWithEmailClient", reflect.TypeOf((*MockPMAPIProvider)(nil).ReportBugWithEmailClient), arg0, arg1, arg2, arg3, arg4, arg5, arg6)
|
||||
}
|
||||
|
||||
// SendMessage mocks base method
|
||||
func (m *MockPMAPIProvider) SendMessage(arg0 string, arg1 *pmapi.SendMessageReq) (*pmapi.Message, *pmapi.Message, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "SendMessage", arg0, arg1)
|
||||
ret0, _ := ret[0].(*pmapi.Message)
|
||||
ret1, _ := ret[1].(*pmapi.Message)
|
||||
ret2, _ := ret[2].(error)
|
||||
return ret0, ret1, ret2
|
||||
}
|
||||
|
||||
// SendMessage indicates an expected call of SendMessage
|
||||
func (mr *MockPMAPIProviderMockRecorder) SendMessage(arg0, arg1 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendMessage", reflect.TypeOf((*MockPMAPIProvider)(nil).SendMessage), arg0, arg1)
|
||||
}
|
||||
|
||||
// SendSimpleMetric mocks base method
|
||||
func (m *MockPMAPIProvider) SendSimpleMetric(arg0, arg1, arg2 string) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "SendSimpleMetric", arg0, arg1, arg2)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// SendSimpleMetric indicates an expected call of SendSimpleMetric
|
||||
func (mr *MockPMAPIProviderMockRecorder) SendSimpleMetric(arg0, arg1, arg2 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendSimpleMetric", reflect.TypeOf((*MockPMAPIProvider)(nil).SendSimpleMetric), arg0, arg1, arg2)
|
||||
}
|
||||
|
||||
// UnlabelMessages mocks base method
|
||||
func (m *MockPMAPIProvider) UnlabelMessages(arg0 []string, arg1 string) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "UnlabelMessages", arg0, arg1)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// UnlabelMessages indicates an expected call of UnlabelMessages
|
||||
func (mr *MockPMAPIProviderMockRecorder) UnlabelMessages(arg0, arg1 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UnlabelMessages", reflect.TypeOf((*MockPMAPIProvider)(nil).UnlabelMessages), arg0, arg1)
|
||||
}
|
||||
|
||||
// Unlock mocks base method
|
||||
func (m *MockPMAPIProvider) Unlock(arg0 string) (*crypto.KeyRing, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Unlock", arg0)
|
||||
ret0, _ := ret[0].(*crypto.KeyRing)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// Unlock indicates an expected call of Unlock
|
||||
func (mr *MockPMAPIProviderMockRecorder) Unlock(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Unlock", reflect.TypeOf((*MockPMAPIProvider)(nil).Unlock), arg0)
|
||||
}
|
||||
|
||||
// UnlockAddresses mocks base method
|
||||
func (m *MockPMAPIProvider) UnlockAddresses(arg0 []byte) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "UnlockAddresses", arg0)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// UnlockAddresses indicates an expected call of UnlockAddresses
|
||||
func (mr *MockPMAPIProviderMockRecorder) UnlockAddresses(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UnlockAddresses", reflect.TypeOf((*MockPMAPIProvider)(nil).UnlockAddresses), arg0)
|
||||
}
|
||||
|
||||
// UpdateLabel mocks base method
|
||||
func (m *MockPMAPIProvider) UpdateLabel(arg0 *pmapi.Label) (*pmapi.Label, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "UpdateLabel", arg0)
|
||||
ret0, _ := ret[0].(*pmapi.Label)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// UpdateLabel indicates an expected call of UpdateLabel
|
||||
func (mr *MockPMAPIProviderMockRecorder) UpdateLabel(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateLabel", reflect.TypeOf((*MockPMAPIProvider)(nil).UpdateLabel), arg0)
|
||||
}
|
||||
|
||||
// UpdateUser mocks base method
|
||||
func (m *MockPMAPIProvider) UpdateUser() (*pmapi.User, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "UpdateUser")
|
||||
ret0, _ := ret[0].(*pmapi.User)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// UpdateUser indicates an expected call of UpdateUser
|
||||
func (mr *MockPMAPIProviderMockRecorder) UpdateUser() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateUser", reflect.TypeOf((*MockPMAPIProvider)(nil).UpdateUser))
|
||||
}
|
||||
|
||||
// MockCredentialsStorer is a mock of CredentialsStorer interface
|
||||
type MockCredentialsStorer struct {
|
||||
ctrl *gomock.Controller
|
||||
|
||||
@ -18,11 +18,8 @@
|
||||
package bridge
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
pmcrypto "github.com/ProtonMail/gopenpgp/crypto"
|
||||
"github.com/ProtonMail/proton-bridge/internal/bridge/credentials"
|
||||
pmapi "github.com/ProtonMail/proton-bridge/pkg/pmapi" // mockgen needs this to be given an explicit import name
|
||||
"github.com/ProtonMail/proton-bridge/pkg/pmapi"
|
||||
)
|
||||
|
||||
type Configer interface {
|
||||
@ -43,62 +40,6 @@ type PanicHandler interface {
|
||||
HandlePanic()
|
||||
}
|
||||
|
||||
type ClientManager interface {
|
||||
GetClient(userID string) *pmapi.Client
|
||||
GetAnonymousClient() *pmapi.Client
|
||||
GetBridgeAuthChannel() chan pmapi.ClientAuth
|
||||
AllowProxy()
|
||||
DisallowProxy()
|
||||
}
|
||||
|
||||
type PMAPIProvider interface {
|
||||
Auth(username, password string, info *pmapi.AuthInfo) (*pmapi.Auth, error)
|
||||
AuthInfo(username string) (*pmapi.AuthInfo, error)
|
||||
AuthRefresh(token string) (*pmapi.Auth, error)
|
||||
Unlock(mailboxPassword string) (kr *pmcrypto.KeyRing, err error)
|
||||
UnlockAddresses(passphrase []byte) error
|
||||
CurrentUser() (*pmapi.User, error)
|
||||
UpdateUser() (*pmapi.User, error)
|
||||
Addresses() pmapi.AddressList
|
||||
|
||||
Logout()
|
||||
|
||||
GetEvent(eventID string) (*pmapi.Event, error)
|
||||
|
||||
CountMessages(addressID string) ([]*pmapi.MessagesCount, error)
|
||||
ListMessages(filter *pmapi.MessagesFilter) ([]*pmapi.Message, int, error)
|
||||
GetMessage(apiID string) (*pmapi.Message, error)
|
||||
Import([]*pmapi.ImportMsgReq) ([]*pmapi.ImportMsgRes, error)
|
||||
DeleteMessages(apiIDs []string) error
|
||||
LabelMessages(apiIDs []string, labelID string) error
|
||||
UnlabelMessages(apiIDs []string, labelID string) error
|
||||
MarkMessagesRead(apiIDs []string) error
|
||||
MarkMessagesUnread(apiIDs []string) error
|
||||
|
||||
ListLabels() ([]*pmapi.Label, error)
|
||||
CreateLabel(label *pmapi.Label) (*pmapi.Label, error)
|
||||
UpdateLabel(label *pmapi.Label) (*pmapi.Label, error)
|
||||
DeleteLabel(labelID string) error
|
||||
EmptyFolder(labelID string, addressID string) error
|
||||
|
||||
ReportBugWithEmailClient(os, osVersion, title, description, username, email, emailClient string) error
|
||||
SendSimpleMetric(category, action, label string) error
|
||||
|
||||
Auth2FA(twoFactorCode string, auth *pmapi.Auth) (*pmapi.Auth2FA, error)
|
||||
|
||||
GetMailSettings() (pmapi.MailSettings, error)
|
||||
GetContactEmailByEmail(string, int, int) ([]pmapi.ContactEmail, error)
|
||||
GetContactByID(string) (pmapi.Contact, error)
|
||||
DecryptAndVerifyCards([]pmapi.Card) ([]pmapi.Card, error)
|
||||
GetPublicKeysForEmail(string) ([]pmapi.PublicKey, bool, error)
|
||||
SendMessage(string, *pmapi.SendMessageReq) (sent, parent *pmapi.Message, err error)
|
||||
CreateDraft(m *pmapi.Message, parent string, action int) (created *pmapi.Message, err error)
|
||||
CreateAttachment(att *pmapi.Attachment, r io.Reader, sig io.Reader) (created *pmapi.Attachment, err error)
|
||||
KeyRingForAddressID(string) (kr *pmcrypto.KeyRing)
|
||||
|
||||
GetAttachment(id string) (att io.ReadCloser, err error)
|
||||
}
|
||||
|
||||
type CredentialsStorer interface {
|
||||
List() (userIDs []string, err error)
|
||||
Add(userID, userName, apiToken, mailboxPassword string, emails []string) (*credentials.Credentials, error)
|
||||
|
||||
@ -30,7 +30,7 @@ import (
|
||||
"github.com/ProtonMail/proton-bridge/pkg/listener"
|
||||
"github.com/ProtonMail/proton-bridge/pkg/pmapi"
|
||||
"github.com/pkg/errors"
|
||||
logrus "github.com/sirupsen/logrus"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// ErrLoggedOutUser is sent to IMAP and SMTP if user exists, password is OK but user is logged out from bridge.
|
||||
@ -38,11 +38,11 @@ var ErrLoggedOutUser = errors.New("bridge account is logged out, use bridge to l
|
||||
|
||||
// User is a struct on top of API client and credentials store.
|
||||
type User struct {
|
||||
log *logrus.Entry
|
||||
panicHandler PanicHandler
|
||||
listener listener.Listener
|
||||
clientMan ClientManager
|
||||
credStorer CredentialsStorer
|
||||
log *logrus.Entry
|
||||
panicHandler PanicHandler
|
||||
listener listener.Listener
|
||||
clientManager *pmapi.ClientManager
|
||||
credStorer CredentialsStorer
|
||||
|
||||
imapUpdatesChannel chan interface{}
|
||||
|
||||
@ -66,7 +66,7 @@ func newUser(
|
||||
userID string,
|
||||
eventListener listener.Listener,
|
||||
credStorer CredentialsStorer,
|
||||
clientMan ClientManager,
|
||||
clientManager *pmapi.ClientManager,
|
||||
storeCache *store.Cache,
|
||||
storeDir string,
|
||||
) (u *User, err error) {
|
||||
@ -79,22 +79,22 @@ func newUser(
|
||||
}
|
||||
|
||||
u = &User{
|
||||
log: log,
|
||||
panicHandler: panicHandler,
|
||||
listener: eventListener,
|
||||
credStorer: credStorer,
|
||||
clientMan: clientMan,
|
||||
storeCache: storeCache,
|
||||
storePath: getUserStorePath(storeDir, userID),
|
||||
userID: userID,
|
||||
creds: creds,
|
||||
log: log,
|
||||
panicHandler: panicHandler,
|
||||
listener: eventListener,
|
||||
credStorer: credStorer,
|
||||
clientManager: clientManager,
|
||||
storeCache: storeCache,
|
||||
storePath: getUserStorePath(storeDir, userID),
|
||||
userID: userID,
|
||||
creds: creds,
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (u *User) client() PMAPIProvider {
|
||||
return u.clientMan.GetClient(u.userID)
|
||||
func (u *User) client() pmapi.Client {
|
||||
return u.clientManager.GetClient(u.userID)
|
||||
}
|
||||
|
||||
// init initialises a bridge user. This includes reloading its credentials from the credentials store
|
||||
@ -295,7 +295,7 @@ func getUserStorePath(storeDir string, userID string) (path string) {
|
||||
// GetTemporaryPMAPIClient returns an authorised PMAPI client.
|
||||
// Do not use! It's only for backward compatibility of old SMTP and IMAP implementations.
|
||||
// After proper refactor of SMTP and IMAP remove this method.
|
||||
func (u *User) GetTemporaryPMAPIClient() PMAPIProvider {
|
||||
func (u *User) GetTemporaryPMAPIClient() pmapi.Client {
|
||||
return u.client()
|
||||
}
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@ package types
|
||||
|
||||
import (
|
||||
"github.com/ProtonMail/proton-bridge/internal/bridge"
|
||||
pmapi "github.com/ProtonMail/proton-bridge/pkg/pmapi"
|
||||
"github.com/ProtonMail/proton-bridge/pkg/pmapi"
|
||||
"github.com/ProtonMail/proton-bridge/pkg/updates"
|
||||
)
|
||||
|
||||
@ -45,8 +45,8 @@ type NoEncConfirmator interface {
|
||||
type Bridger interface {
|
||||
GetCurrentClient() string
|
||||
SetCurrentOS(os string)
|
||||
Login(username, password string) (bridge.PMAPIProvider, *pmapi.Auth, error)
|
||||
FinishLogin(client bridge.PMAPIProvider, auth *pmapi.Auth, mailboxPassword string) (BridgeUser, error)
|
||||
Login(username, password string) (pmapi.Client, *pmapi.Auth, error)
|
||||
FinishLogin(client pmapi.Client, auth *pmapi.Auth, mailboxPassword string) (BridgeUser, error)
|
||||
GetUsers() []BridgeUser
|
||||
GetUser(query string) (BridgeUser, error)
|
||||
DeleteUser(userID string, clearCache bool) error
|
||||
@ -80,7 +80,7 @@ func NewBridgeWrap(bridge *bridge.Bridge) *bridgeWrap { //nolint[golint]
|
||||
return &bridgeWrap{Bridge: bridge}
|
||||
}
|
||||
|
||||
func (b *bridgeWrap) FinishLogin(client bridge.PMAPIProvider, auth *pmapi.Auth, mailboxPassword string) (BridgeUser, error) {
|
||||
func (b *bridgeWrap) FinishLogin(client pmapi.Client, auth *pmapi.Auth, mailboxPassword string) (BridgeUser, error) {
|
||||
return b.Bridge.FinishLogin(client, auth, mailboxPassword)
|
||||
}
|
||||
|
||||
|
||||
@ -19,6 +19,7 @@ package imap
|
||||
|
||||
import (
|
||||
"github.com/ProtonMail/proton-bridge/internal/bridge"
|
||||
"github.com/ProtonMail/proton-bridge/pkg/pmapi"
|
||||
)
|
||||
|
||||
type configProvider interface {
|
||||
@ -43,7 +44,7 @@ type bridgeUser interface {
|
||||
Logout() error
|
||||
CloseConnection(address string)
|
||||
GetStore() storeUserProvider
|
||||
GetTemporaryPMAPIClient() bridge.PMAPIProvider
|
||||
GetTemporaryPMAPIClient() pmapi.Client
|
||||
}
|
||||
|
||||
type bridgeWrap struct {
|
||||
|
||||
@ -21,7 +21,7 @@ import (
|
||||
"errors"
|
||||
"strings"
|
||||
|
||||
"github.com/ProtonMail/proton-bridge/internal/bridge"
|
||||
"github.com/ProtonMail/proton-bridge/pkg/pmapi"
|
||||
imapquota "github.com/emersion/go-imap-quota"
|
||||
goIMAPBackend "github.com/emersion/go-imap/backend"
|
||||
)
|
||||
@ -34,7 +34,7 @@ type imapUser struct {
|
||||
panicHandler panicHandler
|
||||
backend *imapBackend
|
||||
user bridgeUser
|
||||
client bridge.PMAPIProvider
|
||||
client pmapi.Client
|
||||
|
||||
storeUser storeUserProvider
|
||||
storeAddress storeAddressProvider
|
||||
|
||||
@ -19,6 +19,7 @@ package smtp
|
||||
|
||||
import (
|
||||
"github.com/ProtonMail/proton-bridge/internal/bridge"
|
||||
"github.com/ProtonMail/proton-bridge/pkg/pmapi"
|
||||
)
|
||||
|
||||
type bridger interface {
|
||||
@ -29,7 +30,7 @@ type bridgeUser interface {
|
||||
CheckBridgeLogin(password string) error
|
||||
IsCombinedAddressMode() bool
|
||||
GetAddressID(address string) (string, error)
|
||||
GetTemporaryPMAPIClient() bridge.PMAPIProvider
|
||||
GetTemporaryPMAPIClient() pmapi.Client
|
||||
GetStore() storeUserProvider
|
||||
}
|
||||
|
||||
|
||||
@ -33,7 +33,6 @@ import (
|
||||
"time"
|
||||
|
||||
pmcrypto "github.com/ProtonMail/gopenpgp/crypto"
|
||||
"github.com/ProtonMail/proton-bridge/internal/bridge"
|
||||
"github.com/ProtonMail/proton-bridge/internal/events"
|
||||
"github.com/ProtonMail/proton-bridge/pkg/listener"
|
||||
"github.com/ProtonMail/proton-bridge/pkg/message"
|
||||
@ -47,7 +46,7 @@ type smtpUser struct {
|
||||
eventListener listener.Listener
|
||||
backend *smtpBackend
|
||||
user bridgeUser
|
||||
client bridge.PMAPIProvider
|
||||
client pmapi.Client
|
||||
storeUser storeUserProvider
|
||||
addressID string
|
||||
}
|
||||
|
||||
@ -160,7 +160,7 @@ func ConstructAddress(headerEmail string, addressEmail string) string {
|
||||
}
|
||||
|
||||
// GetAddresses requests all of current user addresses (without pagination).
|
||||
func (c *Client) GetAddresses() (addresses AddressList, err error) {
|
||||
func (c *client) GetAddresses() (addresses AddressList, err error) {
|
||||
req, err := c.NewRequest("GET", "/addresses", nil)
|
||||
if err != nil {
|
||||
return
|
||||
@ -174,12 +174,12 @@ func (c *Client) GetAddresses() (addresses AddressList, err error) {
|
||||
return res.Addresses, res.Err()
|
||||
}
|
||||
|
||||
func (c *Client) Addresses() AddressList {
|
||||
func (c *client) Addresses() AddressList {
|
||||
return c.addresses
|
||||
}
|
||||
|
||||
// UnlockAddresses unlocks all keys for all addresses of current user.
|
||||
func (c *Client) UnlockAddresses(passphrase []byte) (err error) {
|
||||
func (c *client) UnlockAddresses(passphrase []byte) (err error) {
|
||||
for _, a := range c.addresses {
|
||||
if a.HasKeys == MissingKeys {
|
||||
continue
|
||||
@ -195,7 +195,7 @@ func (c *Client) UnlockAddresses(passphrase []byte) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (c *Client) KeyRingForAddressID(addrID string) *pmcrypto.KeyRing {
|
||||
func (c *client) KeyRingForAddressID(addrID string) *pmcrypto.KeyRing {
|
||||
addr := c.addresses.ByID(addrID)
|
||||
if addr == nil {
|
||||
addr = c.addresses.Main()
|
||||
|
||||
@ -178,7 +178,7 @@ func writeAttachment(w *multipart.Writer, att *Attachment, r io.Reader, sig io.R
|
||||
// CreateAttachment uploads an attachment. It must be already encrypted and contain a MessageID.
|
||||
//
|
||||
// The returned created attachment contains the new attachment ID and its size.
|
||||
func (c *Client) CreateAttachment(att *Attachment, r io.Reader, sig io.Reader) (created *Attachment, err error) {
|
||||
func (c *client) CreateAttachment(att *Attachment, r io.Reader, sig io.Reader) (created *Attachment, err error) {
|
||||
req, w, err := c.NewMultipartRequest("POST", "/attachments")
|
||||
if err != nil {
|
||||
return
|
||||
@ -211,7 +211,7 @@ type UpdateAttachmentSignatureReq struct {
|
||||
Signature string
|
||||
}
|
||||
|
||||
func (c *Client) UpdateAttachmentSignature(attachmentID, signature string) (err error) {
|
||||
func (c *client) UpdateAttachmentSignature(attachmentID, signature string) (err error) {
|
||||
updateReq := &UpdateAttachmentSignatureReq{signature}
|
||||
req, err := c.NewJSONRequest("PUT", "/attachments/"+attachmentID+"/signature", updateReq)
|
||||
if err != nil {
|
||||
@ -227,7 +227,7 @@ func (c *Client) UpdateAttachmentSignature(attachmentID, signature string) (err
|
||||
}
|
||||
|
||||
// DeleteAttachment removes an attachment. message is the message ID, att is the attachment ID.
|
||||
func (c *Client) DeleteAttachment(attID string) (err error) {
|
||||
func (c *client) DeleteAttachment(attID string) (err error) {
|
||||
req, err := c.NewRequest("DELETE", "/attachments/"+attID, nil)
|
||||
if err != nil {
|
||||
return
|
||||
@ -243,7 +243,7 @@ func (c *Client) DeleteAttachment(attID string) (err error) {
|
||||
}
|
||||
|
||||
// GetAttachment gets an attachment's content. The returned data is encrypted.
|
||||
func (c *Client) GetAttachment(id string) (att io.ReadCloser, err error) {
|
||||
func (c *client) GetAttachment(id string) (att io.ReadCloser, err error) {
|
||||
if id == "" {
|
||||
err = errors.New("pmapi: cannot get an attachment with an empty id")
|
||||
return
|
||||
|
||||
@ -204,7 +204,7 @@ type AuthRefreshReq struct {
|
||||
State string
|
||||
}
|
||||
|
||||
func (c *Client) sendAuth(auth *Auth) {
|
||||
func (c *client) sendAuth(auth *Auth) {
|
||||
c.log.Debug("Client is sending auth to ClientManager")
|
||||
|
||||
if auth != nil {
|
||||
@ -224,7 +224,7 @@ func (c *Client) sendAuth(auth *Auth) {
|
||||
}
|
||||
|
||||
// AuthInfo gets authentication info for a user.
|
||||
func (c *Client) AuthInfo(username string) (info *AuthInfo, err error) {
|
||||
func (c *client) AuthInfo(username string) (info *AuthInfo, err error) {
|
||||
infoReq := &AuthInfoReq{
|
||||
Username: username,
|
||||
}
|
||||
@ -259,7 +259,7 @@ func srpProofsFromInfo(info *AuthInfo, username, password string, fallbackVersio
|
||||
return
|
||||
}
|
||||
|
||||
func (c *Client) tryAuth(username, password string, info *AuthInfo, fallbackVersion int) (res *AuthRes, err error) {
|
||||
func (c *client) tryAuth(username, password string, info *AuthInfo, fallbackVersion int) (res *AuthRes, err error) {
|
||||
proofs, err := srpProofsFromInfo(info, username, password, fallbackVersion)
|
||||
if err != nil {
|
||||
return
|
||||
@ -299,7 +299,7 @@ func (c *Client) tryAuth(username, password string, info *AuthInfo, fallbackVers
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (c *Client) tryFullAuth(username, password string, fallbackVersion int) (info *AuthInfo, authRes *AuthRes, err error) {
|
||||
func (c *client) tryFullAuth(username, password string, fallbackVersion int) (info *AuthInfo, authRes *AuthRes, err error) {
|
||||
info, err = c.AuthInfo(username)
|
||||
if err != nil {
|
||||
return
|
||||
@ -309,7 +309,7 @@ func (c *Client) tryFullAuth(username, password string, fallbackVersion int) (in
|
||||
}
|
||||
|
||||
// Auth will authenticate a user.
|
||||
func (c *Client) Auth(username, password string, info *AuthInfo) (auth *Auth, err error) {
|
||||
func (c *client) Auth(username, password string, info *AuthInfo) (auth *Auth, err error) {
|
||||
if info == nil {
|
||||
if info, err = c.AuthInfo(username); err != nil {
|
||||
return
|
||||
@ -344,7 +344,7 @@ func (c *Client) Auth(username, password string, info *AuthInfo) (auth *Auth, er
|
||||
|
||||
// Auth2FA will authenticate a user into full scope.
|
||||
// `Auth` struct contains method `HasTwoFactor` deciding whether this has to be done.
|
||||
func (c *Client) Auth2FA(twoFactorCode string, auth *Auth) (*Auth2FA, error) {
|
||||
func (c *client) Auth2FA(twoFactorCode string, auth *Auth) (*Auth2FA, error) {
|
||||
auth2FAReq := &Auth2FAReq{
|
||||
TwoFactorCode: twoFactorCode,
|
||||
}
|
||||
@ -377,7 +377,7 @@ func (c *Client) Auth2FA(twoFactorCode string, auth *Auth) (*Auth2FA, error) {
|
||||
return auth2FARes.getAuth2FA(), nil
|
||||
}
|
||||
|
||||
func (c *Client) setKeySaltToAuth(auth *Auth) error {
|
||||
func (c *client) setKeySaltToAuth(auth *Auth) error {
|
||||
// KeySalt already set up, no need to do it again.
|
||||
if auth.KeySalt != "" {
|
||||
return nil
|
||||
@ -402,7 +402,7 @@ func (c *Client) setKeySaltToAuth(auth *Auth) error {
|
||||
|
||||
// Unlock decrypts the key ring.
|
||||
// If the password is invalid, IsUnlockError(err) will return true.
|
||||
func (c *Client) Unlock(password string) (kr *pmcrypto.KeyRing, err error) {
|
||||
func (c *client) Unlock(password string) (kr *pmcrypto.KeyRing, err error) {
|
||||
if _, err = c.CurrentUser(); err != nil {
|
||||
return
|
||||
}
|
||||
@ -420,7 +420,7 @@ func (c *Client) Unlock(password string) (kr *pmcrypto.KeyRing, err error) {
|
||||
}
|
||||
|
||||
// AuthRefresh will refresh an expired access token.
|
||||
func (c *Client) AuthRefresh(uidAndRefreshToken string) (auth *Auth, err error) {
|
||||
func (c *client) AuthRefresh(uidAndRefreshToken string) (auth *Auth, err error) {
|
||||
// If we don't yet have a saved access token, save this one in case the refresh fails!
|
||||
// That way we can try again later (see handleUnauthorizedStatus).
|
||||
// TODO:
|
||||
@ -465,14 +465,14 @@ func (c *Client) AuthRefresh(uidAndRefreshToken string) (auth *Auth, err error)
|
||||
}
|
||||
|
||||
// Logout instructs the client manager to log out this client.
|
||||
func (c *Client) Logout() {
|
||||
func (c *client) Logout() {
|
||||
c.cm.LogoutClient(c.userID)
|
||||
}
|
||||
|
||||
// TODO: Need a method like IsConnected() to be able to detect whether a client is logged in or not.
|
||||
|
||||
// logout logs the current user out.
|
||||
func (c *Client) logout() (err error) {
|
||||
func (c *client) logout() (err error) {
|
||||
req, err := c.NewRequest("DELETE", "/auth", nil)
|
||||
if err != nil {
|
||||
return
|
||||
@ -490,7 +490,7 @@ func (c *Client) logout() (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (c *Client) clearSensitiveData() {
|
||||
func (c *client) clearSensitiveData() {
|
||||
c.uid = ""
|
||||
c.accessToken = ""
|
||||
c.kr = nil
|
||||
|
||||
@ -131,7 +131,7 @@ func writeMultipartReport(w *multipart.Writer, rep *ReportReq) error { // nolint
|
||||
}
|
||||
|
||||
// Report sends request as json or multipart (if has attachment).
|
||||
func (c *Client) Report(rep ReportReq) (err error) {
|
||||
func (c *client) Report(rep ReportReq) (err error) {
|
||||
rep.Client = c.cm.GetConfig().ClientID
|
||||
rep.ClientVersion = c.cm.GetConfig().AppVersion
|
||||
rep.ClientType = EmailClientType
|
||||
@ -174,12 +174,12 @@ func (c *Client) Report(rep ReportReq) (err error) {
|
||||
}
|
||||
|
||||
// ReportBug is old. Use Report instead.
|
||||
func (c *Client) ReportBug(os, osVersion, title, description, username, email string) (err error) {
|
||||
func (c *client) ReportBug(os, osVersion, title, description, username, email string) (err error) {
|
||||
return c.ReportBugWithEmailClient(os, osVersion, title, description, username, email, "")
|
||||
}
|
||||
|
||||
// ReportBugWithEmailClient is old. Use Report instead.
|
||||
func (c *Client) ReportBugWithEmailClient(os, osVersion, title, description, username, email, emailClient string) (err error) {
|
||||
func (c *client) ReportBugWithEmailClient(os, osVersion, title, description, username, email, emailClient string) (err error) {
|
||||
bugReq := ReportReq{
|
||||
OS: os,
|
||||
OSVersion: osVersion,
|
||||
@ -194,7 +194,7 @@ func (c *Client) ReportBugWithEmailClient(os, osVersion, title, description, use
|
||||
}
|
||||
|
||||
// ReportCrash is old. Use sentry instead.
|
||||
func (c *Client) ReportCrash(stacktrace string) (err error) {
|
||||
func (c *client) ReportCrash(stacktrace string) (err error) {
|
||||
crashReq := ReportReq{
|
||||
Client: c.cm.GetConfig().ClientID,
|
||||
ClientVersion: c.cm.GetConfig().AppVersion,
|
||||
|
||||
@ -93,8 +93,59 @@ type ClientConfig struct {
|
||||
MinSpeed int64
|
||||
}
|
||||
|
||||
// Client to communicate with API.
|
||||
type Client struct {
|
||||
// Client defines the interface of a PMAPI client.
|
||||
type Client interface {
|
||||
Auth(username, password string, info *AuthInfo) (*Auth, error)
|
||||
AuthInfo(username string) (*AuthInfo, error)
|
||||
AuthRefresh(token string) (*Auth, error)
|
||||
Unlock(mailboxPassword string) (kr *pmcrypto.KeyRing, err error)
|
||||
UnlockAddresses(passphrase []byte) error
|
||||
CurrentUser() (*User, error)
|
||||
UpdateUser() (*User, error)
|
||||
Addresses() AddressList
|
||||
|
||||
Logout()
|
||||
|
||||
GetEvent(eventID string) (*Event, error)
|
||||
|
||||
CountMessages(addressID string) ([]*MessagesCount, error)
|
||||
ListMessages(filter *MessagesFilter) ([]*Message, int, error)
|
||||
GetMessage(apiID string) (*Message, error)
|
||||
Import([]*ImportMsgReq) ([]*ImportMsgRes, error)
|
||||
DeleteMessages(apiIDs []string) error
|
||||
LabelMessages(apiIDs []string, labelID string) error
|
||||
UnlabelMessages(apiIDs []string, labelID string) error
|
||||
MarkMessagesRead(apiIDs []string) error
|
||||
MarkMessagesUnread(apiIDs []string) error
|
||||
|
||||
ListLabels() ([]*Label, error)
|
||||
CreateLabel(label *Label) (*Label, error)
|
||||
UpdateLabel(label *Label) (*Label, error)
|
||||
DeleteLabel(labelID string) error
|
||||
EmptyFolder(labelID string, addressID string) error
|
||||
|
||||
ReportBugWithEmailClient(os, osVersion, title, description, username, email, emailClient string) error
|
||||
SendSimpleMetric(category, action, label string) error
|
||||
ReportSentryCrash(reportErr error) (err error)
|
||||
|
||||
Auth2FA(twoFactorCode string, auth *Auth) (*Auth2FA, error)
|
||||
|
||||
GetMailSettings() (MailSettings, error)
|
||||
GetContactEmailByEmail(string, int, int) ([]ContactEmail, error)
|
||||
GetContactByID(string) (Contact, error)
|
||||
DecryptAndVerifyCards([]Card) ([]Card, error)
|
||||
GetPublicKeysForEmail(string) ([]PublicKey, bool, error)
|
||||
SendMessage(string, *SendMessageReq) (sent, parent *Message, err error)
|
||||
CreateDraft(m *Message, parent string, action int) (created *Message, err error)
|
||||
CreateAttachment(att *Attachment, r io.Reader, sig io.Reader) (created *Attachment, err error)
|
||||
DeleteAttachment(attID string) (err error)
|
||||
KeyRingForAddressID(string) (kr *pmcrypto.KeyRing)
|
||||
|
||||
GetAttachment(id string) (att io.ReadCloser, err error)
|
||||
}
|
||||
|
||||
// client is a client of the protonmail API. It implements the Client interface.
|
||||
type client struct {
|
||||
cm *ClientManager
|
||||
hc *http.Client
|
||||
|
||||
@ -112,8 +163,8 @@ type Client struct {
|
||||
}
|
||||
|
||||
// newClient creates a new API client.
|
||||
func newClient(cm *ClientManager, userID string) *Client {
|
||||
return &Client{
|
||||
func newClient(cm *ClientManager, userID string) *client {
|
||||
return &client{
|
||||
cm: cm,
|
||||
hc: getHTTPClient(cm.GetConfig(), cm.GetRoundTripper()),
|
||||
userID: userID,
|
||||
@ -132,7 +183,7 @@ func getHTTPClient(cfg *ClientConfig, rt http.RoundTripper) (hc *http.Client) {
|
||||
}
|
||||
|
||||
// Do makes an API request. It does not check for HTTP status code errors.
|
||||
func (c *Client) Do(req *http.Request, retryUnauthorized bool) (res *http.Response, err error) {
|
||||
func (c *client) Do(req *http.Request, retryUnauthorized bool) (res *http.Response, err error) {
|
||||
// Copy the request body in case we need to retry it.
|
||||
var bodyBuffer []byte
|
||||
if req.Body != nil {
|
||||
@ -151,7 +202,7 @@ func (c *Client) Do(req *http.Request, retryUnauthorized bool) (res *http.Respon
|
||||
}
|
||||
|
||||
// If needed it retries using req and buffered body.
|
||||
func (c *Client) doBuffered(req *http.Request, bodyBuffer []byte, retryUnauthorized bool) (res *http.Response, err error) { // nolint[funlen]
|
||||
func (c *client) doBuffered(req *http.Request, bodyBuffer []byte, retryUnauthorized bool) (res *http.Response, err error) { // nolint[funlen]
|
||||
isAuthReq := strings.Contains(req.URL.Path, "/auth")
|
||||
|
||||
req.Header.Set("x-pm-appversion", c.cm.GetConfig().AppVersion)
|
||||
@ -235,7 +286,7 @@ func (c *Client) doBuffered(req *http.Request, bodyBuffer []byte, retryUnauthori
|
||||
// If the API returns a non-2xx HTTP status code, the error returned will contain status
|
||||
// and response as plaintext. API errors must be checked by the caller.
|
||||
// It is performed buffered, in case we need to retry.
|
||||
func (c *Client) DoJSON(req *http.Request, data interface{}) error {
|
||||
func (c *client) DoJSON(req *http.Request, data interface{}) error {
|
||||
// Copy the request body in case we need to retry it
|
||||
var reqBodyBuffer []byte
|
||||
|
||||
@ -253,7 +304,7 @@ func (c *Client) DoJSON(req *http.Request, data interface{}) error {
|
||||
}
|
||||
|
||||
// doJSONBuffered performs a buffered json request (see DoJSON for more information).
|
||||
func (c *Client) doJSONBuffered(req *http.Request, reqBodyBuffer []byte, data interface{}) error { // nolint[funlen]
|
||||
func (c *client) doJSONBuffered(req *http.Request, reqBodyBuffer []byte, data interface{}) error { // nolint[funlen]
|
||||
req.Header.Set("Accept", "application/vnd.protonmail.v1+json")
|
||||
|
||||
var cancelRequest context.CancelFunc
|
||||
@ -350,7 +401,7 @@ func (c *Client) doJSONBuffered(req *http.Request, reqBodyBuffer []byte, data in
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Client) readAllMinSpeed(data io.Reader, cancelRequest context.CancelFunc) ([]byte, error) {
|
||||
func (c *client) readAllMinSpeed(data io.Reader, cancelRequest context.CancelFunc) ([]byte, error) {
|
||||
firstReadTimeout := c.cm.GetConfig().FirstReadTimeout
|
||||
if firstReadTimeout == 0 {
|
||||
firstReadTimeout = 5 * time.Minute
|
||||
@ -372,7 +423,7 @@ func (c *Client) readAllMinSpeed(data io.Reader, cancelRequest context.CancelFun
|
||||
return ioutil.ReadAll(&buffer)
|
||||
}
|
||||
|
||||
func (c *Client) refreshAccessToken() (err error) {
|
||||
func (c *client) refreshAccessToken() (err error) {
|
||||
c.log.Debug("Refreshing token")
|
||||
|
||||
refreshToken := c.cm.GetToken(c.userID)
|
||||
@ -390,7 +441,7 @@ func (c *Client) refreshAccessToken() (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (c *Client) handleStatusUnauthorized(req *http.Request, reqBodyBuffer []byte, res *http.Response, retry bool) (retryRes *http.Response, err error) {
|
||||
func (c *client) handleStatusUnauthorized(req *http.Request, reqBodyBuffer []byte, res *http.Response, retry bool) (retryRes *http.Response, err error) {
|
||||
c.log.Info("Handling unauthorized status")
|
||||
|
||||
// If this is not a retry, then it is the first time handling status unauthorized,
|
||||
|
||||
@ -36,8 +36,8 @@ var testClientConfig = &ClientConfig{
|
||||
MinSpeed: 256,
|
||||
}
|
||||
|
||||
func newTestClient(cm *ClientManager) *Client {
|
||||
return cm.GetClient("tester")
|
||||
func newTestClient(cm *ClientManager) *client {
|
||||
return cm.GetClient("tester").(*client)
|
||||
}
|
||||
|
||||
func TestClient_Do(t *testing.T) {
|
||||
|
||||
@ -18,7 +18,7 @@ type ClientManager struct {
|
||||
config *ClientConfig
|
||||
roundTripper http.RoundTripper
|
||||
|
||||
clients map[string]*Client
|
||||
clients map[string]*client
|
||||
clientsLocker sync.Locker
|
||||
|
||||
tokens map[string]string
|
||||
@ -58,7 +58,7 @@ func NewClientManager(config *ClientConfig) (cm *ClientManager) {
|
||||
config: config,
|
||||
roundTripper: http.DefaultTransport,
|
||||
|
||||
clients: make(map[string]*Client),
|
||||
clients: make(map[string]*client),
|
||||
clientsLocker: &sync.Mutex{},
|
||||
|
||||
tokens: make(map[string]string),
|
||||
@ -95,7 +95,7 @@ func (cm *ClientManager) GetRoundTripper() (rt http.RoundTripper) {
|
||||
|
||||
// GetClient returns a client for the given userID.
|
||||
// If the client does not exist already, it is created.
|
||||
func (cm *ClientManager) GetClient(userID string) *Client {
|
||||
func (cm *ClientManager) GetClient(userID string) Client {
|
||||
if client, ok := cm.clients[userID]; ok {
|
||||
return client
|
||||
}
|
||||
@ -106,7 +106,7 @@ func (cm *ClientManager) GetClient(userID string) *Client {
|
||||
}
|
||||
|
||||
// GetAnonymousClient returns an anonymous client. It replaces any anonymous client that was already created.
|
||||
func (cm *ClientManager) GetAnonymousClient() *Client {
|
||||
func (cm *ClientManager) GetAnonymousClient() Client {
|
||||
if client, ok := cm.clients[""]; ok {
|
||||
client.Logout()
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ var errVerificationFailed = errors.New("signature verification failed")
|
||||
|
||||
//================= Public utility functions ======================
|
||||
|
||||
func (c *Client) EncryptAndSignCards(cards []Card) ([]Card, error) {
|
||||
func (c *client) EncryptAndSignCards(cards []Card) ([]Card, error) {
|
||||
var err error
|
||||
for i := range cards {
|
||||
card := &cards[i]
|
||||
@ -85,7 +85,7 @@ func (c *Client) EncryptAndSignCards(cards []Card) ([]Card, error) {
|
||||
return cards, nil
|
||||
}
|
||||
|
||||
func (c *Client) DecryptAndVerifyCards(cards []Card) ([]Card, error) {
|
||||
func (c *client) DecryptAndVerifyCards(cards []Card) ([]Card, error) {
|
||||
for i := range cards {
|
||||
card := &cards[i]
|
||||
if isEncryptedCardType(card.Type) {
|
||||
@ -113,7 +113,7 @@ type ContactsListRes struct {
|
||||
}
|
||||
|
||||
// GetContacts gets all contacts.
|
||||
func (c *Client) GetContacts(page int, pageSize int) (contacts []*Contact, err error) {
|
||||
func (c *client) GetContacts(page int, pageSize int) (contacts []*Contact, err error) {
|
||||
v := url.Values{}
|
||||
v.Set("Page", strconv.Itoa(page))
|
||||
if pageSize > 0 {
|
||||
@ -135,7 +135,7 @@ func (c *Client) GetContacts(page int, pageSize int) (contacts []*Contact, err e
|
||||
}
|
||||
|
||||
// GetContactByID gets contact details specified by contact ID.
|
||||
func (c *Client) GetContactByID(id string) (contactDetail Contact, err error) {
|
||||
func (c *client) GetContactByID(id string) (contactDetail Contact, err error) {
|
||||
req, err := c.NewRequest("GET", "/contacts/"+id, nil)
|
||||
|
||||
if err != nil {
|
||||
@ -157,7 +157,7 @@ func (c *Client) GetContactByID(id string) (contactDetail Contact, err error) {
|
||||
}
|
||||
|
||||
// GetContactsForExport gets contacts in vCard format, signed and encrypted.
|
||||
func (c *Client) GetContactsForExport(page int, pageSize int) (contacts []Contact, err error) {
|
||||
func (c *client) GetContactsForExport(page int, pageSize int) (contacts []Contact, err error) {
|
||||
v := url.Values{}
|
||||
v.Set("Page", strconv.Itoa(page))
|
||||
if pageSize > 0 {
|
||||
@ -191,7 +191,7 @@ type ContactsEmailsRes struct {
|
||||
}
|
||||
|
||||
// GetAllContactsEmails gets all emails from all contacts.
|
||||
func (c *Client) GetAllContactsEmails(page int, pageSize int) (contactsEmails []ContactEmail, err error) {
|
||||
func (c *client) GetAllContactsEmails(page int, pageSize int) (contactsEmails []ContactEmail, err error) {
|
||||
v := url.Values{}
|
||||
v.Set("Page", strconv.Itoa(page))
|
||||
if pageSize > 0 {
|
||||
@ -213,7 +213,7 @@ func (c *Client) GetAllContactsEmails(page int, pageSize int) (contactsEmails []
|
||||
}
|
||||
|
||||
// GetContactEmailByEmail gets all emails from all contacts matching a specified email string.
|
||||
func (c *Client) GetContactEmailByEmail(email string, page int, pageSize int) (contactEmails []ContactEmail, err error) {
|
||||
func (c *client) GetContactEmailByEmail(email string, page int, pageSize int) (contactEmails []ContactEmail, err error) {
|
||||
v := url.Values{}
|
||||
v.Set("Page", strconv.Itoa(page))
|
||||
if pageSize > 0 {
|
||||
@ -268,7 +268,7 @@ type AddContactsReq struct {
|
||||
}
|
||||
|
||||
// AddContacts adds contacts specified by cards. Performs signing and encrypting based on card type.
|
||||
func (c *Client) AddContacts(cards ContactsCards, overwrite int, groups int, labels int) (res *AddContactsResponse, err error) {
|
||||
func (c *client) AddContacts(cards ContactsCards, overwrite int, groups int, labels int) (res *AddContactsResponse, err error) {
|
||||
reqBody := AddContactsReq{
|
||||
ContactsCards: cards,
|
||||
Overwrite: overwrite,
|
||||
@ -302,7 +302,7 @@ type UpdateContactReq struct {
|
||||
}
|
||||
|
||||
// UpdateContact updates contact identified by contact ID. Modified contact is specified by cards.
|
||||
func (c *Client) UpdateContact(id string, cards []Card) (res *UpdateContactResponse, err error) {
|
||||
func (c *client) UpdateContact(id string, cards []Card) (res *UpdateContactResponse, err error) {
|
||||
reqBody := UpdateContactReq{
|
||||
Cards: cards,
|
||||
}
|
||||
@ -329,11 +329,11 @@ type UpdateContactGroupsResponse struct {
|
||||
Response SingleIDResponse
|
||||
}
|
||||
|
||||
func (c *Client) AddContactGroups(groupID string, contactEmailIDs []string) (res *UpdateContactGroupsResponse, err error) {
|
||||
func (c *client) AddContactGroups(groupID string, contactEmailIDs []string) (res *UpdateContactGroupsResponse, err error) {
|
||||
return c.modifyContactGroups(groupID, addContactGroupsAction, contactEmailIDs)
|
||||
}
|
||||
|
||||
func (c *Client) RemoveContactGroups(groupID string, contactEmailIDs []string) (res *UpdateContactGroupsResponse, err error) {
|
||||
func (c *client) RemoveContactGroups(groupID string, contactEmailIDs []string) (res *UpdateContactGroupsResponse, err error) {
|
||||
return c.modifyContactGroups(groupID, removeContactGroupsAction, contactEmailIDs)
|
||||
}
|
||||
|
||||
@ -348,7 +348,7 @@ type ModifyContactGroupsReq struct {
|
||||
ContactEmailIDs []string
|
||||
}
|
||||
|
||||
func (c *Client) modifyContactGroups(groupID string, modifyContactGroupsAction int, contactEmailIDs []string) (res *UpdateContactGroupsResponse, err error) {
|
||||
func (c *client) modifyContactGroups(groupID string, modifyContactGroupsAction int, contactEmailIDs []string) (res *UpdateContactGroupsResponse, err error) {
|
||||
reqBody := ModifyContactGroupsReq{
|
||||
LabelID: groupID,
|
||||
Action: modifyContactGroupsAction,
|
||||
@ -372,7 +372,7 @@ type DeleteReq struct {
|
||||
}
|
||||
|
||||
// DeleteContacts deletes contacts specified by an array of contact IDs.
|
||||
func (c *Client) DeleteContacts(ids []string) (err error) {
|
||||
func (c *client) DeleteContacts(ids []string) (err error) {
|
||||
deleteReq := DeleteReq{
|
||||
IDs: ids,
|
||||
}
|
||||
@ -401,7 +401,7 @@ func (c *Client) DeleteContacts(ids []string) (err error) {
|
||||
}
|
||||
|
||||
// DeleteAllContacts deletes all contacts.
|
||||
func (c *Client) DeleteAllContacts() (err error) {
|
||||
func (c *client) DeleteAllContacts() (err error) {
|
||||
req, err := c.NewRequest("DELETE", "/contacts", nil)
|
||||
if err != nil {
|
||||
return
|
||||
|
||||
@ -31,7 +31,7 @@ type ConversationsCountsRes struct {
|
||||
type Conversation struct{}
|
||||
|
||||
// CountConversations counts conversations by label.
|
||||
func (c *Client) CountConversations(addressID string) (counts []*ConversationsCount, err error) {
|
||||
func (c *client) CountConversations(addressID string) (counts []*ConversationsCount, err error) {
|
||||
reqURL := "/conversations/count"
|
||||
if addressID != "" {
|
||||
reqURL += ("?AddressID=" + addressID)
|
||||
|
||||
@ -172,11 +172,11 @@ type LatestEventRes struct {
|
||||
|
||||
// GetEvent returns a summary of events that occurred since last. To get the latest event,
|
||||
// provide an empty last value. The latest event is always empty.
|
||||
func (c *Client) GetEvent(last string) (event *Event, err error) {
|
||||
func (c *client) GetEvent(last string) (event *Event, err error) {
|
||||
return c.getEvent(last, 1)
|
||||
}
|
||||
|
||||
func (c *Client) getEvent(last string, numberOfMergedEvents int) (event *Event, err error) {
|
||||
func (c *client) getEvent(last string, numberOfMergedEvents int) (event *Event, err error) {
|
||||
var req *http.Request
|
||||
if last == "" {
|
||||
req, err = c.NewRequest("GET", "/events/latest", nil)
|
||||
|
||||
@ -117,7 +117,7 @@ type ImportMsgRes struct {
|
||||
}
|
||||
|
||||
// Import imports messages to the user's account.
|
||||
func (c *Client) Import(reqs []*ImportMsgReq) (resps []*ImportMsgRes, err error) {
|
||||
func (c *client) Import(reqs []*ImportMsgReq) (resps []*ImportMsgRes, err error) {
|
||||
importReq := &ImportReq{Messages: reqs}
|
||||
|
||||
req, w, err := c.NewMultipartRequest("POST", "/import")
|
||||
|
||||
@ -46,7 +46,7 @@ type PublicKey struct {
|
||||
}
|
||||
|
||||
// PublicKeys returns the public keys of the given email addresses.
|
||||
func (c *Client) PublicKeys(emails []string) (keys map[string]*pmcrypto.KeyRing, err error) {
|
||||
func (c *client) PublicKeys(emails []string) (keys map[string]*pmcrypto.KeyRing, err error) {
|
||||
if len(emails) == 0 {
|
||||
err = fmt.Errorf("pmapi: cannot get public keys: no email address provided")
|
||||
return
|
||||
@ -86,7 +86,7 @@ const (
|
||||
)
|
||||
|
||||
// GetPublicKeysForEmail returns all sending public keys for the given email address.
|
||||
func (c *Client) GetPublicKeysForEmail(email string) (keys []PublicKey, internal bool, err error) {
|
||||
func (c *client) GetPublicKeysForEmail(email string) (keys []PublicKey, internal bool, err error) {
|
||||
email = url.QueryEscape(email)
|
||||
|
||||
var req *http.Request
|
||||
@ -121,7 +121,7 @@ type KeySaltRes struct {
|
||||
}
|
||||
|
||||
// GetKeySalts sends request to get list of key salts (n.b. locked route).
|
||||
func (c *Client) GetKeySalts() (keySalts []KeySalt, err error) {
|
||||
func (c *client) GetKeySalts() (keySalts []KeySalt, err error) {
|
||||
var req *http.Request
|
||||
if req, err = c.NewRequest("GET", "/keys/salts", nil); err != nil {
|
||||
return
|
||||
|
||||
@ -186,7 +186,7 @@ func unlockKeyRingNoErrorWhenAlreadyUnlocked(kr *pmcrypto.KeyRing, passphrase []
|
||||
// ErrNoKeyringAvailable represents an error caused by a keyring being nil or having no entities.
|
||||
var ErrNoKeyringAvailable = errors.New("no keyring available")
|
||||
|
||||
func (c *Client) encrypt(plain string, signer *pmcrypto.KeyRing) (armored string, err error) {
|
||||
func (c *client) encrypt(plain string, signer *pmcrypto.KeyRing) (armored string, err error) {
|
||||
return encrypt(c.kr, plain, signer)
|
||||
}
|
||||
|
||||
@ -203,7 +203,7 @@ func encrypt(encrypter *pmcrypto.KeyRing, plain string, signer *pmcrypto.KeyRing
|
||||
return pgpMessage.GetArmored()
|
||||
}
|
||||
|
||||
func (c *Client) decrypt(armored string) (plain string, err error) {
|
||||
func (c *client) decrypt(armored string) (plain string, err error) {
|
||||
return decrypt(c.kr, armored)
|
||||
}
|
||||
|
||||
@ -222,7 +222,7 @@ func decrypt(decrypter *pmcrypto.KeyRing, armored string) (plainBody string, err
|
||||
return plainMessage.GetString(), nil
|
||||
}
|
||||
|
||||
func (c *Client) sign(plain string) (armoredSignature string, err error) {
|
||||
func (c *client) sign(plain string) (armoredSignature string, err error) {
|
||||
if c.kr == nil {
|
||||
return "", ErrNoKeyringAvailable
|
||||
}
|
||||
@ -234,7 +234,7 @@ func (c *Client) sign(plain string) (armoredSignature string, err error) {
|
||||
return pgpSignature.GetArmored()
|
||||
}
|
||||
|
||||
func (c *Client) verify(plain, amroredSignature string) (err error) {
|
||||
func (c *client) verify(plain, amroredSignature string) (err error) {
|
||||
plainMessage := pmcrypto.NewPlainMessageFromString(plain)
|
||||
pgpSignature, err := pmcrypto.NewPGPSignatureFromArmored(amroredSignature)
|
||||
if err != nil {
|
||||
|
||||
@ -93,16 +93,16 @@ type LabelListRes struct {
|
||||
Labels []*Label
|
||||
}
|
||||
|
||||
func (c *Client) ListLabels() (labels []*Label, err error) {
|
||||
func (c *client) ListLabels() (labels []*Label, err error) {
|
||||
return c.ListLabelType(LabelTypeMailbox)
|
||||
}
|
||||
|
||||
func (c *Client) ListContactGroups() (labels []*Label, err error) {
|
||||
func (c *client) ListContactGroups() (labels []*Label, err error) {
|
||||
return c.ListLabelType(LabelTypeContactGroup)
|
||||
}
|
||||
|
||||
// ListLabelType lists all labels created by the user.
|
||||
func (c *Client) ListLabelType(labelType int) (labels []*Label, err error) {
|
||||
func (c *client) ListLabelType(labelType int) (labels []*Label, err error) {
|
||||
req, err := c.NewRequest("GET", fmt.Sprintf("/labels?%d", labelType), nil)
|
||||
if err != nil {
|
||||
return
|
||||
@ -127,7 +127,7 @@ type LabelRes struct {
|
||||
}
|
||||
|
||||
// CreateLabel creates a new label.
|
||||
func (c *Client) CreateLabel(label *Label) (created *Label, err error) {
|
||||
func (c *client) CreateLabel(label *Label) (created *Label, err error) {
|
||||
labelReq := &LabelReq{label}
|
||||
req, err := c.NewJSONRequest("POST", "/labels", labelReq)
|
||||
if err != nil {
|
||||
@ -144,7 +144,7 @@ func (c *Client) CreateLabel(label *Label) (created *Label, err error) {
|
||||
}
|
||||
|
||||
// UpdateLabel updates a label.
|
||||
func (c *Client) UpdateLabel(label *Label) (updated *Label, err error) {
|
||||
func (c *client) UpdateLabel(label *Label) (updated *Label, err error) {
|
||||
labelReq := &LabelReq{label}
|
||||
req, err := c.NewJSONRequest("PUT", "/labels/"+label.ID, labelReq)
|
||||
if err != nil {
|
||||
@ -161,7 +161,7 @@ func (c *Client) UpdateLabel(label *Label) (updated *Label, err error) {
|
||||
}
|
||||
|
||||
// DeleteLabel deletes a label.
|
||||
func (c *Client) DeleteLabel(id string) (err error) {
|
||||
func (c *client) DeleteLabel(id string) (err error) {
|
||||
req, err := c.NewRequest("DELETE", "/labels/"+id, nil)
|
||||
if err != nil {
|
||||
return
|
||||
|
||||
@ -467,7 +467,7 @@ type MessagesListRes struct {
|
||||
}
|
||||
|
||||
// ListMessages gets message metadata.
|
||||
func (c *Client) ListMessages(filter *MessagesFilter) (msgs []*Message, total int, err error) {
|
||||
func (c *client) ListMessages(filter *MessagesFilter) (msgs []*Message, total int, err error) {
|
||||
req, err := c.NewRequest("GET", "/messages", nil)
|
||||
if err != nil {
|
||||
return
|
||||
@ -495,7 +495,7 @@ type MessagesCountsRes struct {
|
||||
}
|
||||
|
||||
// CountMessages counts messages by label.
|
||||
func (c *Client) CountMessages(addressID string) (counts []*MessagesCount, err error) {
|
||||
func (c *client) CountMessages(addressID string) (counts []*MessagesCount, err error) {
|
||||
reqURL := "/messages/count"
|
||||
if addressID != "" {
|
||||
reqURL += ("?AddressID=" + addressID)
|
||||
@ -521,7 +521,7 @@ type MessageRes struct {
|
||||
}
|
||||
|
||||
// GetMessage retrieves a message.
|
||||
func (c *Client) GetMessage(id string) (msg *Message, err error) {
|
||||
func (c *client) GetMessage(id string) (msg *Message, err error) {
|
||||
req, err := c.NewRequest("GET", "/messages/"+id, nil)
|
||||
if err != nil {
|
||||
return
|
||||
@ -589,7 +589,7 @@ type SendMessageRes struct {
|
||||
Parent *Message
|
||||
}
|
||||
|
||||
func (c *Client) SendMessage(id string, sendReq *SendMessageReq) (sent, parent *Message, err error) {
|
||||
func (c *client) SendMessage(id string, sendReq *SendMessageReq) (sent, parent *Message, err error) {
|
||||
if id == "" {
|
||||
err = errors.New("pmapi: cannot send message with an empty id")
|
||||
return
|
||||
@ -626,7 +626,7 @@ type DraftReq struct {
|
||||
AttachmentKeyPackets []string
|
||||
}
|
||||
|
||||
func (c *Client) CreateDraft(m *Message, parent string, action int) (created *Message, err error) {
|
||||
func (c *client) CreateDraft(m *Message, parent string, action int) (created *Message, err error) {
|
||||
createReq := &DraftReq{Message: m, ParentID: parent, Action: action, AttachmentKeyPackets: []string{}}
|
||||
|
||||
req, err := c.NewJSONRequest("POST", "/messages", createReq)
|
||||
@ -672,7 +672,7 @@ func (res MessagesActionRes) Err() error {
|
||||
|
||||
// doMessagesAction performs paged requests to doMessagesActionInner.
|
||||
// This can eventually be done in parallel though.
|
||||
func (c *Client) doMessagesAction(action string, ids []string) (err error) {
|
||||
func (c *client) doMessagesAction(action string, ids []string) (err error) {
|
||||
for len(ids) > messageIDPageSize {
|
||||
var requestIDs []string
|
||||
requestIDs, ids = ids[:messageIDPageSize], ids[messageIDPageSize:]
|
||||
@ -686,7 +686,7 @@ func (c *Client) doMessagesAction(action string, ids []string) (err error) {
|
||||
|
||||
// doMessagesActionInner is the non-paged inner method of doMessagesAction.
|
||||
// You should not call this directly unless you know what you are doing (it can overload the server).
|
||||
func (c *Client) doMessagesActionInner(action string, ids []string) (err error) {
|
||||
func (c *client) doMessagesActionInner(action string, ids []string) (err error) {
|
||||
actionReq := &MessagesActionReq{IDs: ids}
|
||||
req, err := c.NewJSONRequest("PUT", "/messages/"+action, actionReq)
|
||||
if err != nil {
|
||||
@ -703,19 +703,19 @@ func (c *Client) doMessagesActionInner(action string, ids []string) (err error)
|
||||
return
|
||||
}
|
||||
|
||||
func (c *Client) MarkMessagesRead(ids []string) error {
|
||||
func (c *client) MarkMessagesRead(ids []string) error {
|
||||
return c.doMessagesAction("read", ids)
|
||||
}
|
||||
|
||||
func (c *Client) MarkMessagesUnread(ids []string) error {
|
||||
func (c *client) MarkMessagesUnread(ids []string) error {
|
||||
return c.doMessagesAction("unread", ids)
|
||||
}
|
||||
|
||||
func (c *Client) DeleteMessages(ids []string) error {
|
||||
func (c *client) DeleteMessages(ids []string) error {
|
||||
return c.doMessagesAction("delete", ids)
|
||||
}
|
||||
|
||||
func (c *Client) UndeleteMessages(ids []string) error {
|
||||
func (c *client) UndeleteMessages(ids []string) error {
|
||||
return c.doMessagesAction("undelete", ids)
|
||||
}
|
||||
|
||||
@ -726,7 +726,7 @@ type LabelMessagesReq struct {
|
||||
|
||||
// LabelMessages labels the given message IDs with the given label.
|
||||
// The requests are performed paged; this can eventually be done in parallel.
|
||||
func (c *Client) LabelMessages(ids []string, label string) (err error) {
|
||||
func (c *client) LabelMessages(ids []string, label string) (err error) {
|
||||
for len(ids) > messageIDPageSize {
|
||||
var requestIDs []string
|
||||
requestIDs, ids = ids[:messageIDPageSize], ids[messageIDPageSize:]
|
||||
@ -738,7 +738,7 @@ func (c *Client) LabelMessages(ids []string, label string) (err error) {
|
||||
return c.labelMessages(ids, label)
|
||||
}
|
||||
|
||||
func (c *Client) labelMessages(ids []string, label string) (err error) {
|
||||
func (c *client) labelMessages(ids []string, label string) (err error) {
|
||||
labelReq := &LabelMessagesReq{LabelID: label, IDs: ids}
|
||||
req, err := c.NewJSONRequest("PUT", "/messages/label", labelReq)
|
||||
if err != nil {
|
||||
@ -756,7 +756,7 @@ func (c *Client) labelMessages(ids []string, label string) (err error) {
|
||||
|
||||
// UnlabelMessages removes the given label from the given message IDs.
|
||||
// The requests are performed paged; this can eventually be done in parallel.
|
||||
func (c *Client) UnlabelMessages(ids []string, label string) (err error) {
|
||||
func (c *client) UnlabelMessages(ids []string, label string) (err error) {
|
||||
for len(ids) > messageIDPageSize {
|
||||
var requestIDs []string
|
||||
requestIDs, ids = ids[:messageIDPageSize], ids[messageIDPageSize:]
|
||||
@ -768,7 +768,7 @@ func (c *Client) UnlabelMessages(ids []string, label string) (err error) {
|
||||
return c.unlabelMessages(ids, label)
|
||||
}
|
||||
|
||||
func (c *Client) unlabelMessages(ids []string, label string) (err error) {
|
||||
func (c *client) unlabelMessages(ids []string, label string) (err error) {
|
||||
labelReq := &LabelMessagesReq{LabelID: label, IDs: ids}
|
||||
req, err := c.NewJSONRequest("PUT", "/messages/unlabel", labelReq)
|
||||
if err != nil {
|
||||
@ -784,7 +784,7 @@ func (c *Client) unlabelMessages(ids []string, label string) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (c *Client) EmptyFolder(labelID, addressID string) (err error) {
|
||||
func (c *client) EmptyFolder(labelID, addressID string) (err error) {
|
||||
if labelID == "" {
|
||||
return errors.New("pmapi: labelID parameter is empty string")
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@ import (
|
||||
)
|
||||
|
||||
// SendSimpleMetric makes a simple GET request to send a simple metrics report.
|
||||
func (c *Client) SendSimpleMetric(category, action, label string) (err error) {
|
||||
func (c *client) SendSimpleMetric(category, action, label string) (err error) {
|
||||
v := url.Values{}
|
||||
v.Set("Category", category)
|
||||
v.Set("Action", action)
|
||||
|
||||
608
pkg/pmapi/mocks/mocks.go
Normal file
608
pkg/pmapi/mocks/mocks.go
Normal file
@ -0,0 +1,608 @@
|
||||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: github.com/ProtonMail/proton-bridge/pkg/pmapi (interfaces: Client)
|
||||
|
||||
// Package mocks is a generated GoMock package.
|
||||
package mocks
|
||||
|
||||
import (
|
||||
io "io"
|
||||
reflect "reflect"
|
||||
|
||||
crypto "github.com/ProtonMail/gopenpgp/crypto"
|
||||
pmapi "github.com/ProtonMail/proton-bridge/pkg/pmapi"
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
)
|
||||
|
||||
// MockClient is a mock of Client interface
|
||||
type MockClient struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockClientMockRecorder
|
||||
}
|
||||
|
||||
// MockClientMockRecorder is the mock recorder for MockClient
|
||||
type MockClientMockRecorder struct {
|
||||
mock *MockClient
|
||||
}
|
||||
|
||||
// NewMockClient creates a new mock instance
|
||||
func NewMockClient(ctrl *gomock.Controller) *MockClient {
|
||||
mock := &MockClient{ctrl: ctrl}
|
||||
mock.recorder = &MockClientMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use
|
||||
func (m *MockClient) EXPECT() *MockClientMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// Addresses mocks base method
|
||||
func (m *MockClient) Addresses() pmapi.AddressList {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Addresses")
|
||||
ret0, _ := ret[0].(pmapi.AddressList)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Addresses indicates an expected call of Addresses
|
||||
func (mr *MockClientMockRecorder) Addresses() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Addresses", reflect.TypeOf((*MockClient)(nil).Addresses))
|
||||
}
|
||||
|
||||
// Auth mocks base method
|
||||
func (m *MockClient) Auth(arg0, arg1 string, arg2 *pmapi.AuthInfo) (*pmapi.Auth, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Auth", arg0, arg1, arg2)
|
||||
ret0, _ := ret[0].(*pmapi.Auth)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// Auth indicates an expected call of Auth
|
||||
func (mr *MockClientMockRecorder) Auth(arg0, arg1, arg2 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Auth", reflect.TypeOf((*MockClient)(nil).Auth), arg0, arg1, arg2)
|
||||
}
|
||||
|
||||
// Auth2FA mocks base method
|
||||
func (m *MockClient) Auth2FA(arg0 string, arg1 *pmapi.Auth) (*pmapi.Auth2FA, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Auth2FA", arg0, arg1)
|
||||
ret0, _ := ret[0].(*pmapi.Auth2FA)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// Auth2FA indicates an expected call of Auth2FA
|
||||
func (mr *MockClientMockRecorder) Auth2FA(arg0, arg1 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Auth2FA", reflect.TypeOf((*MockClient)(nil).Auth2FA), arg0, arg1)
|
||||
}
|
||||
|
||||
// AuthInfo mocks base method
|
||||
func (m *MockClient) AuthInfo(arg0 string) (*pmapi.AuthInfo, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "AuthInfo", arg0)
|
||||
ret0, _ := ret[0].(*pmapi.AuthInfo)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// AuthInfo indicates an expected call of AuthInfo
|
||||
func (mr *MockClientMockRecorder) AuthInfo(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AuthInfo", reflect.TypeOf((*MockClient)(nil).AuthInfo), arg0)
|
||||
}
|
||||
|
||||
// AuthRefresh mocks base method
|
||||
func (m *MockClient) AuthRefresh(arg0 string) (*pmapi.Auth, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "AuthRefresh", arg0)
|
||||
ret0, _ := ret[0].(*pmapi.Auth)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// AuthRefresh indicates an expected call of AuthRefresh
|
||||
func (mr *MockClientMockRecorder) AuthRefresh(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AuthRefresh", reflect.TypeOf((*MockClient)(nil).AuthRefresh), arg0)
|
||||
}
|
||||
|
||||
// CountMessages mocks base method
|
||||
func (m *MockClient) CountMessages(arg0 string) ([]*pmapi.MessagesCount, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "CountMessages", arg0)
|
||||
ret0, _ := ret[0].([]*pmapi.MessagesCount)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// CountMessages indicates an expected call of CountMessages
|
||||
func (mr *MockClientMockRecorder) CountMessages(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CountMessages", reflect.TypeOf((*MockClient)(nil).CountMessages), arg0)
|
||||
}
|
||||
|
||||
// CreateAttachment mocks base method
|
||||
func (m *MockClient) CreateAttachment(arg0 *pmapi.Attachment, arg1, arg2 io.Reader) (*pmapi.Attachment, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "CreateAttachment", arg0, arg1, arg2)
|
||||
ret0, _ := ret[0].(*pmapi.Attachment)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// CreateAttachment indicates an expected call of CreateAttachment
|
||||
func (mr *MockClientMockRecorder) CreateAttachment(arg0, arg1, arg2 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateAttachment", reflect.TypeOf((*MockClient)(nil).CreateAttachment), arg0, arg1, arg2)
|
||||
}
|
||||
|
||||
// CreateDraft mocks base method
|
||||
func (m *MockClient) CreateDraft(arg0 *pmapi.Message, arg1 string, arg2 int) (*pmapi.Message, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "CreateDraft", arg0, arg1, arg2)
|
||||
ret0, _ := ret[0].(*pmapi.Message)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// CreateDraft indicates an expected call of CreateDraft
|
||||
func (mr *MockClientMockRecorder) CreateDraft(arg0, arg1, arg2 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateDraft", reflect.TypeOf((*MockClient)(nil).CreateDraft), arg0, arg1, arg2)
|
||||
}
|
||||
|
||||
// CreateLabel mocks base method
|
||||
func (m *MockClient) CreateLabel(arg0 *pmapi.Label) (*pmapi.Label, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "CreateLabel", arg0)
|
||||
ret0, _ := ret[0].(*pmapi.Label)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// CreateLabel indicates an expected call of CreateLabel
|
||||
func (mr *MockClientMockRecorder) CreateLabel(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateLabel", reflect.TypeOf((*MockClient)(nil).CreateLabel), arg0)
|
||||
}
|
||||
|
||||
// CurrentUser mocks base method
|
||||
func (m *MockClient) CurrentUser() (*pmapi.User, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "CurrentUser")
|
||||
ret0, _ := ret[0].(*pmapi.User)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// CurrentUser indicates an expected call of CurrentUser
|
||||
func (mr *MockClientMockRecorder) CurrentUser() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CurrentUser", reflect.TypeOf((*MockClient)(nil).CurrentUser))
|
||||
}
|
||||
|
||||
// DecryptAndVerifyCards mocks base method
|
||||
func (m *MockClient) DecryptAndVerifyCards(arg0 []pmapi.Card) ([]pmapi.Card, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "DecryptAndVerifyCards", arg0)
|
||||
ret0, _ := ret[0].([]pmapi.Card)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// DecryptAndVerifyCards indicates an expected call of DecryptAndVerifyCards
|
||||
func (mr *MockClientMockRecorder) DecryptAndVerifyCards(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DecryptAndVerifyCards", reflect.TypeOf((*MockClient)(nil).DecryptAndVerifyCards), arg0)
|
||||
}
|
||||
|
||||
// DeleteAttachment mocks base method
|
||||
func (m *MockClient) DeleteAttachment(arg0 string) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "DeleteAttachment", arg0)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// DeleteAttachment indicates an expected call of DeleteAttachment
|
||||
func (mr *MockClientMockRecorder) DeleteAttachment(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteAttachment", reflect.TypeOf((*MockClient)(nil).DeleteAttachment), arg0)
|
||||
}
|
||||
|
||||
// DeleteLabel mocks base method
|
||||
func (m *MockClient) DeleteLabel(arg0 string) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "DeleteLabel", arg0)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// DeleteLabel indicates an expected call of DeleteLabel
|
||||
func (mr *MockClientMockRecorder) DeleteLabel(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteLabel", reflect.TypeOf((*MockClient)(nil).DeleteLabel), arg0)
|
||||
}
|
||||
|
||||
// DeleteMessages mocks base method
|
||||
func (m *MockClient) DeleteMessages(arg0 []string) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "DeleteMessages", arg0)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// DeleteMessages indicates an expected call of DeleteMessages
|
||||
func (mr *MockClientMockRecorder) DeleteMessages(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteMessages", reflect.TypeOf((*MockClient)(nil).DeleteMessages), arg0)
|
||||
}
|
||||
|
||||
// EmptyFolder mocks base method
|
||||
func (m *MockClient) EmptyFolder(arg0, arg1 string) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "EmptyFolder", arg0, arg1)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// EmptyFolder indicates an expected call of EmptyFolder
|
||||
func (mr *MockClientMockRecorder) EmptyFolder(arg0, arg1 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EmptyFolder", reflect.TypeOf((*MockClient)(nil).EmptyFolder), arg0, arg1)
|
||||
}
|
||||
|
||||
// GetAttachment mocks base method
|
||||
func (m *MockClient) GetAttachment(arg0 string) (io.ReadCloser, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetAttachment", arg0)
|
||||
ret0, _ := ret[0].(io.ReadCloser)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetAttachment indicates an expected call of GetAttachment
|
||||
func (mr *MockClientMockRecorder) GetAttachment(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAttachment", reflect.TypeOf((*MockClient)(nil).GetAttachment), arg0)
|
||||
}
|
||||
|
||||
// GetContactByID mocks base method
|
||||
func (m *MockClient) GetContactByID(arg0 string) (pmapi.Contact, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetContactByID", arg0)
|
||||
ret0, _ := ret[0].(pmapi.Contact)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetContactByID indicates an expected call of GetContactByID
|
||||
func (mr *MockClientMockRecorder) GetContactByID(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetContactByID", reflect.TypeOf((*MockClient)(nil).GetContactByID), arg0)
|
||||
}
|
||||
|
||||
// GetContactEmailByEmail mocks base method
|
||||
func (m *MockClient) GetContactEmailByEmail(arg0 string, arg1, arg2 int) ([]pmapi.ContactEmail, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetContactEmailByEmail", arg0, arg1, arg2)
|
||||
ret0, _ := ret[0].([]pmapi.ContactEmail)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetContactEmailByEmail indicates an expected call of GetContactEmailByEmail
|
||||
func (mr *MockClientMockRecorder) GetContactEmailByEmail(arg0, arg1, arg2 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetContactEmailByEmail", reflect.TypeOf((*MockClient)(nil).GetContactEmailByEmail), arg0, arg1, arg2)
|
||||
}
|
||||
|
||||
// GetEvent mocks base method
|
||||
func (m *MockClient) GetEvent(arg0 string) (*pmapi.Event, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetEvent", arg0)
|
||||
ret0, _ := ret[0].(*pmapi.Event)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetEvent indicates an expected call of GetEvent
|
||||
func (mr *MockClientMockRecorder) GetEvent(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetEvent", reflect.TypeOf((*MockClient)(nil).GetEvent), arg0)
|
||||
}
|
||||
|
||||
// GetMailSettings mocks base method
|
||||
func (m *MockClient) GetMailSettings() (pmapi.MailSettings, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetMailSettings")
|
||||
ret0, _ := ret[0].(pmapi.MailSettings)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetMailSettings indicates an expected call of GetMailSettings
|
||||
func (mr *MockClientMockRecorder) GetMailSettings() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetMailSettings", reflect.TypeOf((*MockClient)(nil).GetMailSettings))
|
||||
}
|
||||
|
||||
// GetMessage mocks base method
|
||||
func (m *MockClient) GetMessage(arg0 string) (*pmapi.Message, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetMessage", arg0)
|
||||
ret0, _ := ret[0].(*pmapi.Message)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetMessage indicates an expected call of GetMessage
|
||||
func (mr *MockClientMockRecorder) GetMessage(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetMessage", reflect.TypeOf((*MockClient)(nil).GetMessage), arg0)
|
||||
}
|
||||
|
||||
// GetPublicKeysForEmail mocks base method
|
||||
func (m *MockClient) GetPublicKeysForEmail(arg0 string) ([]pmapi.PublicKey, bool, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetPublicKeysForEmail", arg0)
|
||||
ret0, _ := ret[0].([]pmapi.PublicKey)
|
||||
ret1, _ := ret[1].(bool)
|
||||
ret2, _ := ret[2].(error)
|
||||
return ret0, ret1, ret2
|
||||
}
|
||||
|
||||
// GetPublicKeysForEmail indicates an expected call of GetPublicKeysForEmail
|
||||
func (mr *MockClientMockRecorder) GetPublicKeysForEmail(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPublicKeysForEmail", reflect.TypeOf((*MockClient)(nil).GetPublicKeysForEmail), arg0)
|
||||
}
|
||||
|
||||
// Import mocks base method
|
||||
func (m *MockClient) Import(arg0 []*pmapi.ImportMsgReq) ([]*pmapi.ImportMsgRes, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Import", arg0)
|
||||
ret0, _ := ret[0].([]*pmapi.ImportMsgRes)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// Import indicates an expected call of Import
|
||||
func (mr *MockClientMockRecorder) Import(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Import", reflect.TypeOf((*MockClient)(nil).Import), arg0)
|
||||
}
|
||||
|
||||
// KeyRingForAddressID mocks base method
|
||||
func (m *MockClient) KeyRingForAddressID(arg0 string) *crypto.KeyRing {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "KeyRingForAddressID", arg0)
|
||||
ret0, _ := ret[0].(*crypto.KeyRing)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// KeyRingForAddressID indicates an expected call of KeyRingForAddressID
|
||||
func (mr *MockClientMockRecorder) KeyRingForAddressID(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "KeyRingForAddressID", reflect.TypeOf((*MockClient)(nil).KeyRingForAddressID), arg0)
|
||||
}
|
||||
|
||||
// LabelMessages mocks base method
|
||||
func (m *MockClient) LabelMessages(arg0 []string, arg1 string) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "LabelMessages", arg0, arg1)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// LabelMessages indicates an expected call of LabelMessages
|
||||
func (mr *MockClientMockRecorder) LabelMessages(arg0, arg1 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LabelMessages", reflect.TypeOf((*MockClient)(nil).LabelMessages), arg0, arg1)
|
||||
}
|
||||
|
||||
// ListLabels mocks base method
|
||||
func (m *MockClient) ListLabels() ([]*pmapi.Label, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ListLabels")
|
||||
ret0, _ := ret[0].([]*pmapi.Label)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// ListLabels indicates an expected call of ListLabels
|
||||
func (mr *MockClientMockRecorder) ListLabels() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListLabels", reflect.TypeOf((*MockClient)(nil).ListLabels))
|
||||
}
|
||||
|
||||
// ListMessages mocks base method
|
||||
func (m *MockClient) ListMessages(arg0 *pmapi.MessagesFilter) ([]*pmapi.Message, int, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ListMessages", arg0)
|
||||
ret0, _ := ret[0].([]*pmapi.Message)
|
||||
ret1, _ := ret[1].(int)
|
||||
ret2, _ := ret[2].(error)
|
||||
return ret0, ret1, ret2
|
||||
}
|
||||
|
||||
// ListMessages indicates an expected call of ListMessages
|
||||
func (mr *MockClientMockRecorder) ListMessages(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListMessages", reflect.TypeOf((*MockClient)(nil).ListMessages), arg0)
|
||||
}
|
||||
|
||||
// Logout mocks base method
|
||||
func (m *MockClient) Logout() {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "Logout")
|
||||
}
|
||||
|
||||
// Logout indicates an expected call of Logout
|
||||
func (mr *MockClientMockRecorder) Logout() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Logout", reflect.TypeOf((*MockClient)(nil).Logout))
|
||||
}
|
||||
|
||||
// MarkMessagesRead mocks base method
|
||||
func (m *MockClient) MarkMessagesRead(arg0 []string) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "MarkMessagesRead", arg0)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// MarkMessagesRead indicates an expected call of MarkMessagesRead
|
||||
func (mr *MockClientMockRecorder) MarkMessagesRead(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MarkMessagesRead", reflect.TypeOf((*MockClient)(nil).MarkMessagesRead), arg0)
|
||||
}
|
||||
|
||||
// MarkMessagesUnread mocks base method
|
||||
func (m *MockClient) MarkMessagesUnread(arg0 []string) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "MarkMessagesUnread", arg0)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// MarkMessagesUnread indicates an expected call of MarkMessagesUnread
|
||||
func (mr *MockClientMockRecorder) MarkMessagesUnread(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MarkMessagesUnread", reflect.TypeOf((*MockClient)(nil).MarkMessagesUnread), arg0)
|
||||
}
|
||||
|
||||
// ReportBugWithEmailClient mocks base method
|
||||
func (m *MockClient) ReportBugWithEmailClient(arg0, arg1, arg2, arg3, arg4, arg5, arg6 string) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ReportBugWithEmailClient", arg0, arg1, arg2, arg3, arg4, arg5, arg6)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// ReportBugWithEmailClient indicates an expected call of ReportBugWithEmailClient
|
||||
func (mr *MockClientMockRecorder) ReportBugWithEmailClient(arg0, arg1, arg2, arg3, arg4, arg5, arg6 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReportBugWithEmailClient", reflect.TypeOf((*MockClient)(nil).ReportBugWithEmailClient), arg0, arg1, arg2, arg3, arg4, arg5, arg6)
|
||||
}
|
||||
|
||||
// ReportSentryCrash mocks base method
|
||||
func (m *MockClient) ReportSentryCrash(arg0 error) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ReportSentryCrash", arg0)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// ReportSentryCrash indicates an expected call of ReportSentryCrash
|
||||
func (mr *MockClientMockRecorder) ReportSentryCrash(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReportSentryCrash", reflect.TypeOf((*MockClient)(nil).ReportSentryCrash), arg0)
|
||||
}
|
||||
|
||||
// SendMessage mocks base method
|
||||
func (m *MockClient) SendMessage(arg0 string, arg1 *pmapi.SendMessageReq) (*pmapi.Message, *pmapi.Message, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "SendMessage", arg0, arg1)
|
||||
ret0, _ := ret[0].(*pmapi.Message)
|
||||
ret1, _ := ret[1].(*pmapi.Message)
|
||||
ret2, _ := ret[2].(error)
|
||||
return ret0, ret1, ret2
|
||||
}
|
||||
|
||||
// SendMessage indicates an expected call of SendMessage
|
||||
func (mr *MockClientMockRecorder) SendMessage(arg0, arg1 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendMessage", reflect.TypeOf((*MockClient)(nil).SendMessage), arg0, arg1)
|
||||
}
|
||||
|
||||
// SendSimpleMetric mocks base method
|
||||
func (m *MockClient) SendSimpleMetric(arg0, arg1, arg2 string) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "SendSimpleMetric", arg0, arg1, arg2)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// SendSimpleMetric indicates an expected call of SendSimpleMetric
|
||||
func (mr *MockClientMockRecorder) SendSimpleMetric(arg0, arg1, arg2 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendSimpleMetric", reflect.TypeOf((*MockClient)(nil).SendSimpleMetric), arg0, arg1, arg2)
|
||||
}
|
||||
|
||||
// UnlabelMessages mocks base method
|
||||
func (m *MockClient) UnlabelMessages(arg0 []string, arg1 string) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "UnlabelMessages", arg0, arg1)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// UnlabelMessages indicates an expected call of UnlabelMessages
|
||||
func (mr *MockClientMockRecorder) UnlabelMessages(arg0, arg1 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UnlabelMessages", reflect.TypeOf((*MockClient)(nil).UnlabelMessages), arg0, arg1)
|
||||
}
|
||||
|
||||
// Unlock mocks base method
|
||||
func (m *MockClient) Unlock(arg0 string) (*crypto.KeyRing, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Unlock", arg0)
|
||||
ret0, _ := ret[0].(*crypto.KeyRing)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// Unlock indicates an expected call of Unlock
|
||||
func (mr *MockClientMockRecorder) Unlock(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Unlock", reflect.TypeOf((*MockClient)(nil).Unlock), arg0)
|
||||
}
|
||||
|
||||
// UnlockAddresses mocks base method
|
||||
func (m *MockClient) UnlockAddresses(arg0 []byte) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "UnlockAddresses", arg0)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// UnlockAddresses indicates an expected call of UnlockAddresses
|
||||
func (mr *MockClientMockRecorder) UnlockAddresses(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UnlockAddresses", reflect.TypeOf((*MockClient)(nil).UnlockAddresses), arg0)
|
||||
}
|
||||
|
||||
// UpdateLabel mocks base method
|
||||
func (m *MockClient) UpdateLabel(arg0 *pmapi.Label) (*pmapi.Label, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "UpdateLabel", arg0)
|
||||
ret0, _ := ret[0].(*pmapi.Label)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// UpdateLabel indicates an expected call of UpdateLabel
|
||||
func (mr *MockClientMockRecorder) UpdateLabel(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateLabel", reflect.TypeOf((*MockClient)(nil).UpdateLabel), arg0)
|
||||
}
|
||||
|
||||
// UpdateUser mocks base method
|
||||
func (m *MockClient) UpdateUser() (*pmapi.User, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "UpdateUser")
|
||||
ret0, _ := ret[0].(*pmapi.User)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// UpdateUser indicates an expected call of UpdateUser
|
||||
func (mr *MockClientMockRecorder) UpdateUser() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateUser", reflect.TypeOf((*MockClient)(nil).UpdateUser))
|
||||
}
|
||||
@ -26,7 +26,7 @@ import (
|
||||
)
|
||||
|
||||
// NewRequest creates a new request.
|
||||
func (c *Client) NewRequest(method, path string, body io.Reader) (req *http.Request, err error) {
|
||||
func (c *client) NewRequest(method, path string, body io.Reader) (req *http.Request, err error) {
|
||||
// TODO: Support other protocols (localhost needs http not https).
|
||||
req, err = http.NewRequest(method, c.cm.GetRootURL()+path, body)
|
||||
|
||||
@ -37,7 +37,7 @@ func (c *Client) NewRequest(method, path string, body io.Reader) (req *http.Requ
|
||||
}
|
||||
|
||||
// NewJSONRequest create a new JSON request.
|
||||
func (c *Client) NewJSONRequest(method, path string, body interface{}) (*http.Request, error) {
|
||||
func (c *client) NewJSONRequest(method, path string, body interface{}) (*http.Request, error) {
|
||||
b, err := json.Marshal(body)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@ -72,7 +72,7 @@ func (w *MultipartWriter) Close() error {
|
||||
// that writing the request and sending it MUST be done in parallel. If the
|
||||
// request fails, subsequent writes to the multipart writer will fail with an
|
||||
// io.ErrClosedPipe error.
|
||||
func (c *Client) NewMultipartRequest(method, path string) (req *http.Request, w *MultipartWriter, err error) {
|
||||
func (c *client) NewMultipartRequest(method, path string) (req *http.Request, w *MultipartWriter, err error) {
|
||||
// The pipe will connect the multipart writer and the HTTP request body.
|
||||
pr, pw := io.Pipe()
|
||||
|
||||
|
||||
@ -146,7 +146,7 @@ func findPanicSender(s *SentryThreads, err error) string {
|
||||
}
|
||||
|
||||
// ReportSentryCrash reports a sentry crash with stacktrace from all goroutines.
|
||||
func (c *Client) ReportSentryCrash(reportErr error) (err error) {
|
||||
func (c *client) ReportSentryCrash(reportErr error) (err error) {
|
||||
if reportErr == nil {
|
||||
return
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ func Equals(tb testing.TB, exp, act interface{}) {
|
||||
}
|
||||
|
||||
// newTestServer is old function and should be replaced everywhere by newTestServerCallbacks.
|
||||
func newTestServer(h http.Handler) (*httptest.Server, *Client) {
|
||||
func newTestServer(h http.Handler) (*httptest.Server, *client) {
|
||||
s := httptest.NewServer(h)
|
||||
|
||||
serverURL, err := url.Parse(s.URL)
|
||||
@ -86,7 +86,7 @@ func newTestServer(h http.Handler) (*httptest.Server, *Client) {
|
||||
return s, newTestClient(cm)
|
||||
}
|
||||
|
||||
func newTestServerCallbacks(tb testing.TB, callbacks ...func(testing.TB, http.ResponseWriter, *http.Request) string) (func(), *Client) {
|
||||
func newTestServerCallbacks(tb testing.TB, callbacks ...func(testing.TB, http.ResponseWriter, *http.Request) string) (func(), *client) {
|
||||
reqNum := 0
|
||||
_, file, line, _ := runtime.Caller(1)
|
||||
file = filepath.Base(file)
|
||||
|
||||
@ -44,7 +44,7 @@ type UserSettings struct {
|
||||
}
|
||||
|
||||
// GetUserSettings gets general settings.
|
||||
func (c *Client) GetUserSettings() (settings UserSettings, err error) {
|
||||
func (c *client) GetUserSettings() (settings UserSettings, err error) {
|
||||
req, err := c.NewRequest("GET", "/settings", nil)
|
||||
|
||||
if err != nil {
|
||||
@ -98,7 +98,7 @@ type MailSettings struct {
|
||||
}
|
||||
|
||||
// GetMailSettings gets contact details specified by contact ID.
|
||||
func (c *Client) GetMailSettings() (settings MailSettings, err error) {
|
||||
func (c *client) GetMailSettings() (settings MailSettings, err error) {
|
||||
req, err := c.NewRequest("GET", "/settings/mail", nil)
|
||||
|
||||
if err != nil {
|
||||
|
||||
@ -92,7 +92,7 @@ func (u *User) KeyRing() *pmcrypto.KeyRing {
|
||||
}
|
||||
|
||||
// UpdateUser retrieves details about user and loads its addresses.
|
||||
func (c *Client) UpdateUser() (user *User, err error) {
|
||||
func (c *client) UpdateUser() (user *User, err error) {
|
||||
req, err := c.NewRequest("GET", "/users", nil)
|
||||
if err != nil {
|
||||
return
|
||||
@ -122,7 +122,7 @@ func (c *Client) UpdateUser() (user *User, err error) {
|
||||
}
|
||||
|
||||
// CurrentUser returns currently active user or user will be updated.
|
||||
func (c *Client) CurrentUser() (user *User, err error) {
|
||||
func (c *client) CurrentUser() (user *User, err error) {
|
||||
if c.user != nil && len(c.addresses) != 0 {
|
||||
user = c.user
|
||||
return
|
||||
|
||||
@ -23,6 +23,7 @@ import (
|
||||
|
||||
"github.com/ProtonMail/proton-bridge/internal/preferences"
|
||||
"github.com/ProtonMail/proton-bridge/pkg/listener"
|
||||
"github.com/ProtonMail/proton-bridge/pkg/pmapi"
|
||||
)
|
||||
|
||||
// GetBridge returns bridge instance.
|
||||
@ -33,7 +34,7 @@ func (ctx *TestContext) GetBridge() *bridge.Bridge {
|
||||
// withBridgeInstance creates a bridge instance for use in the test.
|
||||
// Every TestContext has this by default and thus this doesn't need to be exported.
|
||||
func (ctx *TestContext) withBridgeInstance() {
|
||||
pmapiFactory := func(userID string) bridge.PMAPIProvider {
|
||||
pmapiFactory := func(userID string) pmapi.Client {
|
||||
return ctx.pmapiController.GetClient(userID)
|
||||
}
|
||||
ctx.bridge = newBridgeInstance(ctx.t, ctx.cfg, ctx.credStore, ctx.listener, pmapiFactory)
|
||||
|
||||
Reference in New Issue
Block a user