Make updateKeyValueStream reject unsupported options #3753

Merged
merged 4 commits into from Aug 21, 2017

Conversation

Projects
None yet
4 participants
Collaborator

mvo5 commented Aug 17, 2017

This also improves the tests and superseeds #3746

mvo5 added some commits Aug 17, 2017

Make tests TestConfigurePiConfigNoChange{,Un}Set more robust
The previous test was racy, i.e. on reasonable quick systems
the check for ModTime() is not precise enough to notice that
there was in fact a write. Modify the test so that the test
file can not be written anymore.
Error if updateKeyValueStream tries to set a unsupported config
The updateKeyValueStream has a concept of the known configuration
options (via allConfig). If the user tries to modify a config
option that is not part of "allConfig" error.

lgtm, but I'm sure about the change to proxy.go, it seems a fix but is not in the description of the PR

- "http": true,
- "https": true,
- "ftp": true,
+ "http_proxy": true,
@pedronis

pedronis Aug 18, 2017

Contributor

are these fixes? should the description mention them?

@zyga

zyga Aug 21, 2017

Contributor

This looks OK upon code inspection. I second @pedronis' comment though. It should be a separate commit with a description of what is going on. It seems this was just a bug all along and we didn't notice because of a bug in the updateKeyValueStream. With that fix this one surfaced.

@mvo5

mvo5 Aug 21, 2017

Collaborator

This is properly fixed and tested in #3754 - maybe we should focus on this one instead than this one here? Unfortunately removing this change will break the tests (because the bugfix in here exposes a bug in the proxy handling)

corecfg/utils_test.go
+ }
+
+ _, err := corecfg.UpdateKeyValueStream(in, supportedConfigKeys, newConfig)
+ c.Check(err, ErrorMatches, `cannot set unsupported configuration value \"unsupported-options"`)
@pedronis

pedronis Aug 18, 2017

Contributor

\ is wrong as zyga noted later

@zyga

zyga Aug 21, 2017

Contributor

Fixed

zyga approved these changes Aug 21, 2017

LGTM with my changes

- "http": true,
- "https": true,
- "ftp": true,
+ "http_proxy": true,
@pedronis

pedronis Aug 18, 2017

Contributor

are these fixes? should the description mention them?

@zyga

zyga Aug 21, 2017

Contributor

This looks OK upon code inspection. I second @pedronis' comment though. It should be a separate commit with a description of what is going on. It seems this was just a bug all along and we didn't notice because of a bug in the updateKeyValueStream. With that fix this one surfaced.

@mvo5

mvo5 Aug 21, 2017

Collaborator

This is properly fixed and tested in #3754 - maybe we should focus on this one instead than this one here? Unfortunately removing this change will break the tests (because the bugfix in here exposes a bug in the proxy handling)

corecfg/utils_test.go
+ }
+
+ _, err := corecfg.UpdateKeyValueStream(in, supportedConfigKeys, newConfig)
+ c.Check(err, ErrorMatches, `cannot set unsupported configuration value \"unsupported-options"`)
@pedronis

pedronis Aug 18, 2017

Contributor

\ is wrong as zyga noted later

@zyga

zyga Aug 21, 2017

Contributor

Fixed

codecov-io commented Aug 21, 2017

Codecov Report

Merging #3753 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3753      +/-   ##
==========================================
+ Coverage   75.83%   75.85%   +0.01%     
==========================================
  Files         399      399              
  Lines       34516    34517       +1     
==========================================
+ Hits        26176    26182       +6     
+ Misses       6478     6474       -4     
+ Partials     1862     1861       -1
Impacted Files Coverage Δ
corecfg/proxy.go 58.62% <ø> (ø) ⬆️
corecfg/utils.go 93.18% <100%> (+0.15%) ⬆️
interfaces/sorting.go 100% <0%> (+1.28%) ⬆️
cmd/snap/cmd_aliases.go 95% <0%> (+1.66%) ⬆️
corecfg/picfg.go 72.72% <0%> (+9.09%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3aed6db...9138cc2. Read the comment docs.

corecfg: fix typo in tests
Signed-off-by: Zygmunt Krynicki <me@zygoon.pl>

@pedronis pedronis merged commit b14f7fd into snapcore:master Aug 21, 2017

2 of 7 checks passed

artful-amd64 autopkgtest finished (failure)
Details
xenial-amd64 autopkgtest finished (failure)
Details
xenial-i386 autopkgtest finished (failure)
Details
xenial-ppc64el autopkgtest finished (failure)
Details
zesty-amd64 autopkgtest finished (failure)
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
yakkety-amd64 autopkgtest finished (success)
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment