indieauth_test.go 993 B

1234567891011121314151617181920212223242526272829303132333435
  1. package indieauth
  2. import (
  3. "testing"
  4. "github.com/owncast/owncast/utils"
  5. )
  6. func TestLimitGlobalPendingRequests(t *testing.T) {
  7. // Simulate 10 pending requests
  8. for i := 0; i < maxPendingRequests-1; i++ {
  9. cid, _ := utils.GenerateRandomString(10)
  10. redirectURL, _ := utils.GenerateRandomString(10)
  11. cc, _ := utils.GenerateRandomString(10)
  12. state, _ := utils.GenerateRandomString(10)
  13. me, _ := utils.GenerateRandomString(10)
  14. _, err := StartServerAuth(cid, redirectURL, cc, state, me)
  15. if err != nil {
  16. t.Error("Registration should be permitted.", i, " of ", len(pendingAuthRequests), err)
  17. }
  18. }
  19. // This should throw an error
  20. cid, _ := utils.GenerateRandomString(10)
  21. redirectURL, _ := utils.GenerateRandomString(10)
  22. cc, _ := utils.GenerateRandomString(10)
  23. state, _ := utils.GenerateRandomString(10)
  24. me, _ := utils.GenerateRandomString(10)
  25. _, err := StartServerAuth(cid, redirectURL, cc, state, me)
  26. if err == nil {
  27. t.Error("Registration should not be permitted.")
  28. }
  29. }