Ejemplo n.º 1
0
        public void HeaderProvider_ThrowsArgumentException_SigningKeyNull()
        {
            var config = new SimpleJwtProviderConfig();

            config.SigningKey = null;

            Assert.Throws <ArgumentException>(() => new HeaderProvider <TestHeaderCreator>(config));
        }
Ejemplo n.º 2
0
        public void HeaderProviderWithHmacFactory_ReturnsHmacSignedKey()
        {
            var config = new SimpleJwtProviderConfig();

            config.SigningKey = "ThisIsMyIncrediblyDifficultHMACSigningKeyUsedInTests!";
            var provider = new HeaderProvider <HMACHeaderCreator>(config);

            var header = provider.GetHeader();

            Assert.Equal("HS256", header.Alg);
        }
Ejemplo n.º 3
0
        public void HeaderProviderWithRsaFactory_ReturnsRsaSignedKey()
        {
            var keyPath = Path.GetFullPath("..\\..\\..\\TstCertificate\\private-rsa.xml");
            var config  = new SimpleJwtProviderConfig();

            config.SigningKey = keyPath;
            var provider = new HeaderProvider <RSAHeaderCreator>(config);

            var header = provider.GetHeader();

            Assert.Equal("RS256", header.Alg);
        }
Ejemplo n.º 4
0
        public HeaderProvider(SimpleJwtProviderConfig config)
        {
            if (config == null)
            {
                throw new ArgumentNullException(typeof(SimpleJwtProviderConfig).ToString());
            }
            if (string.IsNullOrEmpty(config.SigningKey))
            {
                throw new ArgumentException("Signing key is null or empty!");
            }

            this._config   = config;
            this._provider = new T();
        }