at_guard_test.go 926 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package server
  2. import "testing"
  3. func TestValidateATCommandBlocksTrafficMessagingAndDialActions(t *testing.T) {
  4. t.Parallel()
  5. for _, command := range []string{
  6. "AT+CGATT=1",
  7. "AT+CGACT=1,1",
  8. "AT+CGDATA=\"PPP\",1",
  9. "AT+QNETDEVCTL=1,1,1",
  10. "AT+QIACT=1",
  11. "AT+CMGS=42",
  12. "AT+CMSS=7",
  13. "AT+CMGC=12",
  14. "AT+QCMGS=42",
  15. "AT+CUSD=1,\"*100#\"",
  16. "ATD12345;",
  17. "ATA",
  18. "ATH",
  19. "AT+CSQ; +CGACT = 1,1",
  20. "AT+CSQ;+CMSS=7",
  21. "AT+CSQ;D12345;",
  22. } {
  23. if err := validateATCommand(command); err == nil {
  24. t.Errorf("validateATCommand(%q) permitted a guarded mutation", command)
  25. }
  26. }
  27. }
  28. func TestValidateATCommandAllowsReadOnlyStatusQueries(t *testing.T) {
  29. t.Parallel()
  30. for _, command := range []string{
  31. "AT",
  32. "AT+CPIN?",
  33. "AT+CGATT?",
  34. "AT+CGACT?",
  35. "AT+CFUN?",
  36. "AT+CIMI",
  37. "AT+CCID",
  38. } {
  39. if err := validateATCommand(command); err != nil {
  40. t.Errorf("validateATCommand(%q): %v", command, err)
  41. }
  42. }
  43. }