-
Notifications
You must be signed in to change notification settings - Fork 24
Add prettier to repo #223
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
Merged
Merged
Add prettier to repo #223
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 @@ | ||
src/authzedapi | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ignores generated code |
This file contains hidden or 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 hidden or 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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
/** | ||
* Generates a random token with a prefix to support | ||
* unique, idempotent local testing. | ||
* @param prefix | ||
* @returns | ||
* @param prefix | ||
* @returns | ||
*/ | ||
export function generateTestToken(prefix: string): string { | ||
return `${prefix}-${Date.now().toString()}` | ||
} | ||
return `${prefix}-${Date.now().toString()}`; | ||
} |
This file contains hidden or 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 hidden or 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 |
---|---|---|
@@ -1,85 +1,90 @@ | ||
import { ClientSecurity } from "./util.js"; | ||
import * as v1 from "./v1.js"; | ||
import { Consistency } from "./v1.js"; | ||
import { generateTestToken } from './__utils__/helpers.js' | ||
import { describe, it, expect } from 'vitest' | ||
import { generateTestToken } from "./__utils__/helpers.js"; | ||
import { describe, it, expect } from "vitest"; | ||
|
||
describe("a check following a write of schema and relationships", () => { | ||
it("should succeed", () => new Promise<void>((done) => { | ||
// Write the schema. | ||
const token = generateTestToken('full-test') | ||
const v1client = v1.NewClient(token, "localhost:50051", ClientSecurity.INSECURE_LOCALHOST_ALLOWED); | ||
it("should succeed", () => | ||
new Promise<void>((done) => { | ||
// Write the schema. | ||
const token = generateTestToken("full-test"); | ||
const v1client = v1.NewClient( | ||
token, | ||
"localhost:50051", | ||
ClientSecurity.INSECURE_LOCALHOST_ALLOWED, | ||
); | ||
|
||
const writeSchemaRequest = v1.WriteSchemaRequest.create({ | ||
schema: ` | ||
const writeSchemaRequest = v1.WriteSchemaRequest.create({ | ||
schema: ` | ||
definition test/user {} | ||
|
||
definition test/resource { | ||
relation viewer: test/user | ||
permission view = viewer | ||
} | ||
`, | ||
}); | ||
|
||
v1client.writeSchema(writeSchemaRequest, function (err) { | ||
expect(err).toBe(null); | ||
|
||
// Create the relationship between the resource and the user. | ||
const resource = v1.ObjectReference.create({ | ||
objectType: "test/resource", | ||
objectId: "someresource", | ||
}); | ||
|
||
// Create the user reference. | ||
const userref = v1.ObjectReference.create({ | ||
objectType: "test/user", | ||
objectId: "someuser", | ||
}); | ||
|
||
const user = v1.SubjectReference.create({ | ||
object: userref, | ||
}); | ||
|
||
const relationship = v1.Relationship.create({ | ||
resource, | ||
relation: "viewer", | ||
subject: user, | ||
}); | ||
v1client.writeSchema(writeSchemaRequest, function (err) { | ||
expect(err).toBe(null); | ||
|
||
const update = v1.RelationshipUpdate.create({ | ||
operation: v1.RelationshipUpdate_Operation.CREATE, | ||
relationship: relationship, | ||
}); | ||
// Create the relationship between the resource and the user. | ||
const resource = v1.ObjectReference.create({ | ||
objectType: "test/resource", | ||
objectId: "someresource", | ||
}); | ||
|
||
// Write the relationship. | ||
const writeRequest = v1.WriteRelationshipsRequest.create({ | ||
updates: [update], | ||
}); | ||
// Create the user reference. | ||
const userref = v1.ObjectReference.create({ | ||
objectType: "test/user", | ||
objectId: "someuser", | ||
}); | ||
|
||
v1client.writeRelationships(writeRequest, function (err, response) { | ||
expect(err).toBe(null); | ||
expect(response).toBeTruthy(); | ||
const user = v1.SubjectReference.create({ | ||
object: userref, | ||
}); | ||
|
||
const checkPermissionRequest = v1.CheckPermissionRequest.create({ | ||
const relationship = v1.Relationship.create({ | ||
resource, | ||
permission: "view", | ||
relation: "viewer", | ||
subject: user, | ||
consistency: Consistency.create({ | ||
requirement: { | ||
oneofKind: "fullyConsistent", | ||
fullyConsistent: true, | ||
}, | ||
}) | ||
}); | ||
|
||
v1client.checkPermission(checkPermissionRequest, (err, response) => { | ||
const update = v1.RelationshipUpdate.create({ | ||
operation: v1.RelationshipUpdate_Operation.CREATE, | ||
relationship: relationship, | ||
}); | ||
|
||
// Write the relationship. | ||
const writeRequest = v1.WriteRelationshipsRequest.create({ | ||
updates: [update], | ||
}); | ||
|
||
v1client.writeRelationships(writeRequest, function (err, response) { | ||
expect(err).toBe(null); | ||
expect(response?.permissionship).toBe( | ||
v1.CheckPermissionResponse_Permissionship.HAS_PERMISSION | ||
); | ||
done(); | ||
expect(response).toBeTruthy(); | ||
|
||
const checkPermissionRequest = v1.CheckPermissionRequest.create({ | ||
resource, | ||
permission: "view", | ||
subject: user, | ||
consistency: Consistency.create({ | ||
requirement: { | ||
oneofKind: "fullyConsistent", | ||
fullyConsistent: true, | ||
}, | ||
}), | ||
}); | ||
|
||
v1client.checkPermission(checkPermissionRequest, (err, response) => { | ||
expect(err).toBe(null); | ||
expect(response?.permissionship).toBe( | ||
v1.CheckPermissionResponse_Permissionship.HAS_PERMISSION, | ||
); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
})); | ||
})); | ||
}); |
This file contains hidden or 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
"use strict"; | ||
|
||
export * as protobuf from './protobuf.js'; | ||
export * as v1 from './v1.js'; | ||
export * as protobuf from "./protobuf.js"; | ||
export * as v1 from "./v1.js"; |
This file contains hidden or 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export * from './authzedapi/google/protobuf/descriptor.js'; | ||
export * from './authzedapi/google/protobuf/duration.js'; | ||
export * from './authzedapi/google/protobuf/struct.js'; | ||
export * from './authzedapi/google/protobuf/timestamp.js'; | ||
export * from "./authzedapi/google/protobuf/descriptor.js"; | ||
export * from "./authzedapi/google/protobuf/duration.js"; | ||
export * from "./authzedapi/google/protobuf/struct.js"; | ||
export * from "./authzedapi/google/protobuf/timestamp.js"; |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the CI configuration