-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: spacewander <[email protected]>
- Loading branch information
1 parent
88fb116
commit 8ded9c5
Showing
17 changed files
with
323 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright The HTNN Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package routepatch | ||
|
||
import ( | ||
"mosn.io/htnn/api/pkg/plugins" | ||
"mosn.io/htnn/types/plugins/routepatch" | ||
) | ||
|
||
func init() { | ||
plugins.RegisterPlugin(routepatch.Name, &plugin{}) | ||
} | ||
|
||
type plugin struct { | ||
routepatch.Plugin | ||
} | ||
|
||
func (p *plugin) ConfigTypeURL() string { | ||
return "" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
apiVersion: htnn.mosn.io/v1 | ||
kind: FilterPolicy | ||
metadata: | ||
name: policy | ||
namespace: default | ||
spec: | ||
targetRef: | ||
group: networking.istio.io | ||
kind: VirtualService | ||
name: default | ||
filters: | ||
routePatch: | ||
config: | ||
route: | ||
cluster_header: "Cluster-Name" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
- metadata: | ||
creationTimestamp: null | ||
name: htnn-h-default.local | ||
namespace: default | ||
spec: | ||
configPatches: | ||
- applyTo: HTTP_ROUTE | ||
match: | ||
routeConfiguration: | ||
vhost: | ||
name: default.local:80 | ||
route: | ||
name: default/default | ||
patch: | ||
operation: MERGE | ||
value: | ||
route: | ||
cluster_header: Cluster-Name | ||
status: {} | ||
- metadata: | ||
creationTimestamp: null | ||
name: htnn-http-filter | ||
namespace: istio-system | ||
spec: | ||
priority: -10 | ||
status: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright The HTNN Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package tests | ||
|
||
import ( | ||
"context" | ||
"net" | ||
"net/http" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"mosn.io/htnn/e2e/pkg/suite" | ||
) | ||
|
||
func init() { | ||
suite.Register(suite.Test{ | ||
Run: func(t *testing.T, suite *suite.Suite) { | ||
tr := &http.Transport{DialContext: func(ctx context.Context, proto, addr string) (conn net.Conn, err error) { | ||
return net.DialTimeout("tcp", ":18000", 1*time.Second) | ||
}} | ||
client := &http.Client{Transport: tr, Timeout: 10 * time.Second} | ||
rsp, err := client.Get("http://default.local:18000/echo") | ||
require.NoError(t, err) | ||
require.Equal(t, 403, rsp.StatusCode) | ||
rsp, err = client.Get("http://default.local:18000/echo2") | ||
require.NoError(t, err) | ||
require.Equal(t, 403, rsp.StatusCode) | ||
rsp, err = client.Get("http://default.local:18000/") | ||
require.NoError(t, err) | ||
require.Equal(t, 405, rsp.StatusCode) | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
apiVersion: networking.istio.io/v1beta1 | ||
kind: VirtualService | ||
metadata: | ||
name: vs | ||
namespace: istio-system | ||
spec: | ||
gateways: | ||
- default | ||
hosts: | ||
- "default.local" | ||
http: | ||
- match: | ||
- uri: | ||
prefix: /echo | ||
route: | ||
- destination: | ||
host: backend | ||
port: | ||
number: 8080 | ||
- match: | ||
- uri: | ||
prefix: /echo2 | ||
route: | ||
- destination: | ||
host: backend | ||
port: | ||
number: 8080 | ||
- match: | ||
- uri: | ||
prefix: / | ||
name: last | ||
route: | ||
- destination: | ||
host: backend | ||
port: | ||
number: 8080 | ||
--- | ||
apiVersion: htnn.mosn.io/v1 | ||
kind: FilterPolicy | ||
metadata: | ||
name: policy | ||
namespace: istio-system | ||
spec: | ||
targetRef: | ||
group: networking.istio.io | ||
kind: VirtualService | ||
name: vs | ||
filters: | ||
routePatch: | ||
config: | ||
directResponse: | ||
status: 403 | ||
--- | ||
apiVersion: htnn.mosn.io/v1 | ||
kind: FilterPolicy | ||
metadata: | ||
name: policy2 | ||
namespace: istio-system | ||
spec: | ||
targetRef: | ||
group: networking.istio.io | ||
kind: VirtualService | ||
name: vs | ||
sectionName: last | ||
filters: | ||
routePatch: | ||
config: | ||
directResponse: | ||
status: 405 |
Oops, something went wrong.