Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }