Files
openfsd/protocol/vatsimauth/vatsimauth_test.go
Reese Norris 57d54d6705 v0.1.0-alpha
Changes:
- Implement bootstrapping library for managing several concurrent internal services
- Refactor concurrency model for connections/logical clients and their associated I/O
- Refactor server context singleton
- Refactor error handling
    - Most errors are now gracefully sent to the FSD client directly encoded as an $ER packet,
      enhancing visibility and debugging
    - Most errors are now rightfully treated as non-fatal
- Refactor package/dependency graph
- Refactor calling conventions/interfaces for many packages
- Refactor database package
- Refactor post office

Features:
- Add VATSIM-esque HTTP/JSON "data feed"
- Add ephemeral in-memory database option
- Add user management REST API
- Add improved web interface
- Add MySQL support (drop SQLite support)
2024-10-07 12:50:39 -07:00

36 lines
853 B
Go

package vatsimauth
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestVatsimAuth(t *testing.T) {
// vPilot clientID and key
v := NewVatsimAuth(35044, Keys[35044])
assert.NotNil(t, v)
// Initial challenge
// $DISERVER:CLIENT:VATSIM FSD V3.43:30984979d8caed23
v.SetInitialChallenge("30984979d8caed23")
// First challenge from server
// $ZCSERVER:N12345:de6acb8e
res := v.GenerateResponse("de6acb8e")
// Expected response:
// $ZRN12345:SERVER:f8ee97157f66455ed6108fccef6ccf5f
assert.Equal(t, "f8ee97157f66455ed6108fccef6ccf5f", res)
v.UpdateState(res)
// Second challenge from server
// $ZCSERVER:N12345:65b479573b0e
res = v.GenerateResponse("65b479573b0e")
// Expected response
// $ZRN12345:SERVER:8953f545c4e0ffd20943ad89b8ddd087
assert.Equal(t, "8953f545c4e0ffd20943ad89b8ddd087", res)
v.UpdateState(res)
}