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

otp: add tests #1008

Merged
merged 1 commit into from
Dec 9, 2018
Merged

otp: add tests #1008

merged 1 commit into from
Dec 9, 2018

Conversation

colemickens
Copy link
Contributor

Add tests for OTP functionality. Attempt to prevent future regressions like being discussed in #1006.

Note, this won't pass until one of the proposed fixes is merged:

--- FAIL: TestCalculate (0.00s)
    otp_test.go:21: 
        	Error Trace:	otp_test.go:21
        	            				otp_test.go:26
        	Error:      	Expected nil, but got: &errors.errorString{s:"no totp entry in secret"}
        	Test:       	TestCalculate
    otp_test.go:22: 
        	Error Trace:	otp_test.go:22
        	            				otp_test.go:26
        	Error:      	Expected value not to be nil.
        	Test:       	TestCalculate
FAIL
FAIL	github.com/gopasspw/gopass/pkg/otp	0.002s

Note, a case that I expected to work is not working. It's not listed in the docs, but I was still a bit surprised:

 	check(t, pw, fmt.Sprintf("totp:%s", totpSecret)) 
 	check(t, pw, fmt.Sprintf("totp: %s", totpSecret)) 

@codecov-io
Copy link

codecov-io commented Dec 7, 2018

Codecov Report

Merging #1008 into master will decrease coverage by 0.07%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1008      +/-   ##
==========================================
- Coverage   63.64%   63.57%   -0.07%     
==========================================
  Files         172      173       +1     
  Lines        9932     9965      +33     
==========================================
+ Hits         6321     6335      +14     
- Misses       2824     2842      +18     
- Partials      787      788       +1
Impacted Files Coverage Δ
pkg/otp/otp.go 42.42% <0%> (ø)

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 90bb387...f7dce83. Read the comment docs.

@colemickens
Copy link
Contributor Author

Rebased and passing. (Not sure I agree that code coverage decreased as a result of this PR...)

cc: @dominikschulz

dominikschulz
dominikschulz previously approved these changes Dec 8, 2018
Copy link
Member

@dominikschulz dominikschulz left a comment

Choose a reason for hiding this comment

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

LGTM. Not sure if I like the check function - would prefer table based tests - but easy to refactor and ok for now.

And yes, the coverage Delta looks wrong.

Signed-off-by: Cole Mickens <[email protected]>
@colemickens
Copy link
Contributor Author

@dominikschulz Thanks for the feedback! I went ahead and fixed the structure -- I'd been meaning to switch it to table-tests.

I was going to fix the OTP code checking as well, but it seems like the change in go-kyle/twofactor is not yet sufficient to do this.

Copy link
Member

@dominikschulz dominikschulz left a comment

Choose a reason for hiding this comment

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

LGTM

@dominikschulz dominikschulz merged commit 597bbac into gopasspw:master Dec 9, 2018
pdecat pushed a commit to pdecat/gopass that referenced this pull request Dec 10, 2018
kpitt pushed a commit to kpitt/gopass that referenced this pull request Jul 21, 2022
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.

3 participants