示例#1
0
 public DiscourseController(DiscourseService discourseService, UserManager <User> userManager,
                            RoleManager <Role> roleManager, IAuthorizationService authorizationService)
 {
     _discourseService     = discourseService;
     _userManager          = userManager;
     _roleManager          = roleManager;
     _authorizationService = authorizationService;
 }
        public void PayloadExtracted(string sso, string sig, string nonce, string secret)
        {
            var opts = A.Fake <IOptionsMonitor <DiscourseService.Options> >();

            A.CallTo(() => opts.CurrentValue).Returns(new DiscourseService.Options {
                Secret = secret
            });
            var service =
                new DiscourseService(opts);
            var result = service.OpenPayload(sso, sig);

            result.nonce.Should().BeEquivalentTo(nonce);
        }
        public void PayloadCreated()
        {
            var opts = A.Fake <IOptionsMonitor <DiscourseService.Options> >();

            A.CallTo(() => opts.CurrentValue).Returns(new DiscourseService.Options
            {
                Secret = "d836444a9e4084d5b224a60c208dce14"
            });
            var service = new DiscourseService(opts);
            var result  = service.CreatePayload("cb68251eefb5211e58c00ff1395f0c0b",
                                                "*****@*****.**",
                                                "hello123",
                                                "samsam",
                                                "sam",
                                                emailRequireActivation: true
                                                );

            result.payload.Should()
            .Be(
                "bm9uY2U9Y2I2ODI1MWVlZmI1MjExZTU4YzAwZmYxMzk1ZjBjMGImZW1haWw9dGVzdCU0MHRlc3QuY29tJmV4dGVybmFsX2lkPWhlbGxvMTIzJnVzZXJuYW1lPXNhbXNhbSZuYW1lPXNhbSZyZXF1aXJlX2FjdGl2YXRpb249dHJ1ZQ==");
            result.signature.Should().Be("19d360ba4bb346c06ec7fd40702960bb60588c997ecdae14e65ffb6298cc33eb");
        }