✨ MAJOR FEATURES: • Auto-zoom intelligence với smart bounds fitting • Enhanced 3D GPS markers với pulsing effects • Professional route display với 6-layer rendering • Status-based parking icons với availability indicators • Production-ready build optimizations 🗺️ AUTO-ZOOM FEATURES: • Smart bounds fitting cho GPS + selected parking • Adaptive padding (50px) cho visual balance • Max zoom control (level 16) để tránh quá gần • Dynamic centering khi không có selection 🎨 ENHANCED VISUALS: • 3D GPS marker với multi-layer pulse effects • Advanced parking icons với status colors • Selection highlighting với animation • Dimming system cho non-selected items 🛣️ ROUTE SYSTEM: • OpenRouteService API integration • Multi-layer route rendering (glow, shadow, main, animated) • Real-time distance & duration calculation • Visual route info trong popup 📱 PRODUCTION READY: • SSR safe với dynamic imports • Build errors resolved • Global deployment via Vercel • Optimized performance 🌍 DEPLOYMENT: • Vercel: https://whatever-ctk2auuxr-phong12hexdockworks-projects.vercel.app • Bundle size: 22.8 kB optimized • Global CDN distribution • HTTPS enabled 💾 VERSION CONTROL: • MapView-v2.0.tsx backup created • MAPVIEW_VERSIONS.md documentation • Full version history tracking
125 lines
3.4 KiB
JavaScript
125 lines
3.4 KiB
JavaScript
var Strategy = require('../lib/strategy')
|
|
, chai = require('chai')
|
|
, sinon = require('sinon')
|
|
, test_data= require('./testdata')
|
|
, url = require('url')
|
|
, extract_jwt = require('../lib/extract_jwt')
|
|
|
|
|
|
describe('Strategy', function() {
|
|
|
|
var mockVerifier = null;
|
|
|
|
before(function() {
|
|
// Replace the JWT Verfier with a stub to capture the value
|
|
// extracted from the request
|
|
mockVerifier = sinon.stub();
|
|
mockVerifier.callsArgWith(3, null, test_data.valid_jwt.payload);
|
|
Strategy.JwtVerifier = mockVerifier;
|
|
});
|
|
|
|
|
|
|
|
describe('handling request JWT present in request', function() {
|
|
var strategy;
|
|
|
|
before(function(done) {
|
|
strategy = new Strategy({
|
|
jwtFromRequest: function (r) { return test_data.valid_jwt.token; },
|
|
secretOrKey: 'secret'
|
|
},
|
|
function(jwt_payload, next) {
|
|
// Return values aren't important in this case
|
|
return next(null, {}, {});
|
|
}
|
|
);
|
|
|
|
mockVerifier.reset();
|
|
|
|
chai.passport.use(strategy)
|
|
.success(function(u, i) {
|
|
done();
|
|
})
|
|
.authenticate();
|
|
});
|
|
|
|
|
|
it("verifies the right jwt", function() {
|
|
sinon.assert.calledOnce(mockVerifier);
|
|
expect(mockVerifier.args[0][0]).to.equal(test_data.valid_jwt.token);
|
|
});
|
|
});
|
|
|
|
|
|
|
|
describe('handling request with NO JWT', function() {
|
|
|
|
var info;
|
|
|
|
before(function(done) {
|
|
strategy = new Strategy({jwtFromRequest: function(r) {}, secretOrKey: 'secret'}, function(jwt_payload, next) {
|
|
// Return values aren't important in this case
|
|
return next(null, {}, {});
|
|
});
|
|
|
|
mockVerifier.reset();
|
|
|
|
chai.passport.use(strategy)
|
|
.fail(function(i) {
|
|
info = i
|
|
done();
|
|
})
|
|
.req(function(req) {
|
|
req.body = {}
|
|
})
|
|
.authenticate();
|
|
});
|
|
|
|
|
|
it('should fail authentication', function() {
|
|
expect(info).to.be.an.object;
|
|
expect(info.message).to.equal("No auth token");
|
|
});
|
|
|
|
|
|
it('Should not try to verify anything', function() {
|
|
sinon.assert.notCalled(mockVerifier);
|
|
});
|
|
|
|
});
|
|
|
|
describe('handling request url set to url.Url instead of string', function() {
|
|
|
|
var info;
|
|
|
|
before(function(done) {
|
|
strategy = new Strategy({jwtFromRequest: function(r) {}, secretOrKey: 'secret'}, function(jwt_payload, next) {
|
|
// Return values aren't important in this case
|
|
return next(null, {}, {});
|
|
});
|
|
|
|
mockVerifier.reset();
|
|
|
|
chai.passport.use(strategy)
|
|
.fail(function(i) {
|
|
info = i
|
|
done();
|
|
})
|
|
.req(function(req) {
|
|
req.body = {};
|
|
req.url = new url.Url('/');
|
|
})
|
|
.authenticate();
|
|
});
|
|
|
|
|
|
it('should fail authentication', function() {
|
|
expect(info).to.be.an.object;
|
|
expect(info.message).to.equal("No auth token");
|
|
});
|
|
|
|
});
|
|
|
|
|
|
});
|