コード例 #1
0
        public async Task Request_Auth_UserNotInDatabase_Forbidden(string url)
        {
            var req = new HttpRequestMessage(HttpMethod.Get, url);
            await AccessTokenProvider.AuthenticateRequestAsUserAsync(req, Settings.UserNotInDatabase);

            var res = await Client.SendAsync(req);

            Assert.Equal(HttpStatusCode.Forbidden, res.StatusCode);
        }
コード例 #2
0
        public async Task Request_Auth_UserRegular_Pass(string url)
        {
            var req = new HttpRequestMessage(HttpMethod.Get, url);
            await AccessTokenProvider.AuthenticateRequestAsUserAsync(req, Settings.UserRegular);

            var res = await Client.SendAsync(req);

            Assert.Equal(HttpStatusCode.OK, res.StatusCode);
        }
コード例 #3
0
        public async Task CallWithUserAuthenticationSucceeds(string url)
        {
            var req = new HttpRequestMessage(HttpMethod.Get, url);
            await AccessTokenProvider.AuthenticateRequestAsUserAsync(req);

            var res = await Client.SendAsync(req);

            Assert.Equal(HttpStatusCode.OK, res.StatusCode);
        }
コード例 #4
0
        public async Task Request_Auth_UserNoRoles_CannotSignedIn(string url)
        {
            var req = new HttpRequestMessage(HttpMethod.Get, url);
            await AccessTokenProvider.AuthenticateRequestAsUserAsync(req, Settings.UserNoRoles);

            Assert.True(string.IsNullOrEmpty(req.Headers.Authorization.Parameter));
            var res = await Client.SendAsync(req);

            Assert.Equal(HttpStatusCode.Unauthorized, res.StatusCode);
        }
コード例 #5
0
        public async Task Request_Auth_UserRegular_ScopeBoth_Forbidden(string url)
        {
            var req      = new HttpRequestMessage(HttpMethod.Get, url);
            var settings = Settings.UserRegular;

            settings.Scope = Settings.WrongRolesScopesComb.Regular_ScopeBoth;
            await AccessTokenProvider.AuthenticateRequestAsUserAsync(req, settings);

            var res = await Client.SendAsync(req);

            Assert.Equal(HttpStatusCode.Forbidden, res.StatusCode);
        }