Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
packer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kristopher Ruzic
packer
Commits
46d297c7
Commit
46d297c7
authored
Dec 12, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/googlecompute: client secrets tests
parent
6507afd3
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
0 deletions
+33
-0
builder/googlecompute/client_secrets.go
builder/googlecompute/client_secrets.go
+2
-0
builder/googlecompute/client_secrets_test.go
builder/googlecompute/client_secrets_test.go
+31
-0
No files found.
builder/googlecompute/client_secrets.go
View file @
46d297c7
...
...
@@ -22,9 +22,11 @@ func loadClientSecrets(path string) (*clientSecrets, error) {
if
err
!=
nil
{
return
nil
,
err
}
err
=
json
.
Unmarshal
(
secretBytes
,
&
cs
)
if
err
!=
nil
{
return
nil
,
err
}
return
cs
,
nil
}
builder/googlecompute/client_secrets_test.go
0 → 100644
View file @
46d297c7
package
googlecompute
import
(
"io/ioutil"
"testing"
)
func
testClientSecretsFile
(
t
*
testing
.
T
)
string
{
tf
,
err
:=
ioutil
.
TempFile
(
""
,
"packer"
)
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
defer
tf
.
Close
()
if
_
,
err
:=
tf
.
Write
([]
byte
(
testClientSecretsContent
));
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
return
tf
.
Name
()
}
func
TestLoadClientSecrets
(
t
*
testing
.
T
)
{
_
,
err
:=
loadClientSecrets
(
testClientSecretsFile
(
t
))
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
}
// This is just some dummy data that doesn't actually work (it was revoked
// a long time ago).
const
testClientSecretsContent
=
`{"web":{"auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://accounts.google.com/o/oauth2/token","client_email":"774313886706-eorlsj0r4eqkh5e7nvea5fuf59ifr873@developer.gserviceaccount.com","client_x509_cert_url":"https://www.googleapis.com/robot/v1/metadata/x509/774313886706-eorlsj0r4eqkh5e7nvea5fuf59ifr873@developer.gserviceaccount.com","client_id":"774313886706-eorlsj0r4eqkh5e7nvea5fuf59ifr873.apps.googleusercontent.com","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs"}}`
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment