Files
pmg/proxy/interceptors/pypi_registry_test.go
Sahil BansalandGitHub 8e563ee5a1 Skip mitm for unsupported registries (#185)
* implement mitm decider for npm

* fix: Skip MITM for registries not supported for analysis
2026-03-24 21:50:13 +05:30

32 lines
816 B
Go

package interceptors
import (
"testing"
"github.com/safedep/pmg/proxy"
"github.com/stretchr/testify/assert"
)
func TestPypiRegistryInterceptor_ShouldMITM(t *testing.T) {
interceptor := NewPypiRegistryInterceptor(nil, nil, nil, nil)
tests := []struct {
name string
hostname string
wantMITM bool
}{
{"pypi files is MITM'd", "files.pythonhosted.org", true},
{"pypi org is MITM'd", "pypi.org", true},
{"test pypi is NOT MITM'd", "test.pypi.org", false},
{"test pypi files is NOT MITM'd", "test-files.pythonhosted.org", false},
{"unknown registry is NOT MITM'd", "registry.example.com", false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ctx := &proxy.RequestContext{Hostname: tt.hostname}
assert.Equal(t, tt.wantMITM, interceptor.ShouldMITM(ctx))
})
}
}