Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[![NodeJS with Webpack](https://github.com/Mickleran666/ethvalidate/actions/workflows/webpack.yml/badge.svg?event=delete)](https://github.com/Mickleran666/ethvalidate/actions/workflows/webpack.yml) #12393

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions console-ui/src/globalLib.js
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,7 @@ const request = (function(_global) {
}
const { accessToken = '' } = token;
accessTokenInHeader = accessToken;

}

return $.ajax(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,22 @@ protected <T> ResponseEntity<T> request(String path, MultiValueMap<String, Strin
HttpMethod httpMethod) {

HttpHeaders headers = new HttpHeaders();

HttpEntity<?> entity = new HttpEntity<T>(headers);

UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(this.base.toString() + path)
.queryParams(params);

return this.restTemplate.exchange(builder.toUriString(), httpMethod, entity, clazz);
}
protected <T> ResponseEntity<T> request(String path, MultiValueMap<String, String> params,MultiValueMap<String, String> headersMap, Class<T> clazz, HttpMethod httpMethod) {

HttpHeaders headers = new HttpHeaders();
headers.addAll(headersMap);
HttpEntity<?> entity = new HttpEntity<T>(headers);

UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(this.base.toString() + path).queryParams(params);

return this.restTemplate.exchange(builder.toUriString(), httpMethod, entity, clazz);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,38 +97,45 @@ protected void init(int port) throws Exception {
// Create a user:
ResponseEntity<String> response = request("/nacos/v1/auth/users",
Params.newParams().appendParam("username", username1).appendParam("password", password1)
.appendParam("accessToken", accessToken).done(), String.class, HttpMethod.POST);
.appendParam("accessToken", accessToken).done(),
Params.newParams().appendParam("Authorization", accessToken).done()
, String.class, HttpMethod.POST);
System.out.println(response);
assertTrue(response.getStatusCode().is2xxSuccessful());

// Create a user:
response = request("/nacos/v1/auth/users",
Params.newParams().appendParam("username", username2).appendParam("password", password2)
.appendParam("accessToken", accessToken).done(), String.class, HttpMethod.POST);
response = request("/nacos/v1/auth/users", Params.newParams().appendParam("username", username2).appendParam("password", password2)
.appendParam("accessToken", accessToken).done(),
Params.newParams().appendParam("Authorization", accessToken).done(),
String.class, HttpMethod.POST);

System.out.println(response);
assertTrue(response.getStatusCode().is2xxSuccessful());

// Create a user:
response = request("/nacos/v1/auth/users",
Params.newParams().appendParam("username", username3).appendParam("password", password3)
.appendParam("accessToken", accessToken).done(), String.class, HttpMethod.POST);
response = request("/nacos/v1/auth/users", Params.newParams().appendParam("username", username3).appendParam("password", password3)
.appendParam("accessToken", accessToken).done(),
Params.newParams().appendParam("Authorization", accessToken).done(),
String.class, HttpMethod.POST);

System.out.println(response);
assertTrue(response.getStatusCode().is2xxSuccessful());

// Create a role:
response = request("/nacos/v1/auth/roles",
Params.newParams().appendParam("role", role1).appendParam("username", username1)
.appendParam("accessToken", accessToken).done(), String.class, HttpMethod.POST);
Params.newParams().appendParam("role", role1).appendParam("username", username1).appendParam("accessToken", accessToken)
.done(),
Params.newParams().appendParam("Authorization", accessToken).done(),String.class, HttpMethod.POST);

System.out.println(response);
assertTrue(response.getStatusCode().is2xxSuccessful());

// Create a role:
response = request("/nacos/v1/auth/roles",
Params.newParams().appendParam("role", role2).appendParam("username", username2)
.appendParam("accessToken", accessToken).done(), String.class, HttpMethod.POST);
Params.newParams().appendParam("role", role2).appendParam("username", username2).appendParam("accessToken", accessToken)
.done(),
Params.newParams().appendParam("Authorization", accessToken).done(),
String.class, HttpMethod.POST);
System.out.println(response);
assertTrue(response.getStatusCode().is2xxSuccessful());

Expand All @@ -141,25 +148,25 @@ protected void init(int port) throws Exception {

// Add read permission of namespace1 to role1:
response = request("/nacos/v1/auth/permissions",
Params.newParams().appendParam("role", role1).appendParam("resource", namespace1 + ":*:*")
.appendParam("action", "r").appendParam("accessToken", accessToken).done(), String.class,
HttpMethod.POST);
Params.newParams().appendParam("role", role1).appendParam("resource", namespace1 + ":*:*").appendParam("action", "r")
.appendParam("accessToken", accessToken).done(),
Params.newParams().appendParam("Authorization", accessToken).done(),String.class, HttpMethod.POST);

System.out.println(response);
assertTrue(response.getStatusCode().is2xxSuccessful());

// Add write permission of namespace1 to role2:
response = request("/nacos/v1/auth/permissions",
Params.newParams().appendParam("role", role2).appendParam("resource", namespace1 + ":*:*")
.appendParam("action", "w").appendParam("accessToken", accessToken).done(), String.class,
HttpMethod.POST);
Params.newParams().appendParam("role", role2).appendParam("resource", namespace1 + ":*:*").appendParam("action", "w")
.appendParam("accessToken", accessToken).done(), Params.newParams().appendParam("Authorization", accessToken).done(),String.class, HttpMethod.POST);
System.out.println(response);
assertTrue(response.getStatusCode().is2xxSuccessful());

// Add read/write permission of namespace1 to role3:
response = request("/nacos/v1/auth/permissions",
Params.newParams().appendParam("role", role3).appendParam("resource", namespace1 + ":*:*")
.appendParam("action", "rw").appendParam("accessToken", accessToken).done(), String.class,
HttpMethod.POST);
Params.newParams().appendParam("role", role3).appendParam("resource", namespace1 + ":*:*").appendParam("action", "rw")
.appendParam("accessToken", accessToken).done(), Params.newParams().appendParam("Authorization", accessToken).done(), String.class, HttpMethod.POST);

System.out.println(response);
assertTrue(response.getStatusCode().is2xxSuccessful());

Expand All @@ -173,67 +180,62 @@ protected void destroy() {

// Delete permission:
ResponseEntity<String> response = request("/nacos/v1/auth/permissions",
Params.newParams().appendParam("role", role1).appendParam("resource", namespace1 + ":*:*")
.appendParam("action", "r").appendParam("accessToken", accessToken).done(), String.class,
HttpMethod.DELETE);
Params.newParams().appendParam("role", role1).appendParam("resource", namespace1 + ":*:*").appendParam("action", "r")
.appendParam("accessToken", accessToken).done(), Params.newParams().appendParam("Authorization", accessToken).done(),String.class, HttpMethod.DELETE);


assertTrue(response.getStatusCode().is2xxSuccessful());

// Delete permission:
response = request("/nacos/v1/auth/permissions",
Params.newParams().appendParam("role", role2).appendParam("resource", namespace1 + ":*:*")
.appendParam("action", "w").appendParam("accessToken", accessToken).done(), String.class,
HttpMethod.DELETE);
Params.newParams().appendParam("role", role2).appendParam("resource", namespace1 + ":*:*").appendParam("action", "w")
.appendParam("accessToken", accessToken).done(), Params.newParams().appendParam("Authorization", accessToken).done(),String.class, HttpMethod.DELETE);


assertTrue(response.getStatusCode().is2xxSuccessful());

// Delete permission:
response = request("/nacos/v1/auth/permissions",
Params.newParams().appendParam("role", role3).appendParam("resource", namespace1 + ":*:*")
.appendParam("action", "rw").appendParam("accessToken", accessToken).done(), String.class,
HttpMethod.DELETE);

assertTrue(response.getStatusCode().is2xxSuccessful());

// Delete a role:
response = request("/nacos/v1/auth/roles",
Params.newParams().appendParam("role", role1).appendParam("username", username1)
.appendParam("accessToken", accessToken).done(), String.class, HttpMethod.DELETE);
Params.newParams().appendParam("role", role3).appendParam("resource", namespace1 + ":*:*").appendParam("action", "rw")
.appendParam("accessToken", accessToken).done(), Params.newParams().appendParam("Authorization", accessToken).done(), String.class, HttpMethod.DELETE);


assertTrue(response.getStatusCode().is2xxSuccessful());

// Delete a role:
response = request("/nacos/v1/auth/roles",
Params.newParams().appendParam("role", role2).appendParam("username", username2)
.appendParam("accessToken", accessToken).done(), String.class, HttpMethod.DELETE);

Params.newParams().appendParam("role", role1).appendParam("username", username1).appendParam("accessToken", accessToken)
.done(), Params.newParams().appendParam("Authorization", accessToken).done(),String.class, HttpMethod.DELETE);
assertTrue(response.getStatusCode().is2xxSuccessful());

// Delete a role:
response = request("/nacos/v1/auth/roles",
Params.newParams().appendParam("role", role3).appendParam("username", username3)
.appendParam("accessToken", accessToken).done(), String.class, HttpMethod.DELETE);
Params.newParams().appendParam("role", role3).appendParam("username", username3).appendParam("accessToken", accessToken)
.done(), Params.newParams().appendParam("Authorization", accessToken).done(), String.class, HttpMethod.DELETE);

assertTrue(response.getStatusCode().is2xxSuccessful());

// Delete a user:
response = request("/nacos/v1/auth/users",
Params.newParams().appendParam("username", username1).appendParam("password", password1)
.appendParam("accessToken", accessToken).done(), String.class, HttpMethod.DELETE);
response = request("/nacos/v1/auth/users", Params.newParams().appendParam("username", username1).appendParam("password", password1)
.appendParam("accessToken", accessToken).done(), Params.newParams().appendParam("Authorization", accessToken).done(), String.class, HttpMethod.DELETE);


assertTrue(response.getStatusCode().is2xxSuccessful());

// Delete a user:
response = request("/nacos/v1/auth/users",
Params.newParams().appendParam("username", username2).appendParam("password", password2)
.appendParam("accessToken", accessToken).done(), String.class, HttpMethod.DELETE);

response = request("/nacos/v1/auth/users", Params.newParams().appendParam("username", username2).appendParam("password", password2)
.appendParam("accessToken", accessToken).done(),
Params.newParams().appendParam("Authorization", accessToken).done(),
String.class, HttpMethod.DELETE);


assertTrue(response.getStatusCode().is2xxSuccessful());

// Delete a user:
response = request("/nacos/v1/auth/users",
Params.newParams().appendParam("username", username3).appendParam("password", password3)
.appendParam("accessToken", accessToken).done(), String.class, HttpMethod.DELETE);
response = request("/nacos/v1/auth/users", Params.newParams().appendParam("username", username3).appendParam("password", password3)
.appendParam("accessToken", accessToken).done(), Params.newParams().appendParam("Authorization", accessToken).done(), String.class, HttpMethod.DELETE);


assertTrue(response.getStatusCode().is2xxSuccessful());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ void destroy() {

// Delete permission:
ResponseEntity<String> response = request("/nacos/v1/auth/permissions",
Params.newParams().appendParam("role", "role1").appendParam("resource", "public:*:*")
.appendParam("action", "rw").appendParam("accessToken", accessToken).done(), String.class,
HttpMethod.DELETE);
Params.newParams().appendParam("role", "role1").appendParam("resource", "public:*:*").appendParam("action", "rw")
.appendParam("accessToken", accessToken).done(),
String.class, HttpMethod.DELETE);

assertTrue(response.getStatusCode().is2xxSuccessful());

// Delete permission:
Expand Down
Loading