feat: write forgejo local instance URL to json file and port tests read it
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
This commit is contained in:
parent
fa0fb859fe
commit
8551a60d46
2 changed files with 4 additions and 2 deletions
|
@ -307,6 +307,7 @@ class Forgejo:
|
||||||
data["login"] = self.username
|
data["login"] = self.username
|
||||||
data["email"] = self.email
|
data["email"] = self.email
|
||||||
data["repo"] = repo
|
data["repo"] = repo
|
||||||
|
data["forgejo_url"] = self.get_uri("")
|
||||||
content = json.dumps(data)
|
content = json.dumps(data)
|
||||||
f.write(content)
|
f.write(content)
|
||||||
print(f"Wrote access token to {file}")
|
print(f"Wrote access token to {file}")
|
||||||
|
|
|
@ -5,14 +5,15 @@
|
||||||
import Forgejo from "./index";
|
import Forgejo from "./index";
|
||||||
import authtoken from "../secrets/user1-accesstoken.json";
|
import authtoken from "../secrets/user1-accesstoken.json";
|
||||||
|
|
||||||
|
const forgeoUrl = authtoken["forgejo_url"];
|
||||||
const token = authtoken["sha1"];
|
const token = authtoken["sha1"];
|
||||||
const username = authtoken["login"];
|
const username = authtoken["login"];
|
||||||
const repo = authtoken["repo"];
|
const repo = authtoken["repo"];
|
||||||
const api = new Forgejo("http://localhost:3000", "owner_user");
|
const api = new Forgejo(forgeoUrl, "owner_user");
|
||||||
api.setTokenAuth(token);
|
api.setTokenAuth(token);
|
||||||
|
|
||||||
test("use authentication without setting it ", () => {
|
test("use authentication without setting it ", () => {
|
||||||
const api = new Forgejo("http://localhost:3000", "owner_user");
|
const api = new Forgejo(forgeoUrl, "owner_user");
|
||||||
|
|
||||||
expect(() => api.getTokenAuth()).toThrow();
|
expect(() => api.getTokenAuth()).toThrow();
|
||||||
api.setTokenAuth(token);
|
api.setTokenAuth(token);
|
||||||
|
|
Loading…
Reference in a new issue