mirror of
https://github.com/arun11299/cpp-jwt.git
synced 2025-05-14 16:58:34 +00:00
Fixed many warnings that appear due to assert not being executed in
release mode.
This commit is contained in:
parent
9ff6e50b5e
commit
00343347b2
4 changed files with 13 additions and 9 deletions
|
@ -37,12 +37,10 @@ int main() {
|
||||||
|
|
||||||
//Using `add_claim` with extra features.
|
//Using `add_claim` with extra features.
|
||||||
//Check return status and overwrite
|
//Check return status and overwrite
|
||||||
bool ret = obj.payload().add_claim("sub", "new test", false/*overwrite*/);
|
assert (not obj.payload().add_claim("sub", "new test", false/*overwrite*/));
|
||||||
assert (not ret);
|
|
||||||
|
|
||||||
// Overwrite an existing claim
|
// Overwrite an existing claim
|
||||||
ret = obj.payload().add_claim("sub", "new test", true/*overwrite*/);
|
assert (obj.payload().add_claim("sub", "new test", true/*overwrite*/));
|
||||||
assert ( ret );
|
|
||||||
|
|
||||||
assert (obj.payload().has_claim_with_value("sub", "new test"));
|
assert (obj.payload().has_claim_with_value("sub", "new test"));
|
||||||
|
|
||||||
|
|
|
@ -211,6 +211,7 @@ enum class algorithm
|
||||||
ES256,
|
ES256,
|
||||||
ES384,
|
ES384,
|
||||||
ES512,
|
ES512,
|
||||||
|
UNKN,
|
||||||
TERM,
|
TERM,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -233,9 +234,10 @@ inline jwt::string_view alg_to_str(enum algorithm alg) noexcept
|
||||||
case algorithm::ES512: return "ES512";
|
case algorithm::ES512: return "ES512";
|
||||||
case algorithm::TERM: return "TERM";
|
case algorithm::TERM: return "TERM";
|
||||||
case algorithm::NONE: return "NONE";
|
case algorithm::NONE: return "NONE";
|
||||||
|
case algorithm::UNKN: return "UNKN";
|
||||||
default: assert (0 && "Unknown Algorithm");
|
default: assert (0 && "Unknown Algorithm");
|
||||||
};
|
};
|
||||||
|
return "UNKN";
|
||||||
assert (0 && "Code not reached");
|
assert (0 && "Code not reached");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,6 +260,8 @@ inline enum algorithm str_to_alg(const jwt::string_view alg) noexcept
|
||||||
if (!strcasecmp(alg.data(), "es384")) return algorithm::ES384;
|
if (!strcasecmp(alg.data(), "es384")) return algorithm::ES384;
|
||||||
if (!strcasecmp(alg.data(), "es512")) return algorithm::ES512;
|
if (!strcasecmp(alg.data(), "es512")) return algorithm::ES512;
|
||||||
|
|
||||||
|
return algorithm::UNKN;
|
||||||
|
|
||||||
assert (0 && "Code not reached");
|
assert (0 && "Code not reached");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ struct AlgorithmErrCategory: std::error_category
|
||||||
case AlgorithmErrc::NoneAlgorithmUsed:
|
case AlgorithmErrc::NoneAlgorithmUsed:
|
||||||
return "none algorithm used";
|
return "none algorithm used";
|
||||||
};
|
};
|
||||||
|
return "unknown algorithm error";
|
||||||
assert (0 && "Code not reached");
|
assert (0 && "Code not reached");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -86,7 +86,7 @@ struct DecodeErrorCategory: std::error_category
|
||||||
case DecodeErrc::KeyNotRequiredForNoneAlg:
|
case DecodeErrc::KeyNotRequiredForNoneAlg:
|
||||||
return "key not required for NONE algorithm";
|
return "key not required for NONE algorithm";
|
||||||
};
|
};
|
||||||
|
return "unknown decode error";
|
||||||
assert (0 && "Code not reached");
|
assert (0 && "Code not reached");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -125,7 +125,7 @@ struct VerificationErrorCategory: std::error_category
|
||||||
case VerificationErrc::TypeConversionError:
|
case VerificationErrc::TypeConversionError:
|
||||||
return "type conversion error";
|
return "type conversion error";
|
||||||
};
|
};
|
||||||
|
return "unknown verification error";
|
||||||
assert (0 && "Code not reached");
|
assert (0 && "Code not reached");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -64,6 +64,8 @@ inline enum type str_to_type(const jwt::string_view typ) noexcept
|
||||||
|
|
||||||
if (!strcasecmp(typ.data(), "jwt")) return type::JWT;
|
if (!strcasecmp(typ.data(), "jwt")) return type::JWT;
|
||||||
|
|
||||||
|
throw std::runtime_error("Unknown token type");
|
||||||
|
|
||||||
assert (0 && "Code not reached");
|
assert (0 && "Code not reached");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +123,7 @@ inline jwt::string_view reg_claims_to_str(enum registered_claims claim) noexcept
|
||||||
case registered_claims::jti: return "jti";
|
case registered_claims::jti: return "jti";
|
||||||
default: assert (0 && "Not a registered claim");
|
default: assert (0 && "Not a registered claim");
|
||||||
};
|
};
|
||||||
|
return "";
|
||||||
assert (0 && "Code not reached");
|
assert (0 && "Code not reached");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue