Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

neofs-cli: bugfix expire-at flag for session create command. #2546

Merged
merged 1 commit into from
Sep 6, 2023

Conversation

AliceInHunterland
Copy link
Contributor

Added check of passing --lifetime flag by the user and handling of setting defaultLifetime value

Closes #2539.

@codecov
Copy link

codecov bot commented Sep 5, 2023

Codecov Report

Merging #2546 (220efec) into master (9871712) will increase coverage by 0.00%.
Report is 2 commits behind head on master.
The diff coverage is n/a.

❗ Current head 220efec differs from pull request most recent head a43f240. Consider uploading reports for the commit a43f240 to get more accurate results

@@           Coverage Diff           @@
##           master    #2546   +/-   ##
=======================================
  Coverage   29.66%   29.67%           
=======================================
  Files         405      405           
  Lines       30756    30756           
=======================================
+ Hits         9123     9126    +3     
+ Misses      20863    20861    -2     
+ Partials      770      769    -1     

see 2 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

cmd/neofs-cli/modules/session/create.go Outdated Show resolved Hide resolved
cmd/neofs-cli/modules/session/create.go Outdated Show resolved Hide resolved
cmd/neofs-cli/modules/session/create.go Outdated Show resolved Hide resolved
cmd/neofs-cli/modules/session/create.go Outdated Show resolved Hide resolved

exp, _ := cmd.Flags().GetUint64(commonflags.ExpireAt)
lifetime := uint64(defaultLifetime)
if lfArg, _ := cmd.Flags().GetUint64(commonflags.Lifetime); lfArg != 0 {
exp = currEpoch + lfArg
if cmd.Flags().Changed(commonflags.Lifetime) {
Copy link
Contributor

@cthulhu-rider cthulhu-rider Sep 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IINW may be shortened to

	var exp uint64
	if cmd.Flags().Changed(commonflags.ExpireAt) {
		// Cobra guarantees that commonflags.Lifetime is unset then (see init)
		exp, _ = cmd.Flags().GetUint64(commonflags.ExpireAt)
		if exp <= currEpoch {
			common.ExitOnErr(cmd, "", errors.New("expiration epoch must be greater than current epoch"))
		}
	} else {
		lifetime, _ := cmd.Flags().GetUint64(commonflags.Lifetime)
		exp = currEpoch + lifetime
	}
	var tok session.Object

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we also need a check of passing --lifetime 0

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggest to add separate check for this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if exp <= currEpoch {
			common.ExitOnErr(cmd, "", errors.New("expiration epoch must be greater than current epoch"))
		}

this should be enough, no?

Copy link
Contributor

@cthulhu-rider cthulhu-rider Sep 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

technically enough, but smth like lifetime must not be zero would be more clearer, right?

i'm ok to leave if exp <= currEpoch check below as before cuz it doesn't directly related to the bug. But if u find such clarification worthy - add new commit

CHANGELOG.md Outdated
@@ -39,6 +39,7 @@ minor release, the component will be purged, so be prepared (see `Updating` sect
- `neofs-lens write-cache list` command duplication (#2505)
- `neofs-adm` works with contract wallet in `init` and `update-contracts` commands only (#2134)
- Missing removed but locked objects in `SEARCH`'s results (#2526)
- `--exire-at` flag in `neofs-cli session create` command (#2539)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `--exire-at` flag in `neofs-cli session create` command (#2539)
- `--expire-at` flag in `neofs-cli session create` command (#2539)

btw was it broken in the latest release? if not, then this record is redundant

@AliceInHunterland AliceInHunterland force-pushed the bugfix/2539-expire-at-flage-check branch 2 times, most recently from 8314f6c to 2eea1e7 Compare September 5, 2023 13:25
Copy link
Member

@carpawell carpawell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commit header should not end with a period.

Added a check for changes to the lifetime flag when it's passed by the
user to prevent the settlement of the default lifetime value even if
expire-at flag passed.

Closes #2539.

Signed-off-by: Ekaterina Pavlova <[email protected]>
@roman-khimov roman-khimov merged commit 2f5e83b into master Sep 6, 2023
7 of 9 checks passed
@roman-khimov roman-khimov deleted the bugfix/2539-expire-at-flage-check branch September 6, 2023 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

expire-at param for a session token doesn't have any effect
4 participants