summaryrefslogtreecommitdiff
path: root/internal/util
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2024-02-06 14:44:18 +0100
committerJeroen Wijenbergh <46386452+jwijenbergh@users.noreply.github.com>2024-02-19 14:15:07 +0100
commit4d26c8489b09acc98128715e9a2ed67558eb8105 (patch)
tree0ed8f4c95c12e501bc1a78c646c707ed6618936b /internal/util
parent3fd29f3e1c963196cac69fcbb9d68116f7ea80ec (diff)
Util + OAuth: Delete internal OAuth implementation
Preparing to move to github.com/jwijenbergh/eduoauth-go
Diffstat (limited to 'internal/util')
-rw-r--r--internal/util/util.go11
-rw-r--r--internal/util/util_test.go24
2 files changed, 1 insertions, 34 deletions
diff --git a/internal/util/util.go b/internal/util/util.go
index 85c4b37..97b4151 100644
--- a/internal/util/util.go
+++ b/internal/util/util.go
@@ -2,23 +2,12 @@
package util
import (
- "crypto/rand"
"fmt"
"net/url"
"os"
"strings"
)
-// MakeRandomByteSlice creates a cryptographically random bytes slice of `size`
-// It returns the byte slice (or nil if error) and an error if it could not be generated.
-func MakeRandomByteSlice(n int) ([]byte, error) {
- bs := make([]byte, n)
- if _, err := rand.Read(bs); err != nil {
- return nil, errors.WrapPrefix(err, "failed reading random", 0)
- }
- return bs, nil
-}
-
// EnsureDirectory creates a directory with permission 700.
func EnsureDirectory(dir string) error {
// Create with 700 permissions, read, write, execute only for the owner
diff --git a/internal/util/util_test.go b/internal/util/util_test.go
index 5e19f57..827fbe1 100644
--- a/internal/util/util_test.go
+++ b/internal/util/util_test.go
@@ -1,28 +1,6 @@
package util
-import (
- "bytes"
- "testing"
-)
-
-func TestMakeRandomByteSlice(t *testing.T) {
- random, randomErr := MakeRandomByteSlice(32)
- if randomErr != nil {
- t.Fatalf("Got: %v, want: nil", randomErr)
- }
- if len(random) != 32 {
- t.Fatalf("Got length: %d, want length: 32", len(random))
- }
-
- random2, randomErr2 := MakeRandomByteSlice(32)
- if randomErr2 != nil {
- t.Fatalf("2, Got: %v, want: nil", randomErr)
- }
-
- if bytes.Equal(random2, random) {
- t.Fatalf("Two random byteslices are the same: %v, %v", random2, random)
- }
-}
+import "testing"
func TestReplaceWAYF(t *testing.T) {
// We expect url encoding but the spaces to be correctly replace with a + instead of a %20