Added tests for calendarwebapp.authenticator.AuthInfo
This commit is contained in:
parent
4959c67e89
commit
464c224d72
|
@ -54,12 +54,12 @@ struct AuthInfo
|
|||
string passwordHash;
|
||||
Role role;
|
||||
|
||||
bool isUser()
|
||||
bool isUser() const pure @safe nothrow
|
||||
{
|
||||
return role == Role.User;
|
||||
}
|
||||
|
||||
bool isAdmin()
|
||||
bool isAdmin() const pure @safe nothrow
|
||||
{
|
||||
return role == Role.Admin;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
@("Test MongoDBAuthenticator")
|
||||
@("MongoDBAuthenticator.checkUser")
|
||||
@system unittest
|
||||
{
|
||||
auto collection = mock!Collection;
|
||||
|
@ -52,3 +52,35 @@ public:
|
|||
authenticator.checkUser("foo", "bar").isNull.shouldBeFalse;
|
||||
authenticator.checkUser("foo", "baz").isNull.shouldBeTrue;
|
||||
}
|
||||
|
||||
@("AuthInfo.isUser success")
|
||||
@safe unittest
|
||||
{
|
||||
AuthInfo auth;
|
||||
auth.role = Role.User;
|
||||
auth.isUser.shouldBeTrue;
|
||||
}
|
||||
|
||||
@("AuthInfo.isUser failure")
|
||||
@safe unittest
|
||||
{
|
||||
AuthInfo auth;
|
||||
auth.role = Role.Admin;
|
||||
auth.isUser.shouldBeFalse;
|
||||
}
|
||||
|
||||
@("AuthInfo.isAdmin success")
|
||||
@safe unittest
|
||||
{
|
||||
AuthInfo auth;
|
||||
auth.role = Role.Admin;
|
||||
auth.isAdmin.shouldBeTrue;
|
||||
}
|
||||
|
||||
@("AuthInfo.isAdmin failure")
|
||||
@safe unittest
|
||||
{
|
||||
AuthInfo auth;
|
||||
auth.role = Role.User;
|
||||
auth.isAdmin.shouldBeFalse;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue