~nskaggs/+junk/xenial-test

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/provider/joyent/credentials_test.go

  • Committer: Nicholas Skaggs
  • Date: 2016-10-24 20:56:05 UTC
  • Revision ID: nicholas.skaggs@canonical.com-20161024205605-z8lta0uvuhtxwzwl
Initi with beta15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright 2016 Canonical Ltd.
 
2
// Licensed under the AGPLv3, see LICENCE file for details.
 
3
 
 
4
package joyent_test
 
5
 
 
6
import (
 
7
        "github.com/juju/errors"
 
8
        "github.com/juju/testing"
 
9
        jc "github.com/juju/testing/checkers"
 
10
        gc "gopkg.in/check.v1"
 
11
 
 
12
        "github.com/juju/juju/environs"
 
13
        envtesting "github.com/juju/juju/environs/testing"
 
14
)
 
15
 
 
16
type credentialsSuite struct {
 
17
        testing.IsolationSuite
 
18
        provider environs.EnvironProvider
 
19
}
 
20
 
 
21
var _ = gc.Suite(&credentialsSuite{})
 
22
 
 
23
func (s *credentialsSuite) SetUpTest(c *gc.C) {
 
24
        s.IsolationSuite.SetUpTest(c)
 
25
 
 
26
        var err error
 
27
        s.provider, err = environs.Provider("joyent")
 
28
        c.Assert(err, jc.ErrorIsNil)
 
29
}
 
30
 
 
31
func (s *credentialsSuite) TestCredentialSchemas(c *gc.C) {
 
32
        envtesting.AssertProviderAuthTypes(c, s.provider, "userpass")
 
33
}
 
34
 
 
35
func (s *credentialsSuite) TestUserPassCredentialsValid(c *gc.C) {
 
36
        envtesting.AssertProviderCredentialsValid(c, s.provider, "userpass", map[string]string{
 
37
                "sdc-user":    "sdc-user",
 
38
                "sdc-key-id":  "sdc-key-id",
 
39
                "private-key": "private-key",
 
40
                "algorithm":   "rsa-sha256",
 
41
        })
 
42
}
 
43
 
 
44
func (s *credentialsSuite) TestUserPassHiddenAttributes(c *gc.C) {
 
45
        envtesting.AssertProviderCredentialsAttributesHidden(c, s.provider, "userpass", "private-key")
 
46
}
 
47
 
 
48
func (s *credentialsSuite) TestDetectCredentialsNotFound(c *gc.C) {
 
49
        // No environment variables set, so no credentials should be found.
 
50
        _, err := s.provider.DetectCredentials()
 
51
        c.Assert(err, jc.Satisfies, errors.IsNotFound)
 
52
}