Example #1
0
        public void AuthorizationQuertStringFailTest()
        {
            IServiceCollection serviceDescriptors = new ServiceCollection();

            serviceDescriptors.Configure <JT808Configuration>((options) => { });
            var options = serviceDescriptors.BuildServiceProvider().GetRequiredService <IOptionsMonitor <JT808Configuration> >();
            JT808AuthorizationDefault jT808AuthorizationDefault = new JT808AuthorizationDefault(options);
            var m = new DefaultFullHttpRequest(HttpVersion.Http11, HttpMethod.Get, "/demo?token=12345");

            Assert.False(jT808AuthorizationDefault.Authorization(m, out var principal));
        }
Example #2
0
        public void AuthorizationHeaderTest()
        {
            IServiceCollection serviceDescriptors = new ServiceCollection();

            serviceDescriptors.Configure <JT808Configuration>((options) => { });
            var options = serviceDescriptors.BuildServiceProvider().GetRequiredService <IOptionsMonitor <JT808Configuration> >();
            JT808AuthorizationDefault jT808AuthorizationDefault = new JT808AuthorizationDefault(options);
            var m = new DefaultFullHttpRequest(HttpVersion.Http11, HttpMethod.Get, "/");

            m.Headers.Add((AsciiString)"token", "123456");
            Assert.True(jT808AuthorizationDefault.Authorization(m, out var principal));
        }