<commit_before>package auth

import (
	"net/http"
	"testing"

	"github.com/micro/go-micro/v2/auth"
)

func TestNamespaceFromRequest(t *testing.T) {
	tt := []struct {
		Host      string
		Namespace string
	}{
		{Host: "micro.mu", Namespace: auth.DefaultNamespace},
		{Host: "micro.com.au", Namespace: auth.DefaultNamespace},
		{Host: "web.micro.mu", Namespace: auth.DefaultNamespace},
		{Host: "api.micro.mu", Namespace: auth.DefaultNamespace},
		{Host: "myapp.com", Namespace: auth.DefaultNamespace},
		{Host: "staging.myapp.com", Namespace: "staging"},
		{Host: "staging.myapp.m3o.app", Namespace: "myapp.staging"},
		{Host: "127.0.0.1", Namespace: auth.DefaultNamespace},
		{Host: "localhost", Namespace: auth.DefaultNamespace},
		{Host: "172.16.17.32", Namespace: auth.DefaultNamespace},
	}

	h := &authHandler{namespace: "domain"}

	for _, tc := range tt {
		t.Run(tc.Host, func(t *testing.T) {
			ns := h.NamespaceFromRequest(&http.Request{Host: tc.Host})
			if ns != tc.Namespace {
				t.Errorf("Expected namespace %v for host %v, actually got %v", tc.Namespace, tc.Host, ns)
			}
		})
	}
}
<commit_msg>Fix Tests<commit_after>package auth

import (
	"net/http"
	"net/url"
	"testing"

	"github.com/micro/go-micro/v2/auth"
)

func TestNamespaceFromRequest(t *testing.T) {
	tt := []struct {
		Host      string
		Namespace string
	}{
		{Host: "micro.mu", Namespace: auth.DefaultNamespace},
		{Host: "micro.com.au", Namespace: auth.DefaultNamespace},
		{Host: "web.micro.mu", Namespace: auth.DefaultNamespace},
		{Host: "api.micro.mu", Namespace: auth.DefaultNamespace},
		{Host: "myapp.com", Namespace: auth.DefaultNamespace},
		{Host: "staging.myapp.com", Namespace: "staging"},
		{Host: "staging.myapp.m3o.app", Namespace: "myapp.staging"},
		{Host: "127.0.0.1", Namespace: auth.DefaultNamespace},
		{Host: "localhost", Namespace: auth.DefaultNamespace},
		{Host: "172.16.17.32", Namespace: auth.DefaultNamespace},
	}

	h := &authHandler{namespace: "domain"}

	for _, tc := range tt {
		t.Run(tc.Host, func(t *testing.T) {
			ns := h.NamespaceFromRequest(&http.Request{Host: tc.Host, URL: &url.URL{Host: tc.Host}})
			if ns != tc.Namespace {
				t.Errorf("Expected namespace %v for host %v, actually got %v", tc.Namespace, tc.Host, ns)
			}
		})
	}
}

{'fraction_non_alphanumeric': 0.18048780487804877, 'fraction_numerical': 0.01507760532150776, 'mean_word_length': 4.295774647887324, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7363066', 'n_tokens_mistral': 902, 'n_tokens_neox': 834, 'n_words': 171}