Skip to content

Commit e6e08d5

Browse files
authored
test against supported go versions (keybase#74)
* test against supported go versions * appease ci
1 parent 5d323af commit e6e08d5

File tree

11 files changed

+61
-12
lines changed

11 files changed

+61
-12
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ os:
66

77
before_install:
88
- go get golang.org/x/lint/golint
9-
- go mod tidy
109

1110
script:
1211
- go vet ./...
1312
- golint ./...
14-
- curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.32.2
13+
- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.43.0
1514
- golangci-lint run
1615
- go test -tags skipsecretserviceintegrationtests ./...
1716

1817
go:
19-
- 1.14.x
2018
- 1.15.x
19+
- 1.16.x
20+
- 1.17.x

bind/bind.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build darwin || ios
12
// +build darwin ios
23

34
package bind

bindtest/bind_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build darwin || ios
12
// +build darwin ios
23

34
package bindtest

corefoundation.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build darwin || ios
12
// +build darwin ios
23

34
package keychain

datetime.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build darwin || ios
12
// +build darwin ios
23

34
package keychain

datetime_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build darwin && !ios
12
// +build darwin,!ios
23

34
package keychain

go.mod

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
module github.com/keybase/go-keychain
22

3-
go 1.14
3+
go 1.17
44

55
require (
66
github.com/keybase/go.dbus v0.0.0-20200324223359-a94be52c0b03
77
github.com/pkg/errors v0.9.1
88
github.com/stretchr/testify v1.5.1
99
golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59
1010
)
11+
12+
require (
13+
github.com/davecgh/go-spew v1.1.0 // indirect
14+
github.com/pmezard/go-difflib v1.0.0 // indirect
15+
gopkg.in/yaml.v2 v2.2.2 // indirect
16+
)

ios.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build darwin && ios
12
// +build darwin,ios
23

34
package keychain

keychain.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ var (
5757
ErrorDecode = Error(C.errSecDecode)
5858
// ErrorNoSuchKeychain corresponds to errSecNoSuchKeychain result code
5959
ErrorNoSuchKeychain = Error(C.errSecNoSuchKeychain)
60-
// ErrorNoAcccessForItem corresponds to errSecNoAccessForItem result code
60+
// ErrorNoAccessForItem corresponds to errSecNoAccessForItem result code
6161
ErrorNoAccessForItem = Error(C.errSecNoAccessForItem)
6262
// ErrorReadOnly corresponds to errSecReadOnly result code
6363
ErrorReadOnly = Error(C.errSecReadOnly)

secretservice/secretservice.go

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,49 +8,64 @@ import (
88
errors "github.com/pkg/errors"
99
)
1010

11+
// SecretServiceInterface
1112
const SecretServiceInterface = "org.freedesktop.secrets"
13+
14+
// SecretServiceObjectPath
1215
const SecretServiceObjectPath dbus.ObjectPath = "/org/freedesktop/secrets"
1316

1417
// DefaultCollection need not necessarily exist in the user's keyring.
1518
const DefaultCollection dbus.ObjectPath = "/org/freedesktop/secrets/aliases/default"
1619

17-
type authenticationMode string
20+
// AuthenticationMode
21+
type AuthenticationMode string
22+
23+
// AuthenticationInsecurePlain
24+
const AuthenticationInsecurePlain AuthenticationMode = "plain"
1825

19-
const AuthenticationInsecurePlain authenticationMode = "plain"
20-
const AuthenticationDHAES authenticationMode = "dh-ietf1024-sha256-aes128-cbc-pkcs7"
26+
// AuthenticationDHAES
27+
const AuthenticationDHAES AuthenticationMode = "dh-ietf1024-sha256-aes128-cbc-pkcs7"
2128

29+
// NilFlags
2230
const NilFlags = 0
2331

32+
// Attributes
2433
type Attributes map[string]string
2534

35+
// Secret
2636
type Secret struct {
2737
Session dbus.ObjectPath
2838
Parameters []byte
2939
Value []byte
3040
ContentType string
3141
}
3242

43+
// PromptCompletedResult
3344
type PromptCompletedResult struct {
3445
Dismissed bool
3546
Paths dbus.Variant
3647
}
3748

49+
// SecretService
3850
type SecretService struct {
3951
conn *dbus.Conn
4052
signalCh <-chan *dbus.Signal
4153
sessionOpenTimeout time.Duration
4254
}
4355

56+
// Session
4457
type Session struct {
45-
Mode authenticationMode
58+
Mode AuthenticationMode
4659
Path dbus.ObjectPath
4760
Public *big.Int
4861
Private *big.Int
4962
AESKey []byte
5063
}
5164

65+
// DefaultSessionOpenTimeout
5266
const DefaultSessionOpenTimeout = 10 * time.Second
5367

68+
// NewService
5469
func NewService() (*SecretService, error) {
5570
conn, err := dbus.SessionBus()
5671
if err != nil {
@@ -61,14 +76,17 @@ func NewService() (*SecretService, error) {
6176
return &SecretService{conn: conn, signalCh: signalCh, sessionOpenTimeout: DefaultSessionOpenTimeout}, nil
6277
}
6378

79+
// SetSessionOpenTimeout
6480
func (s *SecretService) SetSessionOpenTimeout(d time.Duration) {
6581
s.sessionOpenTimeout = d
6682
}
6783

84+
// ServiceObj
6885
func (s *SecretService) ServiceObj() *dbus.Object {
6986
return s.conn.Object(SecretServiceInterface, SecretServiceObjectPath)
7087
}
7188

89+
// Obj
7290
func (s *SecretService) Obj(path dbus.ObjectPath) *dbus.Object {
7391
return s.conn.Object(SecretServiceInterface, path)
7492
}
@@ -78,14 +96,15 @@ type sessionOpenResponse struct {
7896
path dbus.ObjectPath
7997
}
8098

81-
func (s *SecretService) openSessionRaw(mode authenticationMode, sessionAlgorithmInput dbus.Variant) (resp sessionOpenResponse, err error) {
99+
func (s *SecretService) openSessionRaw(mode AuthenticationMode, sessionAlgorithmInput dbus.Variant) (resp sessionOpenResponse, err error) {
82100
err = s.ServiceObj().
83101
Call("org.freedesktop.Secret.Service.OpenSession", NilFlags, mode, sessionAlgorithmInput).
84102
Store(&resp.algorithmOutput, &resp.path)
85103
return resp, errors.Wrap(err, "failed to open secretservice session")
86104
}
87105

88-
func (s *SecretService) OpenSession(mode authenticationMode) (session *Session, err error) {
106+
// OpenSession
107+
func (s *SecretService) OpenSession(mode AuthenticationMode) (session *Session, err error) {
89108
var sessionAlgorithmInput dbus.Variant
90109

91110
session = new(Session)
@@ -157,10 +176,12 @@ func (s *SecretService) OpenSession(mode authenticationMode) (session *Session,
157176
return session, nil
158177
}
159178

179+
// CloseSession
160180
func (s *SecretService) CloseSession(session *Session) {
161181
s.Obj(session.Path).Call("org.freedesktop.Secret.Session.Close", NilFlags)
162182
}
163183

184+
// SearchColleciton
164185
func (s *SecretService) SearchCollection(collection dbus.ObjectPath, attributes Attributes) (items []dbus.ObjectPath, err error) {
165186
err = s.Obj(collection).
166187
Call("org.freedesktop.Secret.Collection.SearchItems", NilFlags, attributes).
@@ -171,11 +192,16 @@ func (s *SecretService) SearchCollection(collection dbus.ObjectPath, attributes
171192
return items, nil
172193
}
173194

195+
// ReplaceBehavior
174196
type ReplaceBehavior int
175197

198+
// ReplaceBehaviorDoNotReplace
176199
const ReplaceBehaviorDoNotReplace = 0
200+
201+
// ReplaceBehaviorReplace
177202
const ReplaceBehaviorReplace = 1
178203

204+
// CreateItem
179205
func (s *SecretService) CreateItem(collection dbus.ObjectPath, properties map[string]dbus.Variant, secret Secret, replaceBehavior ReplaceBehavior) (item dbus.ObjectPath, err error) {
180206
var replace bool
181207
switch replaceBehavior {
@@ -201,6 +227,7 @@ func (s *SecretService) CreateItem(collection dbus.ObjectPath, properties map[st
201227
return item, nil
202228
}
203229

230+
// DeleteItem
204231
func (s *SecretService) DeleteItem(item dbus.ObjectPath) (err error) {
205232
var prompt dbus.ObjectPath
206233
err = s.Obj(item).
@@ -216,6 +243,7 @@ func (s *SecretService) DeleteItem(item dbus.ObjectPath) (err error) {
216243
return nil
217244
}
218245

246+
// GetAttributes
219247
func (s *SecretService) GetAttributes(item dbus.ObjectPath) (attributes Attributes, err error) {
220248
attributesV, err := s.Obj(item).GetProperty("org.freedesktop.Secret.Item.Attributes")
221249
if err != nil {
@@ -228,6 +256,7 @@ func (s *SecretService) GetAttributes(item dbus.ObjectPath) (attributes Attribut
228256
return Attributes(attributesMap), nil
229257
}
230258

259+
// GetSecret
231260
func (s *SecretService) GetSecret(item dbus.ObjectPath, session Session) (secretPlaintext []byte, err error) {
232261
var secretI []interface{}
233262
err = s.Obj(item).
@@ -258,8 +287,10 @@ func (s *SecretService) GetSecret(item dbus.ObjectPath, session Session) (secret
258287
return secretPlaintext, nil
259288
}
260289

290+
// NullPrompt
261291
const NullPrompt = "/"
262292

293+
// Unlock
263294
func (s *SecretService) Unlock(items []dbus.ObjectPath) (err error) {
264295
var dummy []dbus.ObjectPath
265296
var prompt dbus.ObjectPath
@@ -276,6 +307,7 @@ func (s *SecretService) Unlock(items []dbus.ObjectPath) (err error) {
276307
return nil
277308
}
278309

310+
// LockItems
279311
func (s *SecretService) LockItems(items []dbus.ObjectPath) (err error) {
280312
var dummy []dbus.ObjectPath
281313
var prompt dbus.ObjectPath
@@ -292,10 +324,12 @@ func (s *SecretService) LockItems(items []dbus.ObjectPath) (err error) {
292324
return nil
293325
}
294326

327+
// PromptDismissedError
295328
type PromptDismissedError struct {
296329
err error
297330
}
298331

332+
// Error
299333
func (p PromptDismissedError) Error() string {
300334
return p.err.Error()
301335
}
@@ -336,13 +370,15 @@ func (s *SecretService) PromptAndWait(prompt dbus.ObjectPath) (paths *dbus.Varia
336370
}
337371
}
338372

373+
// NewSecretProperties
339374
func NewSecretProperties(label string, attributes map[string]string) map[string]dbus.Variant {
340375
return map[string]dbus.Variant{
341376
"org.freedesktop.Secret.Item.Label": dbus.MakeVariant(label),
342377
"org.freedesktop.Secret.Item.Attributes": dbus.MakeVariant(attributes),
343378
}
344379
}
345380

381+
// NewSecret
346382
func (session *Session) NewSecret(secretBytes []byte) (Secret, error) {
347383
switch session.Mode {
348384
case AuthenticationInsecurePlain:

0 commit comments

Comments
 (0)