-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removes coroutine and WinRT related headers, Updates stubs methods Removes no longer relevant test for user id size No test should isntantiate production Context
- Loading branch information
1 parent
23084ab
commit 58d95c0
Showing
3 changed files
with
57 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,41 +8,42 @@ namespace StoreApi { | |
|
||
using namespace ::testing; | ||
|
||
TEST(UserInfo, PredictableSizes) { | ||
auto user = UserInfo::Current().get(); | ||
auto size = user.id.size(); | ||
EXPECT_TRUE(size == 0 || size == 64) | ||
<< "User ID of unexpected size: " << size << " <" | ||
<< winrt::to_string(user.id) << '\n'; | ||
TEST(ServerStoreService, NoUsersLikeInCI) { | ||
auto service = ServerStoreService<NoUsers>{}; | ||
EXPECT_THROW({auto user = service.CurrentUserInfo();}, Exception); | ||
} | ||
|
||
TEST(ServerStoreService, TooManyUsers) { | ||
auto service = ServerStoreService<TooManyUsersContext>{}; | ||
EXPECT_THROW({auto user = service.CurrentUserInfo();}, Exception); | ||
} | ||
|
||
TEST(ServerStoreService, FindOneUser) { | ||
static constexpr char goodHash[] = "goodHash"; | ||
auto service = ServerStoreService<FindOneUser>{}; | ||
FindOneUser::goodHash = goodHash; | ||
auto user = service.CurrentUserInfo(); | ||
EXPECT_EQ(user.id, goodHash); | ||
} | ||
|
||
TEST(ServerStoreService, EmptyJwtThrows) { | ||
auto service = ServerStoreService<EmptyJwtContext>{}; | ||
UserInfo user{.id = L"[email protected]"}; | ||
UserInfo user{.id = "[email protected]"}; | ||
EXPECT_THROW( | ||
{ | ||
auto jwt = service.GenerateUserJwt("this-is-a-web-token", user).get(); | ||
auto jwt = service.GenerateUserJwt("this-is-a-web-token", user); | ||
}, | ||
Exception); | ||
} | ||
|
||
TEST(ServerStoreService, NonEmptyJwtNeverThrows) { | ||
auto service = ServerStoreService<IdentityJwtContext>{}; | ||
UserInfo user{.id = L"[email protected]"}; | ||
UserInfo user{.id = "[email protected]"}; | ||
std::string token{"this-is-a-web-token"}; | ||
auto jwt = service.GenerateUserJwt(token, user).get(); | ||
auto jwt = service.GenerateUserJwt(token, user); | ||
EXPECT_EQ(token, jwt); | ||
} | ||
|
||
TEST(ServerStoreService, RealServerFailsUnderTest) { | ||
auto service = ServerStoreService{}; | ||
UserInfo user{.id = L"[email protected]"}; | ||
std::string token{"this-is-a-web-token"}; | ||
// This fails because the test is not an app deployed through the store. | ||
EXPECT_THROW({ auto jwt = service.GenerateUserJwt(token, user).get(); }, | ||
Exception); | ||
} | ||
|
||
TEST(ServerStoreService, ExpirationDateUnsubscribed) { | ||
auto service = ServerStoreService<NeverSubscribedContext>{}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters