コード例 #1
0
        public void Setup()
        {
            var config = A.Fake <IConfiguration>();

            userDataService = A.Fake <IUserDataService>();
            learningHubSsoSecurityService = A.Fake <ILearningHubSsoSecurityService>();

            A.CallTo(() => config["LearningHubSSO:BaseUrl"]).Returns("www.example.com");
            A.CallTo(() => config["LearningHubSSO:ClientCode"]).Returns("test");
            A.CallTo(() => config["LearningHubSSO:LoginEndpoint"]).Returns("/insert-log");
            A.CallTo(() => config["LearningHubSSO:LinkingEndpoint"]).Returns("/to-the-past");

            A.CallTo(() => learningHubSsoSecurityService.VerifyHash("56789", "invalid-hash")).Returns(false);
            A.CallTo(() => learningHubSsoSecurityService.VerifyHash("12345", "valid-hash")).Returns(true);
            A.CallTo(() => learningHubSsoSecurityService.GenerateHash(A <string> ._)).Returns("hash_brown");

            learningHubLinkService = new LearningHubLinkService(learningHubSsoSecurityService, userDataService, config);
        }
コード例 #2
0
        private void ValidateLearningHubUserId(LinkLearningHubRequest linkLearningHubRequest)
        {
            var isVerified = learningHubSsoSecurityService.VerifyHash(
                linkLearningHubRequest.UserId.ToString(),
                linkLearningHubRequest.Hash
                );

            if (!isVerified)
            {
                throw new LearningHubLinkingRequestException("Invalid Learning Hub UserId hash.");
            }
        }