Skip to content

Commit

Permalink
Enable SNAPPY_STORE_AUTH_DATA_FILENAME override for client auth data.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Nelson committed Jul 19, 2016
1 parent 7cedb2b commit 9eef4fe
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Before contributing you should sign [Canonical's contributor agreement](http://w

Before merging any pull request to snappy's code base we need to verify that the code functionality and quality is not degraded by that addition. In order to do that there's a set of checks that we run for each PR, some of them using external services (TravisCI and Coveralls) and others using our own CI infrastructure (integration tests and autopkgtests). The checks based on external services are run for all the pull request. We are using the [GitHub Pull Request Builder Plugin](https://github.com/jenkinsci/ghprb-plugin/blob/master/README.md) for easing the management of PRs in relation with our internal infrastructure.

Depending on the afiliation of the GitHub user submitting a PR, the following actions may happen after receiving it:
Depending on the affiliation of the GitHub user submitting a PR, the following actions may happen after receiving it:

* If the user belongs to the `ubuntu-core` organization or has been previously whitelisted, the internal downstream verification jobs will be triggered, their progress is reported in the PR's status section. Any of the users of the organization can retrigger the execution by posting a `retest this please` comment in the PR.
* For user's outside the `ubuntu-core` organization, the internal checks won't be triggered by default and the [snappy-m-o](https://github.com/snappy-m-o) user, managed by the ghrbp plugin, will post a comment "Can one of the admins verify this patch?". After this, an `ubuntu-core` admin can post one of these comments:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ To run the various tests that we have to ensure a high quality source just run:
This will check if the source format is consistent, that it build, all tests
work as expected and that "go vet" and "golint" have nothing to complain.

You can run individual test with:
You can run individual test for a sub-package by changing into that directory and:

go test -check.f $testname

Expand Down
1 change: 1 addition & 0 deletions client/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ var ParseErrorInTest = parseError
// expose read and write auth helpers for testing
var TestWriteAuth = writeAuthData
var TestReadAuth = readAuthData
var TestStoreAuthFilename = storeAuthDataFilename
4 changes: 4 additions & 0 deletions client/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ func (client *Client) LoggedIn() bool {
}

func storeAuthDataFilename() string {
authFilename := os.Getenv("SNAPPY_STORE_AUTH_DATA_FILENAME")
if authFilename != "" {
return authFilename
}
homeDir, err := osutil.CurrentHomeDir()
if err != nil {
panic(err)
Expand Down
24 changes: 24 additions & 0 deletions client/login_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,27 @@ func (cs *clientSuite) TestReadAuthData(c *check.C) {
c.Assert(err, check.IsNil)
c.Check(readUser, check.DeepEquals, &authData)
}

func (cs *clientSuite) TestStoreAuthDataFilenameDefault(c *check.C) {
home := os.Getenv("HOME")
tmpdir := c.MkDir()
os.Setenv("HOME", tmpdir)
defer os.Setenv("HOME", home)

authFilename := client.TestStoreAuthFilename()

expectedFilename := filepath.Join(tmpdir, ".snap", "auth.json")
c.Check(authFilename, check.Equals, expectedFilename)
}

func (cs *clientSuite) TestStoreAuthDataFilenameViaEnv(c *check.C) {
authFilenameOrig := os.Getenv("SNAPPY_STORE_AUTH_DATA_FILENAME")
tmpdir := c.MkDir()
expectedAuthFilename := filepath.Join(tmpdir, "auth.json")
os.Setenv("SNAPPY_STORE_AUTH_DATA_FILENAME", expectedAuthFilename)
defer os.Setenv("SNAPPY_STORE_AUTH_DATA_FILENAME", authFilenameOrig)

authFilename := client.TestStoreAuthFilename()

c.Check(authFilename, check.Equals, expectedAuthFilename)
}

0 comments on commit 9eef4fe

Please sign in to comment.