forked from jarias/stormpath-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
credentials_test.go
36 lines (31 loc) · 1.21 KB
/
credentials_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package stormpath_test
import (
. "github.com/jarias/stormpath-sdk-go"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Credentials", func() {
It("should load the API credentials from a valid file", func() {
credentials, err := NewCredentialsFromFile("./test_files/apiKeys.properties")
Expect(err).NotTo(HaveOccurred())
Expect(credentials.ID).To(Equal("APIKEY"))
Expect(credentials.Secret).To(Equal("APISECRET"))
})
It("should return an error loading credentials from a unexisting file", func() {
credentials, err := NewCredentialsFromFile("./test_files/doesntexist.properties")
Expect(err).To(HaveOccurred())
Expect(credentials).To(Equal(Credentials{}))
})
It("should load empty credentials from an empty properties file", func() {
credentials, err := NewCredentialsFromFile("./test_files/empty.properties")
Expect(err).NotTo(HaveOccurred())
Expect(credentials.ID).To(BeEmpty())
Expect(credentials.Secret).To(BeEmpty())
})
It("should load the API credentials from a default file location", func() {
credentials, err := NewDefaultCredentials()
Expect(err).NotTo(HaveOccurred())
Expect(credentials.ID).NotTo(BeEmpty())
Expect(credentials.Secret).NotTo(BeEmpty())
})
})