Compare commits

...

2 Commits

Author SHA1 Message Date
Aravinth Manivannan 914302e208
feat: user cors in local dev forgejo
ci/woodpecker/push/woodpecker Pipeline was successful Details
2023-09-19 03:37:09 +05:30
Aravinth Manivannan 674815ca70
feat: autoset username 2023-09-19 03:36:40 +05:30
3 changed files with 8 additions and 12 deletions

View File

@ -16,4 +16,4 @@ services:
volumes:
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
- ./integration/conf/app.ini:/data/gitea/conf/app.ini
- ./integration/conf/app.ini:/data/gitea/conf/app.ini:wo

View File

@ -9,14 +9,10 @@ const forgeoUrl = authtoken["forgejo_url"];
const token = authtoken["sha1"];
const username = authtoken["login"];
const repo = authtoken["repo"];
const api = new Forgejo(forgeoUrl, "owner_user");
api.setTokenAuth(token);
const api = new Forgejo(forgeoUrl);
test("use authentication without setting it ", () => {
const api = new Forgejo(forgeoUrl, "owner_user");
expect(() => api.getTokenAuth()).toThrow();
api.setTokenAuth(token);
test("use authentication without setting it ", async () => {
await api.setTokenAuth(token);
expect(api.getTokenAuth().getToken()).toBe(token);
let headers = api.getTokenAuthHeader();
expect(headers.Authorization).toBe(`token ${token}`);

View File

@ -17,19 +17,19 @@ class Forgejo {
* Represents a Forgejo instance.
* @constructor
* @param {string} url - The URL of the Forgejo instance
* @param {string} username - username of the logged in user
*/
constructor(url: string, username: string) {
constructor(url: string) {
this.url = new URL(url);
this.username = username;
}
/**
* Authenticate with token
* @param {Auth} token - access token
*/
setTokenAuth(token: string) {
async setTokenAuth(token: string) {
this.token = new Auth(token);
let res = await this.getUser();
this.username = res.username;
}
/**