Ejemplo n.º 1
0
        public async Task Get_tokens()
        {
            using var svc = CreateWsHubService();
            var cli    = new WsHubManagementClient(svc.ListenUri, TestAdminWsToken);
            var tokens = await cli.GetTokens();

            tokens.Should().Contain(x => x.Token == TestAdminWsToken);
        }
Ejemplo n.º 2
0
        public async Task Delete_token()
        {
            using var svc = CreateWsHubService();
            var cli = new WsHubManagementClient(svc.ListenUri, TestAdminWsToken);
            await cli.DeleteToken(TestAdminWsToken);

            (await cli.GetTokens()).Should().BeNull();
            cli = new WsHubManagementClient(svc.ListenUri, WsToken1);
            var tokens = await cli.GetTokens();

            tokens.Should().NotContain(x => x.Token == TestAdminWsToken);
        }
Ejemplo n.º 3
0
        public async Task Upsert_token()
        {
            using var svc = CreateWsHubService();
            var cli = new WsHubManagementClient(svc.ListenUri, TestAdminWsToken);
            await cli.UpsertToken(new AuthToken
            {
                Token       = "service-token",
                Roles       = "Service",
                ServiceName = "Test Service"
            });

            (await cli.GetTokens()).Should().Contain(x =>
                                                     x.Token == "service-token" && x.Roles == "Service" && x.ServiceName == "Test Service");
            await cli.UpsertToken(new AuthToken
            {
                Token       = "admin2",
                Roles       = Constants.WsHub.Roles.Admin,
                ServiceName = "Admin 2"
            });

            cli = new WsHubManagementClient(svc.ListenUri, "admin2");
            (await cli.GetTokens()).Should().HaveCount(5);
        }