"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "pkg/cmd/secret/set/set_test.go" between
gh-cli-1.10.3.tar.gz and gh-cli-1.11.0.tar.gz

About: GitHub CLI is GitHub’s official command line tool.

set_test.go  (gh-cli-1.10.3):set_test.go  (gh-cli-1.11.0)
skipping to change at line 104 skipping to change at line 104
name: "repo", name: "repo",
cli: `cool_secret -b"a secret"`, cli: `cool_secret -b"a secret"`,
wants: SetOptions{ wants: SetOptions{
SecretName: "cool_secret", SecretName: "cool_secret",
Visibility: shared.Private, Visibility: shared.Private,
Body: "a secret", Body: "a secret",
OrgName: "", OrgName: "",
}, },
}, },
{ {
name: "env",
cli: `cool_secret -b"a secret" -eRelease`,
wants: SetOptions{
SecretName: "cool_secret",
Visibility: shared.Private,
Body: "a secret",
OrgName: "",
EnvName: "Release",
},
},
{
name: "vis all", name: "vis all",
cli: `cool_secret --org coolOrg -b"cool" -vall`, cli: `cool_secret --org coolOrg -b"cool" -vall`,
wants: SetOptions{ wants: SetOptions{
SecretName: "cool_secret", SecretName: "cool_secret",
Visibility: shared.All, Visibility: shared.All,
Body: "cool", Body: "cool",
OrgName: "coolOrg", OrgName: "coolOrg",
}, },
}, },
{ {
skipping to change at line 163 skipping to change at line 174
if tt.wantsErr { if tt.wantsErr {
assert.Error(t, err) assert.Error(t, err)
return return
} }
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, tt.wants.SecretName, gotOpts.SecretName) assert.Equal(t, tt.wants.SecretName, gotOpts.SecretName)
assert.Equal(t, tt.wants.Body, gotOpts.Body) assert.Equal(t, tt.wants.Body, gotOpts.Body)
assert.Equal(t, tt.wants.Visibility, gotOpts.Visibility) assert.Equal(t, tt.wants.Visibility, gotOpts.Visibility)
assert.Equal(t, tt.wants.OrgName, gotOpts.OrgName) assert.Equal(t, tt.wants.OrgName, gotOpts.OrgName)
assert.Equal(t, tt.wants.EnvName, gotOpts.EnvName)
assert.ElementsMatch(t, tt.wants.RepositoryNames, gotOpts .RepositoryNames) assert.ElementsMatch(t, tt.wants.RepositoryNames, gotOpts .RepositoryNames)
}) })
} }
} }
func Test_setRun_repo(t *testing.T) { func Test_setRun_repo(t *testing.T) {
reg := &httpmock.Registry{} reg := &httpmock.Registry{}
reg.Register(httpmock.REST("GET", "repos/owner/repo/actions/secrets/publi c-key"), reg.Register(httpmock.REST("GET", "repos/owner/repo/actions/secrets/publi c-key"),
httpmock.JSONResponse(PubKey{ID: "123", Key: "CDjXqf7AJBXWhMczcy+ Fs7JlACEptgceysutztHaFQI="})) httpmock.JSONResponse(PubKey{ID: "123", Key: "CDjXqf7AJBXWhMczcy+ Fs7JlACEptgceysutztHaFQI="}))
skipping to change at line 196 skipping to change at line 208
IO: io, IO: io,
SecretName: "cool_secret", SecretName: "cool_secret",
Body: "a secret", Body: "a secret",
// Cribbed from https://github.com/golang/crypto/commit/becbf705a 91575484002d598f87d74f0002801e7 // Cribbed from https://github.com/golang/crypto/commit/becbf705a 91575484002d598f87d74f0002801e7
RandomOverride: bytes.NewReader([]byte{5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5}), RandomOverride: bytes.NewReader([]byte{5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5}),
} }
err := setRun(opts) err := setRun(opts)
assert.NoError(t, err) assert.NoError(t, err)
reg.Verify(t)
data, err := ioutil.ReadAll(reg.Requests[1].Body)
assert.NoError(t, err)
var payload SecretPayload
err = json.Unmarshal(data, &payload)
assert.NoError(t, err)
assert.Equal(t, payload.KeyID, "123")
assert.Equal(t, payload.EncryptedValue, "UKYUCbHd0DJemxa3AOcZ6XcsBwALG9d4
bpB8ZT0gSV39vl3BHiGSgj8zJapDxgB2BwqNqRhpjC4=")
}
func Test_setRun_env(t *testing.T) {
reg := &httpmock.Registry{}
reg.Register(httpmock.REST("GET", "repos/owner/repo/actions/secrets/publi
c-key"),
httpmock.JSONResponse(PubKey{ID: "123", Key: "CDjXqf7AJBXWhMczcy+
Fs7JlACEptgceysutztHaFQI="}))
reg.Register(httpmock.REST("PUT", "repos/owner/repo/environments/developm
ent/secrets/cool_secret"), httpmock.StatusStringResponse(201, `{}`))
io, _, _, _ := iostreams.Test()
opts := &SetOptions{
HttpClient: func() (*http.Client, error) {
return &http.Client{Transport: reg}, nil
},
Config: func() (config.Config, error) { return config.NewBlankCon
fig(), nil },
BaseRepo: func() (ghrepo.Interface, error) {
return ghrepo.FromFullName("owner/repo")
},
EnvName: "development",
IO: io,
SecretName: "cool_secret",
Body: "a secret",
// Cribbed from https://github.com/golang/crypto/commit/becbf705a
91575484002d598f87d74f0002801e7
RandomOverride: bytes.NewReader([]byte{5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5}),
}
err := setRun(opts)
assert.NoError(t, err)
reg.Verify(t) reg.Verify(t)
data, err := ioutil.ReadAll(reg.Requests[1].Body) data, err := ioutil.ReadAll(reg.Requests[1].Body)
assert.NoError(t, err) assert.NoError(t, err)
var payload SecretPayload var payload SecretPayload
err = json.Unmarshal(data, &payload) err = json.Unmarshal(data, &payload)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, payload.KeyID, "123") assert.Equal(t, payload.KeyID, "123")
assert.Equal(t, payload.EncryptedValue, "UKYUCbHd0DJemxa3AOcZ6XcsBwALG9d4 bpB8ZT0gSV39vl3BHiGSgj8zJapDxgB2BwqNqRhpjC4=") assert.Equal(t, payload.EncryptedValue, "UKYUCbHd0DJemxa3AOcZ6XcsBwALG9d4 bpB8ZT0gSV39vl3BHiGSgj8zJapDxgB2BwqNqRhpjC4=")
} }
 End of changes. 3 change blocks. 
0 lines changed or deleted 59 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)