Commit 5a713d10 authored by Sietse Ringers's avatar Sietse Ringers
Browse files

refactor: remove unused parameter from ValidatePin() method

parent fb7994a3
......@@ -61,7 +61,7 @@ func (c *Core) newUserFromSecret(pinRaw string, secret *big.Int) (User, error) {
}
// ValidatePin checks pin for validity and generates JWT for future access.
func (c *Core) ValidatePin(ep User, pin string, userID string) (string, error) {
func (c *Core) ValidatePin(ep User, pin string) (string, error) {
p, err := c.decryptUserIfPinOK(ep, pin)
if err != nil {
return "", err
......
......@@ -37,7 +37,7 @@ func TestPinFunctionality(t *testing.T) {
require.NoError(t, err)
// Test with correct pin
j, err := c.ValidatePin(ep, pin, "testid")
j, err := c.ValidatePin(ep, pin)
assert.NoError(t, err)
var claims jwt.StandardClaims
_, err = jwt.ParseWithClaims(j, &claims, func(_ *jwt.Token) (interface{}, error) {
......@@ -57,11 +57,11 @@ func TestPinFunctionality(t *testing.T) {
require.NoError(t, err)
// test correct pin
_, err = c.ValidatePin(ep, newpin, "testid")
_, err = c.ValidatePin(ep, newpin)
assert.NoError(t, err)
// Test incorrect pin
_, err = c.ValidatePin(ep, pin, "testid")
_, err = c.ValidatePin(ep, pin)
assert.Error(t, err)
}
......@@ -88,7 +88,7 @@ func TestVerifyAccess(t *testing.T) {
require.NoError(t, err)
// Test use jwt on wrong packet
jwtt, err := c.ValidatePin(ep1, pin1, "testid")
jwtt, err := c.ValidatePin(ep1, pin1)
require.NoError(t, err)
_, err = c.verifyAccess(ep2, jwtt)
assert.Error(t, err)
......@@ -183,7 +183,7 @@ func TestProofFunctionality(t *testing.T) {
require.NoError(t, err)
// Validate pin
jwtt, err := c.ValidatePin(ep, pin, "testid")
jwtt, err := c.ValidatePin(ep, pin)
require.NoError(t, err)
// Get keyshare commitment
......@@ -232,7 +232,7 @@ func TestCorruptedPacket(t *testing.T) {
ep, err := c.NewUser(pin)
require.NoError(t, err)
jwtt, err := c.ValidatePin(ep, pin, "testid")
jwtt, err := c.ValidatePin(ep, pin)
require.NoError(t, err)
_, commitID, err := c.GenerateCommitments(ep, jwtt, []irma.PublicKeyIdentifier{irma.PublicKeyIdentifier{Issuer: irma.NewIssuerIdentifier("test"), Counter: 1}})
......@@ -242,7 +242,7 @@ func TestCorruptedPacket(t *testing.T) {
ep[12] = ep[12] + 1
// Verify pin
_, err = c.ValidatePin(ep, pin, "testid")
_, err = c.ValidatePin(ep, pin)
assert.Error(t, err, "ValidatePin accepts corrupted keyshare packet")
// Change pin
......@@ -277,7 +277,7 @@ func TestIncorrectPin(t *testing.T) {
require.NoError(t, err)
// validate pin
jwtt, err := c.ValidatePin(ep, pin, "testid")
jwtt, err := c.ValidatePin(ep, pin)
require.NoError(t, err)
// Corrupt pin
......@@ -314,7 +314,7 @@ func TestMissingKey(t *testing.T) {
require.NoError(t, err)
// Generate jwt
jwtt, err := c.ValidatePin(ep, pin, "testid")
jwtt, err := c.ValidatePin(ep, pin)
require.NoError(t, err)
// GenerateCommitments
......@@ -347,7 +347,7 @@ func TestInvalidChallenge(t *testing.T) {
require.NoError(t, err)
// Validate pin
jwtt, err := c.ValidatePin(ep, pin, "testid")
jwtt, err := c.ValidatePin(ep, pin)
require.NoError(t, err)
// Test negative challenge
......@@ -388,7 +388,7 @@ func TestDoubleCommitUse(t *testing.T) {
require.NoError(t, err)
// validate pin
jwtt, err := c.ValidatePin(ep, pin, "testid")
jwtt, err := c.ValidatePin(ep, pin)
require.NoError(t, err)
// Use commit double
......@@ -419,7 +419,7 @@ func TestNonExistingCommit(t *testing.T) {
require.NoError(t, err)
// Generate jwt
jwtt, err := c.ValidatePin(ep, pin, "testid")
jwtt, err := c.ValidatePin(ep, pin)
require.NoError(t, err)
// test
......
......@@ -297,7 +297,7 @@ func (s *Server) handleVerifyPin(w http.ResponseWriter, r *http.Request) {
}
// and verify pin
result, err := s.verifyPin(user, msg.Username, msg.Pin)
result, err := s.verifyPin(user, msg.Pin)
if err != nil {
// already logged
server.WriteError(w, server.ErrorInternal, err.Error())
......@@ -307,7 +307,7 @@ func (s *Server) handleVerifyPin(w http.ResponseWriter, r *http.Request) {
server.WriteJson(w, result)
}
func (s *Server) verifyPin(user *User, username, pin string) (irma.KeysharePinStatus, error) {
func (s *Server) verifyPin(user *User, pin string) (irma.KeysharePinStatus, error) {
// Check whether pin check is currently allowed
ok, tries, wait, err := s.reservePinCheck(user, pin)
if err != nil {
......@@ -318,7 +318,7 @@ func (s *Server) verifyPin(user *User, username, pin string) (irma.KeysharePinSt
}
// At this point, we are allowed to do an actual check (we have successfully reserved a spot for it), so do it.
jwtt, err := s.core.ValidatePin(user.UserData, pin, username)
jwtt, err := s.core.ValidatePin(user.UserData, pin)
if err != nil && err != keysharecore.ErrInvalidPin {
// Errors other than invalid pin are real errors
s.conf.Logger.WithField("error", err).Error("Could not validate pin")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment